2020-07-24 13:54:03 +00:00
|
|
|
package container
|
|
|
|
|
2021-05-18 08:12:51 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
2021-11-09 20:52:29 +00:00
|
|
|
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
2021-05-18 08:12:51 +00:00
|
|
|
)
|
2020-07-24 13:54:03 +00:00
|
|
|
|
|
|
|
// DeleteArgs groups the arguments
|
|
|
|
// of delete container invocation call.
|
|
|
|
type DeleteArgs struct {
|
|
|
|
cid []byte // container identifier
|
|
|
|
|
|
|
|
sig []byte // container identifier signature
|
2021-05-26 09:59:16 +00:00
|
|
|
|
|
|
|
token []byte // binary session token
|
2021-11-12 15:14:55 +00:00
|
|
|
|
|
|
|
client.InvokePrmOptional
|
2020-07-24 13:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetCID sets the container identifier
|
|
|
|
// in a binary format.
|
|
|
|
func (p *DeleteArgs) SetCID(v []byte) {
|
|
|
|
p.cid = v
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetSignature sets the container identifier
|
|
|
|
// owner's signature.
|
|
|
|
func (p *DeleteArgs) SetSignature(v []byte) {
|
|
|
|
p.sig = v
|
|
|
|
}
|
|
|
|
|
2021-05-26 11:01:38 +00:00
|
|
|
// SetSessionToken sets token of the session
|
|
|
|
// within which the container was removed
|
|
|
|
// in a NeoFS API binary format.
|
|
|
|
func (p *DeleteArgs) SetSessionToken(v []byte) {
|
|
|
|
p.token = v
|
|
|
|
}
|
|
|
|
|
2020-07-24 13:54:03 +00:00
|
|
|
// Delete invokes the call of delete container
|
|
|
|
// method of NeoFS Container contract.
|
|
|
|
func (c *Client) Delete(args DeleteArgs) error {
|
2021-11-09 20:52:29 +00:00
|
|
|
prm := client.InvokePrm{}
|
|
|
|
|
|
|
|
prm.SetMethod(c.deleteMethod)
|
|
|
|
prm.SetArgs(args.cid, args.sig, args.token)
|
2021-11-12 15:14:55 +00:00
|
|
|
prm.InvokePrmOptional = args.InvokePrmOptional
|
2021-11-09 20:52:29 +00:00
|
|
|
|
|
|
|
err := c.client.Invoke(prm)
|
2021-05-18 08:12:51 +00:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("could not invoke method (%s): %w", c.deleteMethod, err)
|
|
|
|
}
|
|
|
|
return nil
|
2020-07-24 13:54:03 +00:00
|
|
|
}
|