2021-11-09 08:07:49 +00:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
v2container "github.com/nspcc-dev/neofs-api-go/v2/container"
|
|
|
|
rpcapi "github.com/nspcc-dev/neofs-api-go/v2/rpc"
|
2021-11-16 18:15:56 +00:00
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
|
2021-12-02 12:21:54 +00:00
|
|
|
v2session "github.com/nspcc-dev/neofs-api-go/v2/session"
|
2021-11-09 08:07:49 +00:00
|
|
|
v2signature "github.com/nspcc-dev/neofs-api-go/v2/signature"
|
|
|
|
"github.com/nspcc-dev/neofs-sdk-go/container"
|
|
|
|
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
|
|
|
"github.com/nspcc-dev/neofs-sdk-go/eacl"
|
|
|
|
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
|
|
|
"github.com/nspcc-dev/neofs-sdk-go/session"
|
|
|
|
"github.com/nspcc-dev/neofs-sdk-go/signature"
|
|
|
|
sigutil "github.com/nspcc-dev/neofs-sdk-go/util/signature"
|
|
|
|
)
|
|
|
|
|
2022-02-17 16:10:49 +00:00
|
|
|
// PrmContainerPut groups parameters of ContainerPut operation.
|
|
|
|
type PrmContainerPut struct {
|
2022-03-03 11:04:53 +00:00
|
|
|
prmCommonMeta
|
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
cnrSet bool
|
|
|
|
cnr container.Container
|
2021-11-09 08:07:49 +00:00
|
|
|
}
|
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// SetContainer sets structured information about new NeoFS container.
|
|
|
|
// Required parameter.
|
2022-02-17 16:10:49 +00:00
|
|
|
func (x *PrmContainerPut) SetContainer(cnr container.Container) {
|
2021-12-02 12:21:54 +00:00
|
|
|
x.cnr = cnr
|
|
|
|
x.cnrSet = true
|
2021-11-09 08:07:49 +00:00
|
|
|
}
|
|
|
|
|
2022-02-17 16:10:49 +00:00
|
|
|
// ResContainerPut groups resulting values of ContainerPut operation.
|
|
|
|
type ResContainerPut struct {
|
2021-11-16 18:17:25 +00:00
|
|
|
statusRes
|
|
|
|
|
|
|
|
id *cid.ID
|
|
|
|
}
|
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// ID returns identifier of the container declared to be stored in the system.
|
|
|
|
// Used as a link to information about the container (in particular, you can
|
|
|
|
// asynchronously check if the save was successful).
|
|
|
|
//
|
|
|
|
// Client doesn't retain value so modification is safe.
|
2022-02-17 16:10:49 +00:00
|
|
|
func (x ResContainerPut) ID() *cid.ID {
|
2021-11-16 18:17:25 +00:00
|
|
|
return x.id
|
|
|
|
}
|
|
|
|
|
2022-02-17 16:10:49 +00:00
|
|
|
func (x *ResContainerPut) setID(id *cid.ID) {
|
2021-11-16 18:17:25 +00:00
|
|
|
x.id = id
|
|
|
|
}
|
|
|
|
|
2022-02-17 16:10:49 +00:00
|
|
|
// ContainerPut sends request to save container in NeoFS.
|
2021-12-29 13:55:29 +00:00
|
|
|
//
|
2022-01-24 10:33:43 +00:00
|
|
|
// Exactly one return value is non-nil. By default, server status is returned in res structure.
|
2022-01-11 12:44:22 +00:00
|
|
|
// Any client's internal or transport errors are returned as `error`.
|
|
|
|
// If WithNeoFSErrorParsing option has been provided, unsuccessful
|
|
|
|
// NeoFS status codes are returned as `error`, otherwise, are included
|
|
|
|
// in the returned result structure.
|
2021-12-02 12:21:54 +00:00
|
|
|
//
|
|
|
|
// Operation is asynchronous and no guaranteed even in the absence of errors.
|
|
|
|
// The required time is also not predictable.
|
|
|
|
//
|
2022-02-17 16:10:49 +00:00
|
|
|
// Success can be verified by reading by identifier (see ResContainerPut.ID).
|
2021-12-02 12:21:54 +00:00
|
|
|
//
|
2022-02-17 16:10:49 +00:00
|
|
|
// Immediately panics if parameters are set incorrectly (see PrmContainerPut docs).
|
2021-12-02 12:21:54 +00:00
|
|
|
// Context is required and must not be nil. It is used for network communication.
|
|
|
|
//
|
2022-01-24 10:33:43 +00:00
|
|
|
// Return statuses:
|
|
|
|
// - global (see Client docs).
|
2022-02-17 16:10:49 +00:00
|
|
|
func (c *Client) ContainerPut(ctx context.Context, prm PrmContainerPut) (*ResContainerPut, error) {
|
2021-12-02 12:21:54 +00:00
|
|
|
// check parameters
|
|
|
|
switch {
|
|
|
|
case ctx == nil:
|
|
|
|
panic(panicMsgMissingContext)
|
|
|
|
case !prm.cnrSet:
|
|
|
|
panic(panicMsgMissingContainer)
|
2021-11-09 08:07:49 +00:00
|
|
|
}
|
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// TODO: check private key is set before forming the request
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// form request body
|
2021-11-09 08:07:49 +00:00
|
|
|
reqBody := new(v2container.PutRequestBody)
|
2021-12-02 12:21:54 +00:00
|
|
|
reqBody.SetContainer(prm.cnr.ToV2())
|
2021-11-09 08:07:49 +00:00
|
|
|
|
|
|
|
// sign container
|
|
|
|
signWrapper := v2signature.StableMarshalerWrapper{SM: reqBody.GetContainer()}
|
|
|
|
|
2022-03-07 11:39:49 +00:00
|
|
|
sig, err := sigutil.SignData(&c.prm.key, signWrapper, sigutil.SignWithRFC6979())
|
2021-11-09 08:07:49 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2022-02-24 11:45:52 +00:00
|
|
|
reqBody.SetSignature(sig.ToV2())
|
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// form meta header
|
|
|
|
var meta v2session.RequestMetaHeader
|
2022-02-03 16:17:30 +00:00
|
|
|
meta.SetSessionToken(prm.cnr.SessionToken().ToV2())
|
2022-03-03 11:04:53 +00:00
|
|
|
prm.prmCommonMeta.writeToMetaHeader(&meta)
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// form request
|
|
|
|
var req v2container.PutRequest
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
req.SetBody(reqBody)
|
|
|
|
req.SetMetaHeader(&meta)
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// init call context
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-11-16 18:17:25 +00:00
|
|
|
var (
|
2021-12-02 12:21:54 +00:00
|
|
|
cc contextCall
|
2022-02-17 16:10:49 +00:00
|
|
|
res ResContainerPut
|
2021-11-16 18:17:25 +00:00
|
|
|
)
|
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
c.initCallContext(&cc)
|
|
|
|
cc.req = &req
|
|
|
|
cc.statusRes = &res
|
|
|
|
cc.call = func() (responseV2, error) {
|
2022-03-07 11:39:49 +00:00
|
|
|
return rpcapi.PutContainer(&c.c, &req, client.WithContext(ctx))
|
2021-12-02 12:21:54 +00:00
|
|
|
}
|
|
|
|
cc.result = func(r responseV2) {
|
|
|
|
resp := r.(*v2container.PutResponse)
|
|
|
|
res.setID(cid.NewFromV2(resp.GetBody().GetContainerID()))
|
2021-11-09 08:07:49 +00:00
|
|
|
}
|
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// process call
|
|
|
|
if !cc.processCall() {
|
|
|
|
return nil, cc.err
|
|
|
|
}
|
2021-11-16 18:17:25 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
return &res, nil
|
|
|
|
}
|
2021-11-16 18:17:25 +00:00
|
|
|
|
2022-02-17 16:10:49 +00:00
|
|
|
// PrmContainerGet groups parameters of ContainerGet operation.
|
|
|
|
type PrmContainerGet struct {
|
2022-03-03 11:04:53 +00:00
|
|
|
prmCommonMeta
|
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
idSet bool
|
|
|
|
id cid.ID
|
|
|
|
}
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// SetContainer sets identifier of the container to be read.
|
|
|
|
// Required parameter.
|
2022-02-17 16:10:49 +00:00
|
|
|
func (x *PrmContainerGet) SetContainer(id cid.ID) {
|
2021-12-02 12:21:54 +00:00
|
|
|
x.id = id
|
|
|
|
x.idSet = true
|
2021-11-16 18:17:25 +00:00
|
|
|
}
|
|
|
|
|
2022-02-17 16:10:49 +00:00
|
|
|
// ResContainerGet groups resulting values of ContainerGet operation.
|
|
|
|
type ResContainerGet struct {
|
2021-11-16 18:17:25 +00:00
|
|
|
statusRes
|
|
|
|
|
|
|
|
cnr *container.Container
|
|
|
|
}
|
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// Container returns structured information about the requested container.
|
|
|
|
//
|
|
|
|
// Client doesn't retain value so modification is safe.
|
2022-02-17 16:10:49 +00:00
|
|
|
func (x ResContainerGet) Container() *container.Container {
|
2021-11-16 18:17:25 +00:00
|
|
|
return x.cnr
|
|
|
|
}
|
|
|
|
|
2022-02-17 16:10:49 +00:00
|
|
|
func (x *ResContainerGet) setContainer(cnr *container.Container) {
|
2021-11-16 18:17:25 +00:00
|
|
|
x.cnr = cnr
|
2021-11-09 08:07:49 +00:00
|
|
|
}
|
|
|
|
|
2022-02-17 16:10:49 +00:00
|
|
|
// ContainerGet reads NeoFS container by ID.
|
2021-11-09 08:07:49 +00:00
|
|
|
//
|
2022-01-24 10:33:43 +00:00
|
|
|
// Exactly one return value is non-nil. By default, server status is returned in res structure.
|
2022-01-11 12:44:22 +00:00
|
|
|
// Any client's internal or transport errors are returned as `error`.
|
|
|
|
// If WithNeoFSErrorParsing option has been provided, unsuccessful
|
|
|
|
// NeoFS status codes are returned as `error`, otherwise, are included
|
|
|
|
// in the returned result structure.
|
2021-12-02 12:21:54 +00:00
|
|
|
//
|
2022-02-17 16:10:49 +00:00
|
|
|
// Immediately panics if parameters are set incorrectly (see PrmContainerGet docs).
|
2021-12-02 12:21:54 +00:00
|
|
|
// Context is required and must not be nil. It is used for network communication.
|
|
|
|
//
|
2022-01-24 10:33:43 +00:00
|
|
|
// Return statuses:
|
2022-02-28 10:56:46 +00:00
|
|
|
// - global (see Client docs);
|
|
|
|
// - *apistatus.ContainerNotFound.
|
2022-02-17 16:10:49 +00:00
|
|
|
func (c *Client) ContainerGet(ctx context.Context, prm PrmContainerGet) (*ResContainerGet, error) {
|
2021-12-02 12:21:54 +00:00
|
|
|
switch {
|
|
|
|
case ctx == nil:
|
|
|
|
panic(panicMsgMissingContext)
|
|
|
|
case !prm.idSet:
|
|
|
|
panic(panicMsgMissingContainer)
|
2021-11-09 08:07:49 +00:00
|
|
|
}
|
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// form request body
|
2021-11-09 08:07:49 +00:00
|
|
|
reqBody := new(v2container.GetRequestBody)
|
2021-12-02 12:21:54 +00:00
|
|
|
reqBody.SetContainerID(prm.id.ToV2())
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// form request
|
|
|
|
var req v2container.GetRequest
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
req.SetBody(reqBody)
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// init call context
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-11-16 18:17:25 +00:00
|
|
|
var (
|
2021-12-02 12:21:54 +00:00
|
|
|
cc contextCall
|
2022-02-17 16:10:49 +00:00
|
|
|
res ResContainerGet
|
2021-11-16 18:17:25 +00:00
|
|
|
)
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
c.initCallContext(&cc)
|
2022-03-03 11:04:53 +00:00
|
|
|
cc.meta = prm.prmCommonMeta
|
2021-12-02 12:21:54 +00:00
|
|
|
cc.req = &req
|
|
|
|
cc.statusRes = &res
|
|
|
|
cc.call = func() (responseV2, error) {
|
2022-03-07 11:39:49 +00:00
|
|
|
return rpcapi.GetContainer(&c.c, &req, client.WithContext(ctx))
|
2021-12-02 12:21:54 +00:00
|
|
|
}
|
|
|
|
cc.result = func(r responseV2) {
|
|
|
|
resp := r.(*v2container.GetResponse)
|
2021-11-16 18:17:25 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
body := resp.GetBody()
|
2021-11-16 18:17:25 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
cnr := container.NewContainerFromV2(body.GetContainer())
|
2021-11-16 18:17:25 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
cnr.SetSessionToken(
|
|
|
|
session.NewTokenFromV2(body.GetSessionToken()),
|
|
|
|
)
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
cnr.SetSignature(
|
|
|
|
signature.NewFromV2(body.GetSignature()),
|
|
|
|
)
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
res.setContainer(cnr)
|
|
|
|
}
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// process call
|
|
|
|
if !cc.processCall() {
|
|
|
|
return nil, cc.err
|
|
|
|
}
|
2021-11-16 18:17:25 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
return &res, nil
|
|
|
|
}
|
2021-11-16 18:17:25 +00:00
|
|
|
|
2022-02-17 16:10:49 +00:00
|
|
|
// PrmContainerList groups parameters of ContainerList operation.
|
|
|
|
type PrmContainerList struct {
|
2022-03-03 11:04:53 +00:00
|
|
|
prmCommonMeta
|
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
ownerSet bool
|
|
|
|
ownerID owner.ID
|
|
|
|
}
|
2021-11-16 18:17:25 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// SetAccount sets identifier of the NeoFS account to list the containers.
|
|
|
|
// Required parameter. Must be a valid ID according to NeoFS API protocol.
|
2022-02-17 16:10:49 +00:00
|
|
|
func (x *PrmContainerList) SetAccount(id owner.ID) {
|
2021-12-02 12:21:54 +00:00
|
|
|
x.ownerID = id
|
|
|
|
x.ownerSet = true
|
2021-11-09 08:07:49 +00:00
|
|
|
}
|
|
|
|
|
2022-02-17 16:10:49 +00:00
|
|
|
// ResContainerList groups resulting values of ContainerList operation.
|
|
|
|
type ResContainerList struct {
|
2021-11-16 18:17:25 +00:00
|
|
|
statusRes
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2022-03-11 09:16:08 +00:00
|
|
|
ids []cid.ID
|
2021-11-16 18:17:25 +00:00
|
|
|
}
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// Containers returns list of identifiers of the account-owned containers.
|
|
|
|
//
|
|
|
|
// Client doesn't retain value so modification is safe.
|
2022-03-11 09:16:08 +00:00
|
|
|
func (x ResContainerList) Containers() []cid.ID {
|
2021-11-16 18:17:25 +00:00
|
|
|
return x.ids
|
2021-11-09 08:07:49 +00:00
|
|
|
}
|
|
|
|
|
2022-03-11 09:16:08 +00:00
|
|
|
func (x *ResContainerList) setContainers(ids []cid.ID) {
|
2021-11-16 18:17:25 +00:00
|
|
|
x.ids = ids
|
|
|
|
}
|
|
|
|
|
2022-02-17 16:10:49 +00:00
|
|
|
// ContainerList requests identifiers of the account-owned containers.
|
2021-12-29 13:55:29 +00:00
|
|
|
//
|
2022-01-24 10:33:43 +00:00
|
|
|
// Exactly one return value is non-nil. By default, server status is returned in res structure.
|
2022-01-11 12:44:22 +00:00
|
|
|
// Any client's internal or transport errors are returned as `error`.
|
|
|
|
// If WithNeoFSErrorParsing option has been provided, unsuccessful
|
|
|
|
// NeoFS status codes are returned as `error`, otherwise, are included
|
|
|
|
// in the returned result structure.
|
2021-12-02 12:21:54 +00:00
|
|
|
//
|
2022-02-17 16:10:49 +00:00
|
|
|
// Immediately panics if parameters are set incorrectly (see PrmContainerList docs).
|
2021-12-02 12:21:54 +00:00
|
|
|
// Context is required and must not be nil. It is used for network communication.
|
|
|
|
//
|
2022-01-24 10:33:43 +00:00
|
|
|
// Return statuses:
|
|
|
|
// - global (see Client docs).
|
2022-02-17 16:10:49 +00:00
|
|
|
func (c *Client) ContainerList(ctx context.Context, prm PrmContainerList) (*ResContainerList, error) {
|
2021-12-02 12:21:54 +00:00
|
|
|
// check parameters
|
|
|
|
switch {
|
|
|
|
case ctx == nil:
|
|
|
|
panic(panicMsgMissingContext)
|
|
|
|
case !prm.ownerSet:
|
|
|
|
panic("account not set")
|
|
|
|
case !prm.ownerID.Valid():
|
|
|
|
panic("invalid account")
|
|
|
|
}
|
|
|
|
|
|
|
|
// form request body
|
2021-11-09 08:07:49 +00:00
|
|
|
reqBody := new(v2container.ListRequestBody)
|
2021-12-02 12:21:54 +00:00
|
|
|
reqBody.SetOwnerID(prm.ownerID.ToV2())
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// form request
|
|
|
|
var req v2container.ListRequest
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
req.SetBody(reqBody)
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// init call context
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-11-16 18:17:25 +00:00
|
|
|
var (
|
2021-12-02 12:21:54 +00:00
|
|
|
cc contextCall
|
2022-02-17 16:10:49 +00:00
|
|
|
res ResContainerList
|
2021-11-16 18:17:25 +00:00
|
|
|
)
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
c.initCallContext(&cc)
|
2022-03-03 11:04:53 +00:00
|
|
|
cc.meta = prm.prmCommonMeta
|
2021-12-02 12:21:54 +00:00
|
|
|
cc.req = &req
|
|
|
|
cc.statusRes = &res
|
|
|
|
cc.call = func() (responseV2, error) {
|
2022-03-07 11:39:49 +00:00
|
|
|
return rpcapi.ListContainers(&c.c, &req, client.WithContext(ctx))
|
2021-12-02 12:21:54 +00:00
|
|
|
}
|
|
|
|
cc.result = func(r responseV2) {
|
|
|
|
resp := r.(*v2container.ListResponse)
|
2021-11-16 18:17:25 +00:00
|
|
|
|
2022-03-11 09:16:08 +00:00
|
|
|
ids := make([]cid.ID, len(resp.GetBody().GetContainerIDs()))
|
2021-11-16 18:17:25 +00:00
|
|
|
|
2022-03-11 09:16:08 +00:00
|
|
|
for i, cidV2 := range resp.GetBody().GetContainerIDs() {
|
|
|
|
ids[i] = *cid.NewFromV2(&cidV2)
|
2021-11-16 18:17:25 +00:00
|
|
|
}
|
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
res.setContainers(ids)
|
2021-11-09 08:07:49 +00:00
|
|
|
}
|
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// process call
|
|
|
|
if !cc.processCall() {
|
|
|
|
return nil, cc.err
|
2021-11-09 08:07:49 +00:00
|
|
|
}
|
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
return &res, nil
|
|
|
|
}
|
|
|
|
|
2022-02-17 16:10:49 +00:00
|
|
|
// PrmContainerDelete groups parameters of ContainerDelete operation.
|
|
|
|
type PrmContainerDelete struct {
|
2022-03-03 11:04:53 +00:00
|
|
|
prmCommonMeta
|
2021-12-02 12:21:54 +00:00
|
|
|
prmSession
|
2021-11-16 18:17:25 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
idSet bool
|
|
|
|
id cid.ID
|
2021-11-16 18:17:25 +00:00
|
|
|
}
|
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// SetContainer sets identifier of the NeoFS container to be removed.
|
|
|
|
// Required parameter.
|
2022-02-17 16:10:49 +00:00
|
|
|
func (x *PrmContainerDelete) SetContainer(id cid.ID) {
|
2021-12-02 12:21:54 +00:00
|
|
|
x.id = id
|
|
|
|
x.idSet = true
|
|
|
|
}
|
|
|
|
|
2022-02-17 16:10:49 +00:00
|
|
|
// ResContainerDelete groups resulting values of ContainerDelete operation.
|
|
|
|
type ResContainerDelete struct {
|
2021-11-16 18:17:25 +00:00
|
|
|
statusRes
|
2021-11-09 08:07:49 +00:00
|
|
|
}
|
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// implements github.com/nspcc-dev/neofs-sdk-go/util/signature.DataSource.
|
|
|
|
type delContainerSignWrapper struct {
|
|
|
|
body *v2container.DeleteRequestBody
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c delContainerSignWrapper) ReadSignedData([]byte) ([]byte, error) {
|
|
|
|
return c.body.GetContainerID().GetValue(), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c delContainerSignWrapper) SignedDataSize() int {
|
|
|
|
return len(c.body.GetContainerID().GetValue())
|
|
|
|
}
|
|
|
|
|
2022-02-17 16:10:49 +00:00
|
|
|
// ContainerDelete sends request to remove the NeoFS container.
|
2021-12-29 13:55:29 +00:00
|
|
|
//
|
2022-01-24 10:33:43 +00:00
|
|
|
// Exactly one return value is non-nil. By default, server status is returned in res structure.
|
2022-01-11 12:44:22 +00:00
|
|
|
// Any client's internal or transport errors are returned as `error`.
|
|
|
|
// If WithNeoFSErrorParsing option has been provided, unsuccessful
|
|
|
|
// NeoFS status codes are returned as `error`, otherwise, are included
|
|
|
|
// in the returned result structure.
|
2021-12-02 12:21:54 +00:00
|
|
|
//
|
|
|
|
// Operation is asynchronous and no guaranteed even in the absence of errors.
|
|
|
|
// The required time is also not predictable.
|
|
|
|
//
|
|
|
|
// Success can be verified by reading by identifier (see GetContainer).
|
|
|
|
//
|
2022-02-17 16:10:49 +00:00
|
|
|
// Immediately panics if parameters are set incorrectly (see PrmContainerDelete docs).
|
2021-12-02 12:21:54 +00:00
|
|
|
// Context is required and must not be nil. It is used for network communication.
|
|
|
|
//
|
2022-02-17 16:10:49 +00:00
|
|
|
// Exactly one return value is non-nil. Server status return is returned in ResContainerDelete.
|
2021-12-02 12:21:54 +00:00
|
|
|
// Reflects all internal errors in second return value (transport problems, response processing, etc.).
|
2022-01-24 10:33:43 +00:00
|
|
|
//
|
|
|
|
// Return statuses:
|
|
|
|
// - global (see Client docs).
|
2022-02-17 16:10:49 +00:00
|
|
|
func (c *Client) ContainerDelete(ctx context.Context, prm PrmContainerDelete) (*ResContainerDelete, error) {
|
2021-12-02 12:21:54 +00:00
|
|
|
// check parameters
|
|
|
|
switch {
|
|
|
|
case ctx == nil:
|
|
|
|
panic(panicMsgMissingContext)
|
|
|
|
case !prm.idSet:
|
|
|
|
panic(panicMsgMissingContainer)
|
|
|
|
}
|
|
|
|
|
|
|
|
// form request body
|
2021-11-09 08:07:49 +00:00
|
|
|
reqBody := new(v2container.DeleteRequestBody)
|
2021-12-02 12:21:54 +00:00
|
|
|
reqBody.SetContainerID(prm.id.ToV2())
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2022-02-24 11:45:52 +00:00
|
|
|
signWrapper := delContainerSignWrapper{body: reqBody}
|
|
|
|
|
2021-11-09 08:07:49 +00:00
|
|
|
// sign container
|
2022-03-07 11:39:49 +00:00
|
|
|
sig, err := sigutil.SignData(&c.prm.key, signWrapper, sigutil.SignWithRFC6979())
|
2021-11-09 08:07:49 +00:00
|
|
|
if err != nil {
|
2021-11-16 18:17:25 +00:00
|
|
|
return nil, err
|
2021-11-09 08:07:49 +00:00
|
|
|
}
|
|
|
|
|
2022-02-24 11:45:52 +00:00
|
|
|
reqBody.SetSignature(sig.ToV2())
|
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// form meta header
|
|
|
|
var meta v2session.RequestMetaHeader
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
prm.prmSession.writeToMetaHeader(&meta)
|
2022-03-03 11:04:53 +00:00
|
|
|
prm.prmCommonMeta.writeToMetaHeader(&meta)
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// form request
|
|
|
|
var req v2container.DeleteRequest
|
|
|
|
|
|
|
|
req.SetBody(reqBody)
|
|
|
|
req.SetMetaHeader(&meta)
|
|
|
|
|
|
|
|
// init call context
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-11-16 18:17:25 +00:00
|
|
|
var (
|
2021-12-02 12:21:54 +00:00
|
|
|
cc contextCall
|
2022-02-17 16:10:49 +00:00
|
|
|
res ResContainerDelete
|
2021-11-16 18:17:25 +00:00
|
|
|
)
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
c.initCallContext(&cc)
|
|
|
|
cc.req = &req
|
|
|
|
cc.statusRes = &res
|
|
|
|
cc.call = func() (responseV2, error) {
|
2022-03-07 11:39:49 +00:00
|
|
|
return rpcapi.DeleteContainer(&c.c, &req, client.WithContext(ctx))
|
2021-12-02 12:21:54 +00:00
|
|
|
}
|
2021-11-16 18:17:25 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// process call
|
|
|
|
if !cc.processCall() {
|
|
|
|
return nil, cc.err
|
|
|
|
}
|
2021-11-16 18:17:25 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
return &res, nil
|
|
|
|
}
|
2021-11-16 18:17:25 +00:00
|
|
|
|
2022-02-17 16:10:49 +00:00
|
|
|
// PrmContainerEACL groups parameters of ContainerEACL operation.
|
|
|
|
type PrmContainerEACL struct {
|
2022-03-03 11:04:53 +00:00
|
|
|
prmCommonMeta
|
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
idSet bool
|
|
|
|
id cid.ID
|
|
|
|
}
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// SetContainer sets identifier of the NeoFS container to read the eACL table.
|
|
|
|
// Required parameter.
|
2022-02-17 16:10:49 +00:00
|
|
|
func (x *PrmContainerEACL) SetContainer(id cid.ID) {
|
2021-12-02 12:21:54 +00:00
|
|
|
x.id = id
|
|
|
|
x.idSet = true
|
2021-11-16 18:17:25 +00:00
|
|
|
}
|
|
|
|
|
2022-02-17 16:10:49 +00:00
|
|
|
// ResContainerEACL groups resulting values of ContainerEACL operation.
|
|
|
|
type ResContainerEACL struct {
|
2021-11-16 18:17:25 +00:00
|
|
|
statusRes
|
|
|
|
|
|
|
|
table *eacl.Table
|
|
|
|
}
|
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// Table returns eACL table of the requested container.
|
|
|
|
//
|
|
|
|
// Client doesn't retain value so modification is safe.
|
2022-02-17 16:10:49 +00:00
|
|
|
func (x ResContainerEACL) Table() *eacl.Table {
|
2021-11-16 18:17:25 +00:00
|
|
|
return x.table
|
|
|
|
}
|
|
|
|
|
2022-02-17 16:10:49 +00:00
|
|
|
func (x *ResContainerEACL) setTable(table *eacl.Table) {
|
2021-11-16 18:17:25 +00:00
|
|
|
x.table = table
|
2021-11-09 08:07:49 +00:00
|
|
|
}
|
|
|
|
|
2022-02-17 16:10:49 +00:00
|
|
|
// ContainerEACL reads eACL table of the NeoFS container.
|
2021-12-29 13:55:29 +00:00
|
|
|
//
|
2022-01-24 10:33:43 +00:00
|
|
|
// Exactly one return value is non-nil. By default, server status is returned in res structure.
|
2022-01-11 12:44:22 +00:00
|
|
|
// Any client's internal or transport errors are returned as `error`.
|
|
|
|
// If WithNeoFSErrorParsing option has been provided, unsuccessful
|
|
|
|
// NeoFS status codes are returned as `error`, otherwise, are included
|
|
|
|
// in the returned result structure.
|
2021-12-02 12:21:54 +00:00
|
|
|
//
|
2022-02-17 16:10:49 +00:00
|
|
|
// Immediately panics if parameters are set incorrectly (see PrmContainerEACL docs).
|
2021-12-02 12:21:54 +00:00
|
|
|
// Context is required and must not be nil. It is used for network communication.
|
|
|
|
//
|
2022-01-24 10:33:43 +00:00
|
|
|
// Return statuses:
|
2022-02-28 10:56:46 +00:00
|
|
|
// - global (see Client docs);
|
|
|
|
// - *apistatus.ContainerNotFound.
|
2022-02-17 16:10:49 +00:00
|
|
|
func (c *Client) ContainerEACL(ctx context.Context, prm PrmContainerEACL) (*ResContainerEACL, error) {
|
2021-12-02 12:21:54 +00:00
|
|
|
// check parameters
|
|
|
|
switch {
|
|
|
|
case ctx == nil:
|
|
|
|
panic(panicMsgMissingContext)
|
|
|
|
case !prm.idSet:
|
|
|
|
panic(panicMsgMissingContainer)
|
|
|
|
}
|
|
|
|
|
|
|
|
// form request body
|
2021-11-09 08:07:49 +00:00
|
|
|
reqBody := new(v2container.GetExtendedACLRequestBody)
|
2021-12-02 12:21:54 +00:00
|
|
|
reqBody.SetContainerID(prm.id.ToV2())
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// form request
|
|
|
|
var req v2container.GetExtendedACLRequest
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
req.SetBody(reqBody)
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// init call context
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-11-16 18:17:25 +00:00
|
|
|
var (
|
2021-12-02 12:21:54 +00:00
|
|
|
cc contextCall
|
2022-02-17 16:10:49 +00:00
|
|
|
res ResContainerEACL
|
2021-11-16 18:17:25 +00:00
|
|
|
)
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
c.initCallContext(&cc)
|
2022-03-03 11:04:53 +00:00
|
|
|
cc.meta = prm.prmCommonMeta
|
2021-12-02 12:21:54 +00:00
|
|
|
cc.req = &req
|
|
|
|
cc.statusRes = &res
|
|
|
|
cc.call = func() (responseV2, error) {
|
2022-03-07 11:39:49 +00:00
|
|
|
return rpcapi.GetEACL(&c.c, &req, client.WithContext(ctx))
|
2021-12-02 12:21:54 +00:00
|
|
|
}
|
|
|
|
cc.result = func(r responseV2) {
|
|
|
|
resp := r.(*v2container.GetExtendedACLResponse)
|
2021-11-16 18:17:25 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
body := resp.GetBody()
|
2021-11-16 18:17:25 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
table := eacl.NewTableFromV2(body.GetEACL())
|
2021-11-16 18:17:25 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
table.SetSessionToken(
|
|
|
|
session.NewTokenFromV2(body.GetSessionToken()),
|
|
|
|
)
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
table.SetSignature(
|
|
|
|
signature.NewFromV2(body.GetSignature()),
|
|
|
|
)
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
res.setTable(table)
|
|
|
|
}
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// process call
|
|
|
|
if !cc.processCall() {
|
|
|
|
return nil, cc.err
|
|
|
|
}
|
2021-11-16 18:17:25 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
return &res, nil
|
|
|
|
}
|
2021-11-16 18:17:25 +00:00
|
|
|
|
2022-02-17 16:10:49 +00:00
|
|
|
// PrmContainerSetEACL groups parameters of ContainerSetEACL operation.
|
|
|
|
type PrmContainerSetEACL struct {
|
2022-03-03 11:04:53 +00:00
|
|
|
prmCommonMeta
|
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
tableSet bool
|
|
|
|
table eacl.Table
|
2021-11-09 08:07:49 +00:00
|
|
|
}
|
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// SetTable sets eACL table structure to be set for the container.
|
|
|
|
// Required parameter.
|
2022-02-17 16:10:49 +00:00
|
|
|
func (x *PrmContainerSetEACL) SetTable(table eacl.Table) {
|
2021-12-02 12:21:54 +00:00
|
|
|
x.table = table
|
|
|
|
x.tableSet = true
|
|
|
|
}
|
|
|
|
|
2022-02-17 16:10:49 +00:00
|
|
|
// ResContainerSetEACL groups resulting values of ContainerSetEACL operation.
|
|
|
|
type ResContainerSetEACL struct {
|
2021-11-16 18:17:25 +00:00
|
|
|
statusRes
|
|
|
|
}
|
|
|
|
|
2022-02-17 16:10:49 +00:00
|
|
|
// ContainerSetEACL sends request to update eACL table of the NeoFS container.
|
2021-12-29 13:55:29 +00:00
|
|
|
//
|
2022-01-24 10:33:43 +00:00
|
|
|
// Exactly one return value is non-nil. By default, server status is returned in res structure.
|
2022-01-11 12:44:22 +00:00
|
|
|
// Any client's internal or transport errors are returned as `error`.
|
|
|
|
// If WithNeoFSErrorParsing option has been provided, unsuccessful
|
|
|
|
// NeoFS status codes are returned as `error`, otherwise, are included
|
|
|
|
// in the returned result structure.
|
2021-12-02 12:21:54 +00:00
|
|
|
//
|
|
|
|
// Operation is asynchronous and no guaranteed even in the absence of errors.
|
|
|
|
// The required time is also not predictable.
|
|
|
|
//
|
|
|
|
// Success can be verified by reading by identifier (see EACL).
|
|
|
|
//
|
2022-02-17 16:10:49 +00:00
|
|
|
// Immediately panics if parameters are set incorrectly (see PrmContainerSetEACL docs).
|
2021-12-02 12:21:54 +00:00
|
|
|
// Context is required and must not be nil. It is used for network communication.
|
|
|
|
//
|
2022-01-24 10:33:43 +00:00
|
|
|
// Return statuses:
|
|
|
|
// - global (see Client docs).
|
2022-02-17 16:10:49 +00:00
|
|
|
func (c *Client) ContainerSetEACL(ctx context.Context, prm PrmContainerSetEACL) (*ResContainerSetEACL, error) {
|
2021-12-02 12:21:54 +00:00
|
|
|
// check parameters
|
|
|
|
switch {
|
|
|
|
case ctx == nil:
|
|
|
|
panic(panicMsgMissingContext)
|
|
|
|
case !prm.tableSet:
|
|
|
|
panic("eACL table not set")
|
|
|
|
}
|
|
|
|
|
|
|
|
// form request body
|
2021-11-09 08:07:49 +00:00
|
|
|
reqBody := new(v2container.SetExtendedACLRequestBody)
|
2021-12-02 12:21:54 +00:00
|
|
|
reqBody.SetEACL(prm.table.ToV2())
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// sign the eACL table
|
2021-11-09 08:07:49 +00:00
|
|
|
signWrapper := v2signature.StableMarshalerWrapper{SM: reqBody.GetEACL()}
|
|
|
|
|
2022-03-07 11:39:49 +00:00
|
|
|
sig, err := sigutil.SignData(&c.prm.key, signWrapper, sigutil.SignWithRFC6979())
|
2021-11-09 08:07:49 +00:00
|
|
|
if err != nil {
|
2021-11-16 18:17:25 +00:00
|
|
|
return nil, err
|
2021-11-09 08:07:49 +00:00
|
|
|
}
|
|
|
|
|
2022-02-24 11:45:52 +00:00
|
|
|
reqBody.SetSignature(sig.ToV2())
|
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// form meta header
|
|
|
|
var meta v2session.RequestMetaHeader
|
2022-02-16 20:11:49 +00:00
|
|
|
meta.SetSessionToken(prm.table.SessionToken().ToV2())
|
2022-03-03 11:04:53 +00:00
|
|
|
prm.prmCommonMeta.writeToMetaHeader(&meta)
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// form request
|
|
|
|
var req v2container.SetExtendedACLRequest
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
req.SetBody(reqBody)
|
|
|
|
req.SetMetaHeader(&meta)
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// init call context
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-11-16 18:17:25 +00:00
|
|
|
var (
|
2021-12-02 12:21:54 +00:00
|
|
|
cc contextCall
|
2022-02-17 16:10:49 +00:00
|
|
|
res ResContainerSetEACL
|
2021-11-16 18:17:25 +00:00
|
|
|
)
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
c.initCallContext(&cc)
|
|
|
|
cc.req = &req
|
|
|
|
cc.statusRes = &res
|
|
|
|
cc.call = func() (responseV2, error) {
|
2022-03-07 11:39:49 +00:00
|
|
|
return rpcapi.SetEACL(&c.c, &req, client.WithContext(ctx))
|
2021-12-02 12:21:54 +00:00
|
|
|
}
|
2021-11-16 18:17:25 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// process call
|
|
|
|
if !cc.processCall() {
|
|
|
|
return nil, cc.err
|
|
|
|
}
|
2021-11-16 18:17:25 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
return &res, nil
|
|
|
|
}
|
2021-11-16 18:17:25 +00:00
|
|
|
|
2022-02-17 16:10:49 +00:00
|
|
|
// PrmAnnounceSpace groups parameters of ContainerAnnounceUsedSpace operation.
|
|
|
|
type PrmAnnounceSpace struct {
|
2022-03-03 11:04:53 +00:00
|
|
|
prmCommonMeta
|
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
announcements []container.UsedSpaceAnnouncement
|
|
|
|
}
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// SetValues sets values describing volume of space that is used for the container objects.
|
|
|
|
// Required parameter. Must not be empty.
|
|
|
|
//
|
|
|
|
// Must not be mutated before the end of the operation.
|
2022-02-17 16:10:49 +00:00
|
|
|
func (x *PrmAnnounceSpace) SetValues(announcements []container.UsedSpaceAnnouncement) {
|
2021-12-02 12:21:54 +00:00
|
|
|
x.announcements = announcements
|
2021-11-16 18:17:25 +00:00
|
|
|
}
|
|
|
|
|
2022-02-17 16:10:49 +00:00
|
|
|
// ResAnnounceSpace groups resulting values of ContainerAnnounceUsedSpace operation.
|
|
|
|
type ResAnnounceSpace struct {
|
2021-11-16 18:17:25 +00:00
|
|
|
statusRes
|
2021-11-09 08:07:49 +00:00
|
|
|
}
|
|
|
|
|
2022-02-17 16:10:49 +00:00
|
|
|
// ContainerAnnounceUsedSpace sends request to announce volume of the space used for the container objects.
|
2021-12-29 13:55:29 +00:00
|
|
|
//
|
2022-01-24 10:33:43 +00:00
|
|
|
// Exactly one return value is non-nil. By default, server status is returned in res structure.
|
2022-01-11 12:44:22 +00:00
|
|
|
// Any client's internal or transport errors are returned as `error`.
|
|
|
|
// If WithNeoFSErrorParsing option has been provided, unsuccessful
|
|
|
|
// NeoFS status codes are returned as `error`, otherwise, are included
|
|
|
|
// in the returned result structure.
|
2021-12-02 12:21:54 +00:00
|
|
|
//
|
|
|
|
// Operation is asynchronous and no guaranteed even in the absence of errors.
|
|
|
|
// The required time is also not predictable.
|
|
|
|
//
|
|
|
|
// At this moment success can not be checked.
|
|
|
|
//
|
2022-02-17 16:10:49 +00:00
|
|
|
// Immediately panics if parameters are set incorrectly (see PrmAnnounceSpace docs).
|
2021-12-02 12:21:54 +00:00
|
|
|
// Context is required and must not be nil. It is used for network communication.
|
|
|
|
//
|
2022-01-24 10:33:43 +00:00
|
|
|
// Return statuses:
|
|
|
|
// - global (see Client docs).
|
2022-02-17 16:10:49 +00:00
|
|
|
func (c *Client) ContainerAnnounceUsedSpace(ctx context.Context, prm PrmAnnounceSpace) (*ResAnnounceSpace, error) {
|
2021-12-02 12:21:54 +00:00
|
|
|
// check parameters
|
|
|
|
switch {
|
|
|
|
case ctx == nil:
|
|
|
|
panic(panicMsgMissingContext)
|
|
|
|
case len(prm.announcements) == 0:
|
|
|
|
panic("missing announcements")
|
2021-11-09 08:07:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// convert list of SDK announcement structures into NeoFS-API v2 list
|
2022-03-11 09:16:08 +00:00
|
|
|
v2announce := make([]v2container.UsedSpaceAnnouncement, len(prm.announcements))
|
2021-12-02 12:21:54 +00:00
|
|
|
for i := range prm.announcements {
|
2022-03-11 09:16:08 +00:00
|
|
|
v2announce[i] = *prm.announcements[i].ToV2()
|
2021-11-09 08:07:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// prepare body of the NeoFS-API v2 request and request itself
|
|
|
|
reqBody := new(v2container.AnnounceUsedSpaceRequestBody)
|
|
|
|
reqBody.SetAnnouncements(v2announce)
|
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// form request
|
|
|
|
var req v2container.AnnounceUsedSpaceRequest
|
|
|
|
|
2021-11-09 08:07:49 +00:00
|
|
|
req.SetBody(reqBody)
|
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// init call context
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-11-16 18:17:25 +00:00
|
|
|
var (
|
2021-12-02 12:21:54 +00:00
|
|
|
cc contextCall
|
2022-02-17 16:10:49 +00:00
|
|
|
res ResAnnounceSpace
|
2021-11-16 18:17:25 +00:00
|
|
|
)
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
c.initCallContext(&cc)
|
2022-03-03 11:04:53 +00:00
|
|
|
cc.meta = prm.prmCommonMeta
|
2021-12-02 12:21:54 +00:00
|
|
|
cc.req = &req
|
|
|
|
cc.statusRes = &res
|
|
|
|
cc.call = func() (responseV2, error) {
|
2022-03-07 11:39:49 +00:00
|
|
|
return rpcapi.AnnounceUsedSpace(&c.c, &req, client.WithContext(ctx))
|
2021-12-02 12:21:54 +00:00
|
|
|
}
|
2021-11-16 18:17:25 +00:00
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
// process call
|
|
|
|
if !cc.processCall() {
|
|
|
|
return nil, cc.err
|
2021-11-09 08:07:49 +00:00
|
|
|
}
|
|
|
|
|
2021-12-02 12:21:54 +00:00
|
|
|
return &res, nil
|
2021-11-09 08:07:49 +00:00
|
|
|
}
|