frostfs-api-go-pogpp/pkg/container/container.go
Leonard Lyubich 63c8d6e9ea [#128] sdk: Use owner ID instead of NEO3Wallet
Replace owner.NEO3Wallet usage with owner.ID usage. Functions that process
the wallet address convert it to the owner identifier through the public
method.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-09-18 10:45:11 +03:00

41 lines
876 B
Go

package container
import (
"github.com/nspcc-dev/neofs-api-go/v2/container"
)
type Container struct {
container.Container
}
func New(opts ...NewOption) (*Container, error) {
cnrOptions := defaultContainerOptions()
for i := range opts {
opts[i].apply(&cnrOptions)
}
cnr := new(Container)
cnr.SetNonce(cnrOptions.nonce[:])
cnr.SetBasicACL(cnrOptions.acl)
if cnrOptions.policy != "" {
// todo: set placement policy
}
if cnrOptions.owner != nil {
cnr.SetOwnerID(cnrOptions.owner.ToV2())
}
attributes := make([]*container.Attribute, len(cnrOptions.attributes))
for i := range cnrOptions.attributes {
attribute := new(container.Attribute)
attribute.SetKey(cnrOptions.attributes[i].key)
attribute.SetValue(cnrOptions.attributes[i].value)
attributes[i] = attribute
}
if len(attributes) > 0 {
cnr.SetAttributes(attributes)
}
return cnr, nil
}