v2: Define API service interfaces

Define interfaces that reflect service (Accounting, Container, Session)
declarations in the API.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-08-22 12:28:33 +03:00 committed by Stanislav Bogatyrev
parent ecb0a4be67
commit 55a6509e8f
6 changed files with 148 additions and 112 deletions

View file

@ -9,26 +9,10 @@ type BalanceRequestBody struct {
ownerID *refs.OwnerID ownerID *refs.OwnerID
} }
type BalanceRequest struct {
body *BalanceRequestBody
metaHeader *session.RequestMetaHeader
verifyHeader *session.RequestVerificationHeader
}
type BalanceResponseBody struct { type BalanceResponseBody struct {
bal *Decimal bal *Decimal
} }
type BalanceResponse struct {
body *BalanceResponseBody
metaHeader *session.ResponseMetaHeader
verifyHeader *session.ResponseVerificationHeader
}
type Decimal struct { type Decimal struct {
val int64 val int64

27
v2/accounting/service.go Normal file
View file

@ -0,0 +1,27 @@
package accounting
import (
"context"
"github.com/nspcc-dev/neofs-api-go/v2/session"
)
type Service interface {
Balance(context.Context, *BalanceRequest) (*BalanceResponse, error)
}
type BalanceRequest struct {
body *BalanceRequestBody
metaHeader *session.RequestMetaHeader
verifyHeader *session.RequestVerificationHeader
}
type BalanceResponse struct {
body *BalanceResponseBody
metaHeader *session.ResponseMetaHeader
verifyHeader *session.ResponseVerificationHeader
}

96
v2/container/service.go Normal file
View file

@ -0,0 +1,96 @@
package container
import (
"context"
"github.com/nspcc-dev/neofs-api-go/v2/session"
)
type Service interface {
Put(context.Context, *PutRequest) (*PutResponse, error)
Delete(context.Context, *DeleteRequest) (*DeleteResponse, error)
Get(context.Context, *GetRequest) (*GetResponse, error)
List(context.Context, *ListRequest) (*ListResponse, error)
SetExtendedACL(context.Context, *SetExtendedACLRequest) (*SetExtendedACLResponse, error)
GetExtendedACL(context.Context, *GetExtendedACLRequest) (*GetExtendedACLResponse, error)
}
type PutRequest struct {
body *PutRequestBody
metaHeader *session.RequestMetaHeader
verifyHeader *session.RequestVerificationHeader
}
type PutResponse struct {
body *PutResponseBody
metaHeader *session.ResponseMetaHeader
verifyHeader *session.ResponseVerificationHeader
}
type DeleteRequest struct {
body *DeleteRequestBody
metaHeader *session.RequestMetaHeader
verifyHeader *session.RequestVerificationHeader
}
type DeleteResponse struct {
body *DeleteResponseBody
metaHeader *session.ResponseMetaHeader
verifyHeader *session.ResponseVerificationHeader
}
type ListRequest struct {
body *ListRequestBody
metaHeader *session.RequestMetaHeader
verifyHeader *session.RequestVerificationHeader
}
type ListResponse struct {
body *ListResponseBody
metaHeader *session.ResponseMetaHeader
verifyHeader *session.ResponseVerificationHeader
}
type SetExtendedACLRequest struct {
body *SetExtendedACLRequestBody
metaHeader *session.RequestMetaHeader
verifyHeader *session.RequestVerificationHeader
}
type SetExtendedACLResponse struct {
body *SetExtendedACLResponseBody
metaHeader *session.ResponseMetaHeader
verifyHeader *session.ResponseVerificationHeader
}
type GetExtendedACLRequest struct {
body *GetExtendedACLRequestBody
metaHeader *session.RequestMetaHeader
verifyHeader *session.RequestVerificationHeader
}
type GetExtendedACLResponse struct {
body *GetExtendedACLResponseBody
metaHeader *session.ResponseMetaHeader
verifyHeader *session.ResponseVerificationHeader
}

View file

@ -31,26 +31,10 @@ type PutRequestBody struct {
sig *refs.Signature sig *refs.Signature
} }
type PutRequest struct {
body *PutRequestBody
metaHeader *session.RequestMetaHeader
verifyHeader *session.RequestVerificationHeader
}
type PutResponseBody struct { type PutResponseBody struct {
cid *refs.ContainerID cid *refs.ContainerID
} }
type PutResponse struct {
body *PutResponseBody
metaHeader *session.ResponseMetaHeader
verifyHeader *session.ResponseVerificationHeader
}
type GetRequestBody struct { type GetRequestBody struct {
cid *refs.ContainerID cid *refs.ContainerID
} }
@ -81,98 +65,34 @@ type DeleteRequestBody struct {
sig *refs.Signature sig *refs.Signature
} }
type DeleteRequest struct {
body *DeleteRequestBody
metaHeader *session.RequestMetaHeader
verifyHeader *session.RequestVerificationHeader
}
type DeleteResponseBody struct{} type DeleteResponseBody struct{}
type DeleteResponse struct {
body *DeleteResponseBody
metaHeader *session.ResponseMetaHeader
verifyHeader *session.ResponseVerificationHeader
}
type ListRequestBody struct { type ListRequestBody struct {
ownerID *refs.OwnerID ownerID *refs.OwnerID
} }
type ListRequest struct {
body *ListRequestBody
metaHeader *session.RequestMetaHeader
verifyHeader *session.RequestVerificationHeader
}
type ListResponseBody struct { type ListResponseBody struct {
cidList []*refs.ContainerID cidList []*refs.ContainerID
} }
type ListResponse struct {
body *ListResponseBody
metaHeader *session.ResponseMetaHeader
verifyHeader *session.ResponseVerificationHeader
}
type SetExtendedACLRequestBody struct { type SetExtendedACLRequestBody struct {
eacl *acl.Table eacl *acl.Table
sig *refs.Signature sig *refs.Signature
} }
type SetExtendedACLRequest struct {
body *SetExtendedACLRequestBody
metaHeader *session.RequestMetaHeader
verifyHeader *session.RequestVerificationHeader
}
type SetExtendedACLResponseBody struct{} type SetExtendedACLResponseBody struct{}
type SetExtendedACLResponse struct {
body *SetExtendedACLResponseBody
metaHeader *session.ResponseMetaHeader
verifyHeader *session.ResponseVerificationHeader
}
type GetExtendedACLRequestBody struct { type GetExtendedACLRequestBody struct {
cid *refs.ContainerID cid *refs.ContainerID
} }
type GetExtendedACLRequest struct {
body *GetExtendedACLRequestBody
metaHeader *session.RequestMetaHeader
verifyHeader *session.RequestVerificationHeader
}
type GetExtendedACLResponseBody struct { type GetExtendedACLResponseBody struct {
eacl *acl.Table eacl *acl.Table
sig *refs.Signature sig *refs.Signature
} }
type GetExtendedACLResponse struct {
body *GetExtendedACLResponseBody
metaHeader *session.ResponseMetaHeader
verifyHeader *session.ResponseVerificationHeader
}
func (a *Attribute) GetKey() string { func (a *Attribute) GetKey() string {
if a != nil { if a != nil {
return a.key return a.key

25
v2/session/service.go Normal file
View file

@ -0,0 +1,25 @@
package session
import (
"context"
)
type Service interface {
Create(context.Context, *CreateRequest) (*CreateResponse, error)
}
type CreateRequest struct {
body *CreateRequestBody
metaHeader *RequestMetaHeader
verifyHeader *RequestVerificationHeader
}
type CreateResponse struct {
body *CreateResponseBody
metaHeader *ResponseMetaHeader
verifyHeader *ResponseVerificationHeader
}

View file

@ -11,28 +11,12 @@ type CreateRequestBody struct {
expiration uint64 expiration uint64
} }
type CreateRequest struct {
body *CreateRequestBody
metaHeader *RequestMetaHeader
verifyHeader *RequestVerificationHeader
}
type CreateResponseBody struct { type CreateResponseBody struct {
id []byte id []byte
sessionKey []byte sessionKey []byte
} }
type CreateResponse struct {
body *CreateResponseBody
metaHeader *ResponseMetaHeader
verifyHeader *ResponseVerificationHeader
}
type XHeader struct { type XHeader struct {
key, val string key, val string
} }