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
}
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

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
}
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

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
}
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
}