2020-08-17 12:08:00 +00:00
|
|
|
package container
|
|
|
|
|
|
|
|
import (
|
2023-03-07 10:38:56 +00:00
|
|
|
container "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/container/grpc"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/netmap"
|
|
|
|
netmapGRPC "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/netmap/grpc"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs"
|
|
|
|
refsGRPC "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs/grpc"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/grpc"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/message"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session"
|
|
|
|
sessionGRPC "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session/grpc"
|
2020-08-17 12:08:00 +00:00
|
|
|
)
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (a *Attribute) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *container.Container_Attribute
|
2020-08-17 12:08:00 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if a != nil {
|
|
|
|
m = new(container.Container_Attribute)
|
2020-08-17 12:08:00 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetKey(a.key)
|
|
|
|
m.SetValue(a.val)
|
|
|
|
}
|
2020-08-17 12:08:00 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (a *Attribute) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*container.Container_Attribute)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-17 12:08:00 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
a.key = v.GetKey()
|
|
|
|
a.val = v.GetValue()
|
2020-08-17 12:08:00 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
2020-08-17 12:08:00 +00:00
|
|
|
}
|
|
|
|
|
2024-08-27 12:12:31 +00:00
|
|
|
func AttributesToGRPC(xs []Attribute) (res []container.Container_Attribute) {
|
2021-03-12 12:57:23 +00:00
|
|
|
if xs != nil {
|
2024-08-27 12:12:31 +00:00
|
|
|
res = make([]container.Container_Attribute, 0, len(xs))
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
for i := range xs {
|
2024-08-27 12:12:31 +00:00
|
|
|
res = append(res, *xs[i].ToGRPCMessage().(*container.Container_Attribute))
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
2020-08-17 12:08:00 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return
|
|
|
|
}
|
2020-08-17 12:08:00 +00:00
|
|
|
|
2024-08-27 12:12:31 +00:00
|
|
|
func AttributesFromGRPC(xs []container.Container_Attribute) (res []Attribute, err error) {
|
2021-03-12 12:57:23 +00:00
|
|
|
if xs != nil {
|
2022-03-02 08:18:59 +00:00
|
|
|
res = make([]Attribute, len(xs))
|
2020-08-17 12:08:00 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
for i := range xs {
|
2024-08-27 12:12:31 +00:00
|
|
|
err = res[i].FromGRPCMessage(&xs[i])
|
|
|
|
if err != nil {
|
|
|
|
return
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
2020-08-17 12:08:00 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (c *Container) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *container.Container
|
2020-08-17 12:08:00 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if c != nil {
|
|
|
|
m = new(container.Container)
|
2020-08-17 12:08:00 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetVersion(c.version.ToGRPCMessage().(*refsGRPC.Version))
|
|
|
|
m.SetOwnerId(c.ownerID.ToGRPCMessage().(*refsGRPC.OwnerID))
|
|
|
|
m.SetPlacementPolicy(c.policy.ToGRPCMessage().(*netmapGRPC.PlacementPolicy))
|
|
|
|
m.SetAttributes(AttributesToGRPC(c.attr))
|
|
|
|
m.SetBasicAcl(c.basicACL)
|
|
|
|
m.SetNonce(c.nonce)
|
|
|
|
}
|
2020-08-17 12:08:00 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (c *Container) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*container.Container)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-17 12:08:00 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-17 12:08:00 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
version := v.GetVersion()
|
|
|
|
if version == nil {
|
|
|
|
c.version = nil
|
|
|
|
} else {
|
|
|
|
if c.version == nil {
|
|
|
|
c.version = new(refs.Version)
|
|
|
|
}
|
2020-08-17 12:08:00 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = c.version.FromGRPCMessage(version)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-17 12:08:00 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
ownerID := v.GetOwnerId()
|
|
|
|
if ownerID == nil {
|
|
|
|
c.ownerID = nil
|
|
|
|
} else {
|
|
|
|
if c.ownerID == nil {
|
|
|
|
c.ownerID = new(refs.OwnerID)
|
|
|
|
}
|
2020-08-17 12:08:00 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = c.ownerID.FromGRPCMessage(ownerID)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-17 12:08:00 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
policy := v.GetPlacementPolicy()
|
|
|
|
if policy == nil {
|
|
|
|
c.policy = nil
|
|
|
|
} else {
|
|
|
|
if c.policy == nil {
|
|
|
|
c.policy = new(netmap.PlacementPolicy)
|
|
|
|
}
|
2020-08-17 12:08:00 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = c.policy.FromGRPCMessage(policy)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-17 12:08:00 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
c.attr, err = AttributesFromGRPC(v.GetAttributes())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2020-08-17 12:08:00 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
c.basicACL = v.GetBasicAcl()
|
|
|
|
c.nonce = v.GetNonce()
|
2020-08-17 12:08:00 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
2020-08-17 12:08:00 +00:00
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2022-03-02 10:15:36 +00:00
|
|
|
func toSignatureRFC6979(s *refs.Signature) *refsGRPC.SignatureRFC6979 {
|
|
|
|
var res *refsGRPC.SignatureRFC6979
|
|
|
|
|
|
|
|
if s != nil {
|
|
|
|
res = new(refsGRPC.SignatureRFC6979)
|
|
|
|
res.SetKey(s.GetKey())
|
|
|
|
res.SetSign(s.GetSign())
|
|
|
|
}
|
|
|
|
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *PutRequestBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *container.PutRequest_Body
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(container.PutRequest_Body)
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetContainer(r.cnr.ToGRPCMessage().(*container.Container))
|
2022-03-02 10:15:36 +00:00
|
|
|
m.SetSignature(toSignatureRFC6979(r.sig))
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *PutRequestBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*container.PutRequest_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
cnr := v.GetContainer()
|
|
|
|
if cnr == nil {
|
|
|
|
r.cnr = nil
|
|
|
|
} else {
|
|
|
|
if r.cnr == nil {
|
|
|
|
r.cnr = new(Container)
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.cnr.FromGRPCMessage(cnr)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
sig := v.GetSignature()
|
|
|
|
if sig == nil {
|
|
|
|
r.sig = nil
|
|
|
|
} else {
|
|
|
|
if r.sig == nil {
|
|
|
|
r.sig = new(refs.Signature)
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2022-03-02 10:15:36 +00:00
|
|
|
r.sig.SetKey(sig.GetKey())
|
|
|
|
r.sig.SetSign(sig.GetSign())
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *PutRequest) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *container.PutRequest
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(container.PutRequest)
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetBody(r.body.ToGRPCMessage().(*container.PutRequest_Body))
|
|
|
|
r.RequestHeaders.ToMessage(m)
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *PutRequest) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*container.PutRequest)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
body := v.GetBody()
|
|
|
|
if body == nil {
|
|
|
|
r.body = nil
|
|
|
|
} else {
|
|
|
|
if r.body == nil {
|
|
|
|
r.body = new(PutRequestBody)
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return r.RequestHeaders.FromMessage(v)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *PutResponseBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *container.PutResponse_Body
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(container.PutResponse_Body)
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetContainerId(r.cid.ToGRPCMessage().(*refsGRPC.ContainerID))
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *PutResponseBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*container.PutResponse_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
cid := v.GetContainerId()
|
|
|
|
if cid == nil {
|
|
|
|
r.cid = nil
|
|
|
|
} else {
|
|
|
|
if r.cid == nil {
|
|
|
|
r.cid = new(refs.ContainerID)
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.cid.FromGRPCMessage(cid)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return err
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *PutResponse) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *container.PutResponse
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(container.PutResponse)
|
|
|
|
|
|
|
|
m.SetBody(r.body.ToGRPCMessage().(*container.PutResponse_Body))
|
|
|
|
r.ResponseHeaders.ToMessage(m)
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *PutResponse) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*container.PutResponse)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
body := v.GetBody()
|
|
|
|
if body == nil {
|
|
|
|
r.body = nil
|
|
|
|
} else {
|
|
|
|
if r.body == nil {
|
|
|
|
r.body = new(PutResponseBody)
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return r.ResponseHeaders.FromMessage(v)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetRequestBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *container.GetRequest_Body
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(container.GetRequest_Body)
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetContainerId(r.cid.ToGRPCMessage().(*refsGRPC.ContainerID))
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetRequestBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*container.GetRequest_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
cid := v.GetContainerId()
|
|
|
|
if cid == nil {
|
|
|
|
r.cid = nil
|
|
|
|
} else {
|
|
|
|
if r.cid == nil {
|
|
|
|
r.cid = new(refs.ContainerID)
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.cid.FromGRPCMessage(cid)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *GetRequest) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *container.GetRequest
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(container.GetRequest)
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetBody(r.body.ToGRPCMessage().(*container.GetRequest_Body))
|
|
|
|
r.RequestHeaders.ToMessage(m)
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetRequest) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*container.GetRequest)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
body := v.GetBody()
|
|
|
|
if body == nil {
|
|
|
|
r.body = nil
|
|
|
|
} else {
|
|
|
|
if r.body == nil {
|
|
|
|
r.body = new(GetRequestBody)
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return r.RequestHeaders.FromMessage(v)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetResponseBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *container.GetResponse_Body
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(container.GetResponse_Body)
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetContainer(r.cnr.ToGRPCMessage().(*container.Container))
|
2021-05-24 18:18:56 +00:00
|
|
|
m.SetSessionToken(r.token.ToGRPCMessage().(*sessionGRPC.SessionToken))
|
2022-03-02 10:15:36 +00:00
|
|
|
m.SetSignature(toSignatureRFC6979(r.sig))
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetResponseBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*container.GetResponse_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
cnr := v.GetContainer()
|
|
|
|
if cnr == nil {
|
|
|
|
r.cnr = nil
|
|
|
|
} else {
|
|
|
|
if r.cnr == nil {
|
|
|
|
r.cnr = new(Container)
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.cnr.FromGRPCMessage(cnr)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-05-24 18:18:56 +00:00
|
|
|
sig := v.GetSignature()
|
|
|
|
if sig == nil {
|
|
|
|
r.sig = nil
|
|
|
|
} else {
|
|
|
|
if r.sig == nil {
|
|
|
|
r.sig = new(refs.Signature)
|
|
|
|
}
|
|
|
|
|
2022-03-02 10:15:36 +00:00
|
|
|
r.sig.SetKey(sig.GetKey())
|
|
|
|
r.sig.SetSign(sig.GetSign())
|
2021-05-24 18:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
token := v.GetSessionToken()
|
|
|
|
if token == nil {
|
|
|
|
r.token = nil
|
|
|
|
} else {
|
|
|
|
if r.token == nil {
|
2022-02-25 07:36:46 +00:00
|
|
|
r.token = new(session.Token)
|
2021-05-24 18:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = r.token.FromGRPCMessage(token)
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *GetResponse) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *container.GetResponse
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(container.GetResponse)
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetBody(r.body.ToGRPCMessage().(*container.GetResponse_Body))
|
|
|
|
r.ResponseHeaders.ToMessage(m)
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetResponse) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*container.GetResponse)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
body := v.GetBody()
|
|
|
|
if body == nil {
|
|
|
|
r.body = nil
|
|
|
|
} else {
|
|
|
|
if r.body == nil {
|
|
|
|
r.body = new(GetResponseBody)
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return r.ResponseHeaders.FromMessage(v)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *DeleteRequestBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *container.DeleteRequest_Body
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(container.DeleteRequest_Body)
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetContainerId(r.cid.ToGRPCMessage().(*refsGRPC.ContainerID))
|
2022-03-02 10:15:36 +00:00
|
|
|
m.SetSignature(toSignatureRFC6979(r.sig))
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *DeleteRequestBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*container.DeleteRequest_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
cid := v.GetContainerId()
|
|
|
|
if cid == nil {
|
|
|
|
r.cid = nil
|
|
|
|
} else {
|
|
|
|
if r.cid == nil {
|
|
|
|
r.cid = new(refs.ContainerID)
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.cid.FromGRPCMessage(cid)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
sig := v.GetSignature()
|
|
|
|
if sig == nil {
|
|
|
|
r.sig = nil
|
|
|
|
} else {
|
|
|
|
if r.sig == nil {
|
|
|
|
r.sig = new(refs.Signature)
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2022-03-02 10:15:36 +00:00
|
|
|
r.sig.SetKey(sig.GetKey())
|
|
|
|
r.sig.SetSign(sig.GetSign())
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return err
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *DeleteRequest) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *container.DeleteRequest
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(container.DeleteRequest)
|
|
|
|
|
|
|
|
m.SetBody(r.body.ToGRPCMessage().(*container.DeleteRequest_Body))
|
|
|
|
r.RequestHeaders.ToMessage(m)
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *DeleteRequest) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*container.DeleteRequest)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
body := v.GetBody()
|
|
|
|
if body == nil {
|
|
|
|
r.body = nil
|
|
|
|
} else {
|
|
|
|
if r.body == nil {
|
|
|
|
r.body = new(DeleteRequestBody)
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return r.RequestHeaders.FromMessage(v)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *DeleteResponseBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *container.DeleteResponse_Body
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(container.DeleteResponse_Body)
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *DeleteResponseBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*container.DeleteResponse_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *DeleteResponse) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *container.DeleteResponse
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(container.DeleteResponse)
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetBody(r.body.ToGRPCMessage().(*container.DeleteResponse_Body))
|
|
|
|
r.ResponseHeaders.ToMessage(m)
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *DeleteResponse) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*container.DeleteResponse)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
body := v.GetBody()
|
|
|
|
if body == nil {
|
|
|
|
r.body = nil
|
|
|
|
} else {
|
|
|
|
if r.body == nil {
|
|
|
|
r.body = new(DeleteResponseBody)
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return r.ResponseHeaders.FromMessage(v)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *ListRequestBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *container.ListRequest_Body
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(container.ListRequest_Body)
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetOwnerId(r.ownerID.ToGRPCMessage().(*refsGRPC.OwnerID))
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *ListRequestBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*container.ListRequest_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
ownerID := v.GetOwnerId()
|
|
|
|
if ownerID == nil {
|
|
|
|
r.ownerID = nil
|
|
|
|
} else {
|
|
|
|
if r.ownerID == nil {
|
|
|
|
r.ownerID = new(refs.OwnerID)
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.ownerID.FromGRPCMessage(ownerID)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *ListRequest) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *container.ListRequest
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(container.ListRequest)
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetBody(r.body.ToGRPCMessage().(*container.ListRequest_Body))
|
|
|
|
r.RequestHeaders.ToMessage(m)
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *ListRequest) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*container.ListRequest)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
body := v.GetBody()
|
|
|
|
if body == nil {
|
|
|
|
r.body = nil
|
|
|
|
} else {
|
|
|
|
if r.body == nil {
|
|
|
|
r.body = new(ListRequestBody)
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return r.RequestHeaders.FromMessage(v)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *ListResponseBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *container.ListResponse_Body
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(container.ListResponse_Body)
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetContainerIds(refs.ContainerIDsToGRPCMessage(r.cidList))
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *ListResponseBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*container.ListResponse_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
r.cidList, err = refs.ContainerIDsFromGRPCMessage(v.GetContainerIds())
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return err
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *ListResponse) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *container.ListResponse
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(container.ListResponse)
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetBody(r.body.ToGRPCMessage().(*container.ListResponse_Body))
|
|
|
|
r.ResponseHeaders.ToMessage(m)
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *ListResponse) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*container.ListResponse)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
body := v.GetBody()
|
|
|
|
if body == nil {
|
|
|
|
r.body = nil
|
|
|
|
} else {
|
|
|
|
if r.body == nil {
|
|
|
|
r.body = new(ListResponseBody)
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-17 16:00:10 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return r.ResponseHeaders.FromMessage(v)
|
2020-08-17 16:00:10 +00:00
|
|
|
}
|