2020-08-17 14:01:53 +00:00
|
|
|
package session
|
|
|
|
|
|
|
|
import (
|
2020-08-20 10:32:02 +00:00
|
|
|
"fmt"
|
|
|
|
|
2023-03-07 10:38:56 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/acl"
|
|
|
|
aclGRPC "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/acl/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"
|
|
|
|
session "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session/grpc"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/status"
|
|
|
|
statusGRPC "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/status/grpc"
|
2020-08-17 14:01:53 +00:00
|
|
|
)
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (c *CreateRequestBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *session.CreateRequest_Body
|
2020-08-17 14:01:53 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if c != nil {
|
|
|
|
m = new(session.CreateRequest_Body)
|
2020-08-17 14:01:53 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetOwnerId(c.ownerID.ToGRPCMessage().(*refsGRPC.OwnerID))
|
|
|
|
m.SetExpiration(c.expiration)
|
|
|
|
}
|
2020-08-17 14:01:53 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (c *CreateRequestBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*session.CreateRequest_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-17 14:01:53 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-17 14:01:53 +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 14:01:53 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = c.ownerID.FromGRPCMessage(ownerID)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-17 14:01:53 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
c.expiration = v.GetExpiration()
|
2020-08-17 14:01:53 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
|
|
|
}
|
2020-08-17 14:01:53 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (c *CreateRequest) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *session.CreateRequest
|
2020-08-17 14:01:53 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if c != nil {
|
|
|
|
m = new(session.CreateRequest)
|
2020-08-17 14:01:53 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetBody(c.body.ToGRPCMessage().(*session.CreateRequest_Body))
|
|
|
|
c.RequestHeaders.ToMessage(m)
|
|
|
|
}
|
2020-08-17 14:01:53 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (c *CreateRequest) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*session.CreateRequest)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-17 14:01:53 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-17 14:01:53 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
body := v.GetBody()
|
|
|
|
if body == nil {
|
|
|
|
c.body = nil
|
|
|
|
} else {
|
|
|
|
if c.body == nil {
|
|
|
|
c.body = new(CreateRequestBody)
|
|
|
|
}
|
2020-08-17 14:01:53 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = c.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-17 14:01:53 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return c.RequestHeaders.FromMessage(v)
|
2020-08-17 14:01:53 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (c *CreateResponseBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *session.CreateResponse_Body
|
2020-08-17 14:01:53 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if c != nil {
|
|
|
|
m = new(session.CreateResponse_Body)
|
2020-08-17 14:01:53 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetSessionKey(c.sessionKey)
|
|
|
|
m.SetId(c.id)
|
|
|
|
}
|
2020-08-17 14:01:53 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (c *CreateResponseBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*session.CreateResponse_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-17 14:01:53 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
c.sessionKey = v.GetSessionKey()
|
|
|
|
c.id = v.GetId()
|
2020-08-17 14:01:53 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
2020-08-17 14:01:53 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (c *CreateResponse) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *session.CreateResponse
|
2020-08-17 14:01:53 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if c != nil {
|
|
|
|
m = new(session.CreateResponse)
|
2020-08-17 14:01:53 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetBody(c.body.ToGRPCMessage().(*session.CreateResponse_Body))
|
|
|
|
c.ResponseHeaders.ToMessage(m)
|
|
|
|
}
|
2020-08-17 14:01:53 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (c *CreateResponse) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*session.CreateResponse)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-17 14:01:53 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-17 14:01:53 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
body := v.GetBody()
|
|
|
|
if body == nil {
|
|
|
|
c.body = nil
|
|
|
|
} else {
|
|
|
|
if c.body == nil {
|
|
|
|
c.body = new(CreateResponseBody)
|
|
|
|
}
|
2020-08-17 14:01:53 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = c.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return c.ResponseHeaders.FromMessage(v)
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (l *TokenLifetime) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *session.SessionToken_Body_TokenLifetime
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if l != nil {
|
|
|
|
m = new(session.SessionToken_Body_TokenLifetime)
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetExp(l.exp)
|
|
|
|
m.SetIat(l.iat)
|
|
|
|
m.SetNbf(l.nbf)
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (l *TokenLifetime) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*session.SessionToken_Body_TokenLifetime)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
l.exp = v.GetExp()
|
|
|
|
l.iat = v.GetIat()
|
|
|
|
l.nbf = v.GetNbf()
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (x *XHeader) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *session.XHeader
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if x != nil {
|
|
|
|
m = new(session.XHeader)
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetKey(x.key)
|
|
|
|
m.SetValue(x.val)
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (x *XHeader) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*session.XHeader)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
x.key = v.GetKey()
|
|
|
|
x.val = v.GetValue()
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2022-03-02 08:01:03 +00:00
|
|
|
func XHeadersToGRPC(xs []XHeader) (res []*session.XHeader) {
|
2021-03-12 12:57:23 +00:00
|
|
|
if xs != nil {
|
|
|
|
res = make([]*session.XHeader, 0, len(xs))
|
|
|
|
|
|
|
|
for i := range xs {
|
|
|
|
res = append(res, xs[i].ToGRPCMessage().(*session.XHeader))
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2022-03-02 08:01:03 +00:00
|
|
|
func XHeadersFromGRPC(xs []*session.XHeader) (res []XHeader, err error) {
|
2021-03-12 12:57:23 +00:00
|
|
|
if xs != nil {
|
2022-03-02 08:01:03 +00:00
|
|
|
res = make([]XHeader, len(xs))
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
for i := range xs {
|
|
|
|
if xs[i] != nil {
|
2022-03-02 08:01:03 +00:00
|
|
|
err = res[i].FromGRPCMessage(xs[i])
|
2021-03-12 12:57:23 +00:00
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
func (t *Token) ToGRPCMessage() grpc.Message {
|
2021-03-12 12:57:23 +00:00
|
|
|
var m *session.SessionToken
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if t != nil {
|
|
|
|
m = new(session.SessionToken)
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetBody(t.body.ToGRPCMessage().(*session.SessionToken_Body))
|
|
|
|
m.SetSignature(t.sig.ToGRPCMessage().(*refsGRPC.Signature))
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
func (t *Token) FromGRPCMessage(m grpc.Message) error {
|
2021-03-12 12:57:23 +00:00
|
|
|
v, ok := m.(*session.SessionToken)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
body := v.GetBody()
|
|
|
|
if body == nil {
|
|
|
|
t.body = nil
|
|
|
|
} else {
|
|
|
|
if t.body == nil {
|
2022-02-25 07:36:46 +00:00
|
|
|
t.body = new(TokenBody)
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = t.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
sig := v.GetSignature()
|
|
|
|
if sig == nil {
|
|
|
|
t.sig = nil
|
|
|
|
} else {
|
|
|
|
if t.sig == nil {
|
|
|
|
t.sig = new(refs.Signature)
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = t.sig.FromGRPCMessage(sig)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *RequestVerificationHeader) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *session.RequestVerificationHeader
|
|
|
|
|
|
|
|
if r != nil {
|
|
|
|
m = new(session.RequestVerificationHeader)
|
|
|
|
|
|
|
|
m.SetBodySignature(r.bodySig.ToGRPCMessage().(*refsGRPC.Signature))
|
|
|
|
m.SetMetaSignature(r.metaSig.ToGRPCMessage().(*refsGRPC.Signature))
|
|
|
|
m.SetOriginSignature(r.originSig.ToGRPCMessage().(*refsGRPC.Signature))
|
|
|
|
m.SetOrigin(r.origin.ToGRPCMessage().(*session.RequestVerificationHeader))
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return m
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *RequestVerificationHeader) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*session.RequestVerificationHeader)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
originSig := v.GetOriginSignature()
|
|
|
|
if originSig == nil {
|
|
|
|
r.originSig = nil
|
|
|
|
} else {
|
|
|
|
if r.originSig == nil {
|
|
|
|
r.originSig = new(refs.Signature)
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.originSig.FromGRPCMessage(originSig)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
metaSig := v.GetMetaSignature()
|
|
|
|
if metaSig == nil {
|
|
|
|
r.metaSig = nil
|
|
|
|
} else {
|
|
|
|
if r.metaSig == nil {
|
|
|
|
r.metaSig = new(refs.Signature)
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.metaSig.FromGRPCMessage(metaSig)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
bodySig := v.GetBodySignature()
|
|
|
|
if bodySig == nil {
|
|
|
|
r.bodySig = nil
|
|
|
|
} else {
|
|
|
|
if r.bodySig == nil {
|
|
|
|
r.bodySig = new(refs.Signature)
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.bodySig.FromGRPCMessage(bodySig)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
origin := v.GetOrigin()
|
|
|
|
if origin == nil {
|
|
|
|
r.origin = nil
|
|
|
|
} else {
|
|
|
|
if r.origin == nil {
|
|
|
|
r.origin = new(RequestVerificationHeader)
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.origin.FromGRPCMessage(origin)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *RequestMetaHeader) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *session.RequestMetaHeader
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(session.RequestMetaHeader)
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetVersion(r.version.ToGRPCMessage().(*refsGRPC.Version))
|
|
|
|
m.SetSessionToken(r.sessionToken.ToGRPCMessage().(*session.SessionToken))
|
|
|
|
m.SetBearerToken(r.bearerToken.ToGRPCMessage().(*aclGRPC.BearerToken))
|
|
|
|
m.SetXHeaders(XHeadersToGRPC(r.xHeaders))
|
|
|
|
m.SetEpoch(r.epoch)
|
|
|
|
m.SetTtl(r.ttl)
|
|
|
|
m.SetOrigin(r.origin.ToGRPCMessage().(*session.RequestMetaHeader))
|
2022-01-13 12:25:03 +00:00
|
|
|
m.SetNetworkMagic(r.netMagic)
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *RequestMetaHeader) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*session.RequestMetaHeader)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
version := v.GetVersion()
|
|
|
|
if version == nil {
|
|
|
|
r.version = nil
|
|
|
|
} else {
|
|
|
|
if r.version == nil {
|
|
|
|
r.version = new(refs.Version)
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.version.FromGRPCMessage(version)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
sessionToken := v.GetSessionToken()
|
|
|
|
if sessionToken == nil {
|
|
|
|
r.sessionToken = nil
|
|
|
|
} else {
|
|
|
|
if r.sessionToken == nil {
|
2022-02-25 07:36:46 +00:00
|
|
|
r.sessionToken = new(Token)
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.sessionToken.FromGRPCMessage(sessionToken)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
bearerToken := v.GetBearerToken()
|
|
|
|
if bearerToken == nil {
|
|
|
|
r.bearerToken = nil
|
|
|
|
} else {
|
|
|
|
if r.bearerToken == nil {
|
|
|
|
r.bearerToken = new(acl.BearerToken)
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.bearerToken.FromGRPCMessage(bearerToken)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
origin := v.GetOrigin()
|
|
|
|
if origin == nil {
|
|
|
|
r.origin = nil
|
|
|
|
} else {
|
|
|
|
if r.origin == nil {
|
|
|
|
r.origin = new(RequestMetaHeader)
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.origin.FromGRPCMessage(origin)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
r.xHeaders, err = XHeadersFromGRPC(v.GetXHeaders())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
r.epoch = v.GetEpoch()
|
|
|
|
r.ttl = v.GetTtl()
|
2022-01-13 12:25:03 +00:00
|
|
|
r.netMagic = v.GetNetworkMagic()
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *ResponseVerificationHeader) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *session.ResponseVerificationHeader
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(session.ResponseVerificationHeader)
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetBodySignature(r.bodySig.ToGRPCMessage().(*refsGRPC.Signature))
|
|
|
|
m.SetMetaSignature(r.metaSig.ToGRPCMessage().(*refsGRPC.Signature))
|
|
|
|
m.SetOriginSignature(r.originSig.ToGRPCMessage().(*refsGRPC.Signature))
|
|
|
|
m.SetOrigin(r.origin.ToGRPCMessage().(*session.ResponseVerificationHeader))
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *ResponseVerificationHeader) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*session.ResponseVerificationHeader)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
originSig := v.GetOriginSignature()
|
|
|
|
if originSig == nil {
|
|
|
|
r.originSig = nil
|
|
|
|
} else {
|
|
|
|
if r.originSig == nil {
|
|
|
|
r.originSig = new(refs.Signature)
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.originSig.FromGRPCMessage(originSig)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
metaSig := v.GetMetaSignature()
|
|
|
|
if metaSig == nil {
|
|
|
|
r.metaSig = nil
|
|
|
|
} else {
|
|
|
|
if r.metaSig == nil {
|
|
|
|
r.metaSig = new(refs.Signature)
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.metaSig.FromGRPCMessage(metaSig)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
bodySig := v.GetBodySignature()
|
|
|
|
if bodySig == nil {
|
|
|
|
r.bodySig = nil
|
|
|
|
} else {
|
|
|
|
if r.bodySig == nil {
|
|
|
|
r.bodySig = new(refs.Signature)
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.bodySig.FromGRPCMessage(bodySig)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
origin := v.GetOrigin()
|
|
|
|
if origin == nil {
|
|
|
|
r.origin = nil
|
|
|
|
} else {
|
|
|
|
if r.origin == nil {
|
|
|
|
r.origin = new(ResponseVerificationHeader)
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.origin.FromGRPCMessage(origin)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *ResponseMetaHeader) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *session.ResponseMetaHeader
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(session.ResponseMetaHeader)
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetVersion(r.version.ToGRPCMessage().(*refsGRPC.Version))
|
|
|
|
m.SetXHeaders(XHeadersToGRPC(r.xHeaders))
|
|
|
|
m.SetEpoch(r.epoch)
|
|
|
|
m.SetTtl(r.ttl)
|
|
|
|
m.SetOrigin(r.origin.ToGRPCMessage().(*session.ResponseMetaHeader))
|
2021-11-06 10:40:15 +00:00
|
|
|
m.SetStatus(r.status.ToGRPCMessage().(*statusGRPC.Status))
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *ResponseMetaHeader) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*session.ResponseMetaHeader)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
version := v.GetVersion()
|
|
|
|
if version == nil {
|
|
|
|
r.version = nil
|
|
|
|
} else {
|
|
|
|
if r.version == nil {
|
|
|
|
r.version = new(refs.Version)
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.version.FromGRPCMessage(version)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
origin := v.GetOrigin()
|
|
|
|
if origin == nil {
|
|
|
|
r.origin = nil
|
|
|
|
} else {
|
|
|
|
if r.origin == nil {
|
|
|
|
r.origin = new(ResponseMetaHeader)
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.origin.FromGRPCMessage(origin)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2021-11-06 10:40:15 +00:00
|
|
|
st := v.GetStatus()
|
|
|
|
if st == nil {
|
|
|
|
r.status = nil
|
|
|
|
} else {
|
|
|
|
if r.status == nil {
|
|
|
|
r.status = new(status.Status)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = r.status.FromGRPCMessage(st)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
r.xHeaders, err = XHeadersFromGRPC(v.GetXHeaders())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
r.epoch = v.GetEpoch()
|
|
|
|
r.ttl = v.GetTtl()
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func ObjectSessionVerbToGRPCField(v ObjectSessionVerb) session.ObjectSessionContext_Verb {
|
|
|
|
switch v {
|
|
|
|
case ObjectVerbPut:
|
|
|
|
return session.ObjectSessionContext_PUT
|
|
|
|
case ObjectVerbGet:
|
|
|
|
return session.ObjectSessionContext_GET
|
|
|
|
case ObjectVerbHead:
|
|
|
|
return session.ObjectSessionContext_HEAD
|
|
|
|
case ObjectVerbSearch:
|
|
|
|
return session.ObjectSessionContext_SEARCH
|
|
|
|
case ObjectVerbDelete:
|
|
|
|
return session.ObjectSessionContext_DELETE
|
|
|
|
case ObjectVerbRange:
|
|
|
|
return session.ObjectSessionContext_RANGE
|
|
|
|
case ObjectVerbRangeHash:
|
|
|
|
return session.ObjectSessionContext_RANGEHASH
|
|
|
|
default:
|
|
|
|
return session.ObjectSessionContext_VERB_UNSPECIFIED
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func ObjectSessionVerbFromGRPCField(v session.ObjectSessionContext_Verb) ObjectSessionVerb {
|
|
|
|
switch v {
|
|
|
|
case session.ObjectSessionContext_PUT:
|
|
|
|
return ObjectVerbPut
|
|
|
|
case session.ObjectSessionContext_GET:
|
|
|
|
return ObjectVerbGet
|
|
|
|
case session.ObjectSessionContext_HEAD:
|
|
|
|
return ObjectVerbHead
|
|
|
|
case session.ObjectSessionContext_SEARCH:
|
|
|
|
return ObjectVerbSearch
|
|
|
|
case session.ObjectSessionContext_DELETE:
|
|
|
|
return ObjectVerbDelete
|
|
|
|
case session.ObjectSessionContext_RANGE:
|
|
|
|
return ObjectVerbRange
|
|
|
|
case session.ObjectSessionContext_RANGEHASH:
|
|
|
|
return ObjectVerbRangeHash
|
|
|
|
default:
|
|
|
|
return ObjectVerbUnknown
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (c *ObjectSessionContext) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *session.ObjectSessionContext
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if c != nil {
|
|
|
|
m = new(session.ObjectSessionContext)
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetVerb(ObjectSessionVerbToGRPCField(c.verb))
|
2022-09-16 15:09:25 +00:00
|
|
|
m.SetTarget(c.cnr.ToGRPCMessage().(*refsGRPC.ContainerID), refs.ObjectIDListToGRPCMessage(c.objs))
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (c *ObjectSessionContext) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*session.ObjectSessionContext)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2022-09-16 15:09:25 +00:00
|
|
|
cnr := v.GetTarget().GetContainer()
|
|
|
|
if cnr == nil {
|
|
|
|
c.cnr = nil
|
2021-03-12 12:57:23 +00:00
|
|
|
} else {
|
2022-09-16 15:09:25 +00:00
|
|
|
if c.cnr == nil {
|
|
|
|
c.cnr = new(refs.ContainerID)
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
2020-08-17 14:01:53 +00:00
|
|
|
|
2022-09-16 15:09:25 +00:00
|
|
|
err = c.cnr.FromGRPCMessage(cnr)
|
2021-03-12 12:57:23 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2022-09-16 15:09:25 +00:00
|
|
|
c.objs, err = refs.ObjectIDListFromGRPCMessage(v.GetTarget().GetObjects())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
c.verb = ObjectSessionVerbFromGRPCField(v.GetVerb())
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
func (t *TokenBody) ToGRPCMessage() grpc.Message {
|
2021-03-12 12:57:23 +00:00
|
|
|
var m *session.SessionToken_Body
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if t != nil {
|
|
|
|
m = new(session.SessionToken_Body)
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
switch typ := t.ctx.(type) {
|
|
|
|
default:
|
|
|
|
panic(fmt.Sprintf("unknown session context %T", typ))
|
|
|
|
case nil:
|
|
|
|
m.Context = nil
|
|
|
|
case *ObjectSessionContext:
|
|
|
|
m.SetObjectSessionContext(typ.ToGRPCMessage().(*session.ObjectSessionContext))
|
2021-05-24 14:46:39 +00:00
|
|
|
case *ContainerSessionContext:
|
|
|
|
m.SetContainerSessionContext(typ.ToGRPCMessage().(*session.ContainerSessionContext))
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetOwnerId(t.ownerID.ToGRPCMessage().(*refsGRPC.OwnerID))
|
|
|
|
m.SetId(t.id)
|
|
|
|
m.SetSessionKey(t.sessionKey)
|
|
|
|
m.SetLifetime(t.lifetime.ToGRPCMessage().(*session.SessionToken_Body_TokenLifetime))
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
func (t *TokenBody) FromGRPCMessage(m grpc.Message) error {
|
2021-03-12 12:57:23 +00:00
|
|
|
v, ok := m.(*session.SessionToken_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
|
|
|
|
|
|
|
t.ctx = nil
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
switch val := v.GetContext().(type) {
|
|
|
|
default:
|
2021-05-17 12:56:17 +00:00
|
|
|
err = fmt.Errorf("unknown session context %T", val)
|
2020-08-20 10:32:02 +00:00
|
|
|
case nil:
|
|
|
|
case *session.SessionToken_Body_Object:
|
2021-03-12 12:57:23 +00:00
|
|
|
ctx, ok := t.ctx.(*ObjectSessionContext)
|
|
|
|
if !ok {
|
|
|
|
ctx = new(ObjectSessionContext)
|
|
|
|
t.ctx = ctx
|
|
|
|
}
|
|
|
|
|
|
|
|
err = ctx.FromGRPCMessage(val.Object)
|
2021-05-24 14:46:39 +00:00
|
|
|
case *session.SessionToken_Body_Container:
|
|
|
|
ctx, ok := t.ctx.(*ContainerSessionContext)
|
|
|
|
if !ok {
|
|
|
|
ctx = new(ContainerSessionContext)
|
|
|
|
t.ctx = ctx
|
|
|
|
}
|
|
|
|
|
|
|
|
err = ctx.FromGRPCMessage(val.Container)
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
ownerID := v.GetOwnerId()
|
|
|
|
if ownerID == nil {
|
|
|
|
t.ownerID = nil
|
|
|
|
} else {
|
|
|
|
if t.ownerID == nil {
|
|
|
|
t.ownerID = new(refs.OwnerID)
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = t.ownerID.FromGRPCMessage(ownerID)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
lifetime := v.GetLifetime()
|
|
|
|
if lifetime == nil {
|
|
|
|
t.lifetime = nil
|
|
|
|
} else {
|
|
|
|
if t.lifetime == nil {
|
|
|
|
t.lifetime = new(TokenLifetime)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = t.lifetime.FromGRPCMessage(lifetime)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
t.id = v.GetId()
|
|
|
|
t.sessionKey = v.GetSessionKey()
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
2021-05-24 14:46:39 +00:00
|
|
|
|
|
|
|
// ContainerSessionVerbToGRPCField converts ContainerSessionVerb
|
|
|
|
// to gRPC-generated session.ContainerSessionContext_Verb.
|
|
|
|
//
|
|
|
|
// If v is outside of the ContainerSessionVerb enum,
|
|
|
|
// session.ContainerSessionContext_VERB_UNSPECIFIED is returned.
|
|
|
|
func ContainerSessionVerbToGRPCField(v ContainerSessionVerb) session.ContainerSessionContext_Verb {
|
|
|
|
switch v {
|
|
|
|
default:
|
|
|
|
return session.ContainerSessionContext_VERB_UNSPECIFIED
|
|
|
|
case ContainerVerbPut:
|
|
|
|
return session.ContainerSessionContext_PUT
|
|
|
|
case ContainerVerbDelete:
|
|
|
|
return session.ContainerSessionContext_DELETE
|
|
|
|
case ContainerVerbSetEACL:
|
|
|
|
return session.ContainerSessionContext_SETEACL
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ContainerSessionVerbFromGRPCField converts gRPC-generated
|
|
|
|
// session.ContainerSessionContext_Verb to ContainerSessionVerb.
|
|
|
|
//
|
|
|
|
// If v is outside of the session.ContainerSessionContext_Verb enum,
|
|
|
|
// ContainerVerbUnknown is returned.
|
|
|
|
func ContainerSessionVerbFromGRPCField(v session.ContainerSessionContext_Verb) ContainerSessionVerb {
|
|
|
|
switch v {
|
|
|
|
default:
|
|
|
|
return ContainerVerbUnknown
|
|
|
|
case session.ContainerSessionContext_PUT:
|
|
|
|
return ContainerVerbPut
|
|
|
|
case session.ContainerSessionContext_DELETE:
|
|
|
|
return ContainerVerbDelete
|
|
|
|
case session.ContainerSessionContext_SETEACL:
|
|
|
|
return ContainerVerbSetEACL
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ToGRPCMessage converts ContainerSessionContext to gRPC-generated
|
|
|
|
// session.ContainerSessionContext message.
|
|
|
|
func (x *ContainerSessionContext) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *session.ContainerSessionContext
|
|
|
|
|
|
|
|
if x != nil {
|
|
|
|
m = new(session.ContainerSessionContext)
|
|
|
|
|
|
|
|
m.SetVerb(ContainerSessionVerbToGRPCField(x.verb))
|
|
|
|
m.SetWildcard(x.wildcard)
|
|
|
|
m.SetContainerId(x.cid.ToGRPCMessage().(*refsGRPC.ContainerID))
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
// FromGRPCMessage tries to restore ContainerSessionContext from grpc.Message.
|
|
|
|
//
|
|
|
|
// Returns message.ErrUnexpectedMessageType if m is not
|
|
|
|
// a gRPC-generated session.ContainerSessionContext message.
|
|
|
|
func (x *ContainerSessionContext) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*session.ContainerSessionContext)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
cid := v.GetContainerId()
|
|
|
|
if cid == nil {
|
|
|
|
x.cid = nil
|
|
|
|
} else {
|
|
|
|
if x.cid == nil {
|
|
|
|
x.cid = new(refs.ContainerID)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = x.cid.FromGRPCMessage(cid)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
x.verb = ContainerSessionVerbFromGRPCField(v.GetVerb())
|
|
|
|
x.wildcard = v.GetWildcard()
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|