From 55a6509e8ff67e96598d63d875ceba689d666a63 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Sat, 22 Aug 2020 12:28:33 +0300 Subject: [PATCH] v2: Define API service interfaces Define interfaces that reflect service (Accounting, Container, Session) declarations in the API. Signed-off-by: Leonard Lyubich --- v2/accounting/accounting.go | 16 ------- v2/accounting/service.go | 27 +++++++++++ v2/container/service.go | 96 +++++++++++++++++++++++++++++++++++++ v2/container/types.go | 80 ------------------------------- v2/session/service.go | 25 ++++++++++ v2/session/types.go | 16 ------- 6 files changed, 148 insertions(+), 112 deletions(-) create mode 100644 v2/accounting/service.go create mode 100644 v2/container/service.go create mode 100644 v2/session/service.go diff --git a/v2/accounting/accounting.go b/v2/accounting/accounting.go index f2c0d984..619f2205 100644 --- a/v2/accounting/accounting.go +++ b/v2/accounting/accounting.go @@ -9,26 +9,10 @@ type BalanceRequestBody struct { ownerID *refs.OwnerID } -type BalanceRequest struct { - body *BalanceRequestBody - - metaHeader *session.RequestMetaHeader - - verifyHeader *session.RequestVerificationHeader -} - type BalanceResponseBody struct { bal *Decimal } -type BalanceResponse struct { - body *BalanceResponseBody - - metaHeader *session.ResponseMetaHeader - - verifyHeader *session.ResponseVerificationHeader -} - type Decimal struct { val int64 diff --git a/v2/accounting/service.go b/v2/accounting/service.go new file mode 100644 index 00000000..8443c66b --- /dev/null +++ b/v2/accounting/service.go @@ -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 +} diff --git a/v2/container/service.go b/v2/container/service.go new file mode 100644 index 00000000..f6640845 --- /dev/null +++ b/v2/container/service.go @@ -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 +} diff --git a/v2/container/types.go b/v2/container/types.go index ae4a3c11..0e53639b 100644 --- a/v2/container/types.go +++ b/v2/container/types.go @@ -31,26 +31,10 @@ type PutRequestBody struct { sig *refs.Signature } -type PutRequest struct { - body *PutRequestBody - - metaHeader *session.RequestMetaHeader - - verifyHeader *session.RequestVerificationHeader -} - type PutResponseBody struct { cid *refs.ContainerID } -type PutResponse struct { - body *PutResponseBody - - metaHeader *session.ResponseMetaHeader - - verifyHeader *session.ResponseVerificationHeader -} - type GetRequestBody struct { cid *refs.ContainerID } @@ -81,98 +65,34 @@ type DeleteRequestBody struct { sig *refs.Signature } -type DeleteRequest struct { - body *DeleteRequestBody - - metaHeader *session.RequestMetaHeader - - verifyHeader *session.RequestVerificationHeader -} - type DeleteResponseBody struct{} -type DeleteResponse struct { - body *DeleteResponseBody - - metaHeader *session.ResponseMetaHeader - - verifyHeader *session.ResponseVerificationHeader -} - type ListRequestBody struct { ownerID *refs.OwnerID } -type ListRequest struct { - body *ListRequestBody - - metaHeader *session.RequestMetaHeader - - verifyHeader *session.RequestVerificationHeader -} - type ListResponseBody struct { cidList []*refs.ContainerID } -type ListResponse struct { - body *ListResponseBody - - metaHeader *session.ResponseMetaHeader - - verifyHeader *session.ResponseVerificationHeader -} - type SetExtendedACLRequestBody struct { eacl *acl.Table sig *refs.Signature } -type SetExtendedACLRequest struct { - body *SetExtendedACLRequestBody - - metaHeader *session.RequestMetaHeader - - verifyHeader *session.RequestVerificationHeader -} - type SetExtendedACLResponseBody struct{} -type SetExtendedACLResponse struct { - body *SetExtendedACLResponseBody - - metaHeader *session.ResponseMetaHeader - - verifyHeader *session.ResponseVerificationHeader -} - type GetExtendedACLRequestBody struct { cid *refs.ContainerID } -type GetExtendedACLRequest struct { - body *GetExtendedACLRequestBody - - metaHeader *session.RequestMetaHeader - - verifyHeader *session.RequestVerificationHeader -} - type GetExtendedACLResponseBody struct { eacl *acl.Table sig *refs.Signature } -type GetExtendedACLResponse struct { - body *GetExtendedACLResponseBody - - metaHeader *session.ResponseMetaHeader - - verifyHeader *session.ResponseVerificationHeader -} - func (a *Attribute) GetKey() string { if a != nil { return a.key diff --git a/v2/session/service.go b/v2/session/service.go new file mode 100644 index 00000000..5a07e2db --- /dev/null +++ b/v2/session/service.go @@ -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 +} diff --git a/v2/session/types.go b/v2/session/types.go index 9e876033..0322b25a 100644 --- a/v2/session/types.go +++ b/v2/session/types.go @@ -11,28 +11,12 @@ type CreateRequestBody struct { expiration uint64 } -type CreateRequest struct { - body *CreateRequestBody - - metaHeader *RequestMetaHeader - - verifyHeader *RequestVerificationHeader -} - type CreateResponseBody struct { id []byte sessionKey []byte } -type CreateResponse struct { - body *CreateResponseBody - - metaHeader *ResponseMetaHeader - - verifyHeader *ResponseVerificationHeader -} - type XHeader struct { key, val string }