frostfs-node/pkg/morph/client/neofsid/addrm_keys.go
Evgenii Stratonikov 8c5c3ac9e8 [#625] client/neofsid: remove intermediate wrapper
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2022-02-08 09:43:54 +03:00

61 lines
1.3 KiB
Go

package neofsid
import (
"fmt"
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
)
type CommonBindPrm struct {
ownerID []byte // NeoFS account identifier
keys [][]byte // list of serialized public keys
client.InvokePrmOptional
}
func (x *CommonBindPrm) SetOptionalPrm(prm client.InvokePrmOptional) {
x.InvokePrmOptional = prm
}
// SetOwnerID sets NeoFS account identifier.
func (x *CommonBindPrm) SetOwnerID(v []byte) {
x.ownerID = v
}
// SetKeys sets list of public keys in a binary format.
func (x *CommonBindPrm) SetKeys(v [][]byte) {
x.keys = v
}
// AddKeys adds a list of public keys to/from NeoFS account.
func (x *Client) AddKeys(p CommonBindPrm) error {
prm := client.InvokePrm{}
prm.SetMethod(addKeysMethod)
prm.SetArgs(p.ownerID, p.keys)
prm.InvokePrmOptional = p.InvokePrmOptional
err := x.client.Invoke(prm)
if err != nil {
return fmt.Errorf("could not invoke method (%s): %w", addKeysMethod, err)
}
return nil
}
// RemoveKeys removes a list of public keys to/from NeoFS account.
func (x *Client) RemoveKeys(args CommonBindPrm) error {
prm := client.InvokePrm{}
prm.SetMethod(removeKeysMethod)
prm.SetArgs(args.ownerID, args.keys)
prm.InvokePrmOptional = args.InvokePrmOptional
err := x.client.Invoke(prm)
if err != nil {
return fmt.Errorf("could not invoke method (%s): %w", removeKeysMethod, err)
}
return nil
}