2020-08-17 17:26:25 +00:00
|
|
|
package object
|
|
|
|
|
|
|
|
import (
|
2020-08-18 10:23:26 +00:00
|
|
|
"fmt"
|
|
|
|
|
2023-03-07 10:38:56 +00:00
|
|
|
object "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/object/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 17:26:25 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TypeToGRPCField(t Type) object.ObjectType {
|
|
|
|
return object.ObjectType(t)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TypeFromGRPCField(t object.ObjectType) Type {
|
|
|
|
return Type(t)
|
|
|
|
}
|
|
|
|
|
|
|
|
func MatchTypeToGRPCField(t MatchType) object.MatchType {
|
|
|
|
return object.MatchType(t)
|
|
|
|
}
|
|
|
|
|
|
|
|
func MatchTypeFromGRPCField(t object.MatchType) MatchType {
|
|
|
|
return MatchType(t)
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (h *ShortHeader) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.ShortHeader
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if h != nil {
|
|
|
|
m = new(object.ShortHeader)
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetVersion(h.version.ToGRPCMessage().(*refsGRPC.Version))
|
|
|
|
m.SetOwnerId(h.ownerID.ToGRPCMessage().(*refsGRPC.OwnerID))
|
|
|
|
m.SetHomomorphicHash(h.homoHash.ToGRPCMessage().(*refsGRPC.Checksum))
|
|
|
|
m.SetPayloadHash(h.payloadHash.ToGRPCMessage().(*refsGRPC.Checksum))
|
|
|
|
m.SetObjectType(TypeToGRPCField(h.typ))
|
|
|
|
m.SetCreationEpoch(h.creatEpoch)
|
|
|
|
m.SetPayloadLength(h.payloadLen)
|
|
|
|
}
|
2020-12-17 10:18:07 +00:00
|
|
|
|
2020-08-17 17:26:25 +00:00
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (h *ShortHeader) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.ShortHeader)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-17 17:26:25 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
version := v.GetVersion()
|
|
|
|
if version == nil {
|
|
|
|
h.version = nil
|
|
|
|
} else {
|
|
|
|
if h.version == nil {
|
|
|
|
h.version = new(refs.Version)
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = h.version.FromGRPCMessage(version)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
ownerID := v.GetOwnerId()
|
|
|
|
if ownerID == nil {
|
|
|
|
h.ownerID = nil
|
|
|
|
} else {
|
|
|
|
if h.ownerID == nil {
|
|
|
|
h.ownerID = new(refs.OwnerID)
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = h.ownerID.FromGRPCMessage(ownerID)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
homoHash := v.GetHomomorphicHash()
|
|
|
|
if homoHash == nil {
|
|
|
|
h.homoHash = nil
|
|
|
|
} else {
|
|
|
|
if h.homoHash == nil {
|
|
|
|
h.homoHash = new(refs.Checksum)
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = h.homoHash.FromGRPCMessage(homoHash)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-12-17 10:18:07 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
payloadHash := v.GetPayloadHash()
|
|
|
|
if payloadHash == nil {
|
|
|
|
h.payloadHash = nil
|
|
|
|
} else {
|
|
|
|
if h.payloadHash == nil {
|
|
|
|
h.payloadHash = new(refs.Checksum)
|
|
|
|
}
|
2020-12-17 10:18:07 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = h.payloadHash.FromGRPCMessage(payloadHash)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
h.typ = TypeFromGRPCField(v.GetObjectType())
|
|
|
|
h.creatEpoch = v.GetCreationEpoch()
|
|
|
|
h.payloadLen = v.GetPayloadLength()
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
2020-08-17 17:26:25 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (a *Attribute) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.Header_Attribute
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if a != nil {
|
|
|
|
m = new(object.Header_Attribute)
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetKey(a.key)
|
|
|
|
m.SetValue(a.val)
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return m
|
2020-08-17 17:26:25 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (a *Attribute) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.Header_Attribute)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-17 17:26:25 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
a.key = v.GetKey()
|
|
|
|
a.val = v.GetValue()
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2024-08-27 12:12:31 +00:00
|
|
|
func AttributesToGRPC(xs []Attribute) (res []object.Header_Attribute) {
|
2021-03-12 12:57:23 +00:00
|
|
|
if xs != nil {
|
2024-08-27 12:12:31 +00:00
|
|
|
res = make([]object.Header_Attribute, 0, len(xs))
|
2020-08-17 17:26:25 +00:00
|
|
|
|
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().(*object.Header_Attribute))
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2024-08-27 12:12:31 +00:00
|
|
|
func AttributesFromGRPC(xs []object.Header_Attribute) (res []Attribute, err error) {
|
2021-03-12 12:57:23 +00:00
|
|
|
if xs != nil {
|
2022-02-28 12:06:51 +00:00
|
|
|
res = make([]Attribute, len(xs))
|
2020-08-17 17:26:25 +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
|
|
|
}
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (h *SplitHeader) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.Header_Split
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if h != nil {
|
|
|
|
m = new(object.Header_Split)
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetParent(h.par.ToGRPCMessage().(*refsGRPC.ObjectID))
|
|
|
|
m.SetPrevious(h.prev.ToGRPCMessage().(*refsGRPC.ObjectID))
|
|
|
|
m.SetParentHeader(h.parHdr.ToGRPCMessage().(*object.Header))
|
|
|
|
m.SetParentSignature(h.parSig.ToGRPCMessage().(*refsGRPC.Signature))
|
|
|
|
m.SetChildren(refs.ObjectIDListToGRPCMessage(h.children))
|
|
|
|
m.SetSplitId(h.splitID)
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return m
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (h *SplitHeader) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.Header_Split)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-17 17:26:25 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
par := v.GetParent()
|
|
|
|
if par == nil {
|
|
|
|
h.par = nil
|
|
|
|
} else {
|
|
|
|
if h.par == nil {
|
|
|
|
h.par = new(refs.ObjectID)
|
|
|
|
}
|
2020-11-24 17:14:03 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = h.par.FromGRPCMessage(par)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
prev := v.GetPrevious()
|
|
|
|
if prev == nil {
|
|
|
|
h.prev = nil
|
|
|
|
} else {
|
|
|
|
if h.prev == nil {
|
|
|
|
h.prev = new(refs.ObjectID)
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = h.prev.FromGRPCMessage(prev)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
parHdr := v.GetParentHeader()
|
|
|
|
if parHdr == nil {
|
|
|
|
h.parHdr = nil
|
|
|
|
} else {
|
|
|
|
if h.parHdr == nil {
|
|
|
|
h.parHdr = new(Header)
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = h.parHdr.FromGRPCMessage(parHdr)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
parSig := v.GetParentSignature()
|
|
|
|
if parSig == nil {
|
|
|
|
h.parSig = nil
|
|
|
|
} else {
|
|
|
|
if h.parSig == nil {
|
|
|
|
h.parSig = new(refs.Signature)
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = h.parSig.FromGRPCMessage(parSig)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
h.children, err = refs.ObjectIDListFromGRPCMessage(v.GetChildren())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
h.splitID = v.GetSplitId()
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2024-03-19 06:55:23 +00:00
|
|
|
func (h *ECHeader) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.Header_EC
|
|
|
|
|
|
|
|
if h != nil {
|
|
|
|
m = new(object.Header_EC)
|
|
|
|
|
|
|
|
m.Parent = h.Parent.ToGRPCMessage().(*refsGRPC.ObjectID)
|
2024-05-08 12:03:29 +00:00
|
|
|
m.ParentSplitId = h.ParentSplitID
|
2024-05-16 09:03:42 +00:00
|
|
|
m.ParentSplitParentId = h.ParentSplitParentID.ToGRPCMessage().(*refsGRPC.ObjectID)
|
2024-05-27 09:13:49 +00:00
|
|
|
m.ParentAttributes = AttributesToGRPC(h.ParentAttributes)
|
2024-03-19 06:55:23 +00:00
|
|
|
m.Index = h.Index
|
|
|
|
m.Total = h.Total
|
|
|
|
m.Header = h.Header
|
|
|
|
m.HeaderLength = h.HeaderLength
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *ECHeader) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.Header_EC)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
par := v.GetParent()
|
|
|
|
if par == nil {
|
|
|
|
h.Parent = nil
|
|
|
|
} else {
|
|
|
|
if h.Parent == nil {
|
|
|
|
h.Parent = new(refs.ObjectID)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = h.Parent.FromGRPCMessage(par)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-08 12:03:29 +00:00
|
|
|
h.ParentSplitID = v.GetParentSplitId()
|
2024-05-16 09:03:42 +00:00
|
|
|
|
|
|
|
parSplitParentID := v.GetParentSplitParentId()
|
|
|
|
if parSplitParentID == nil {
|
|
|
|
h.ParentSplitParentID = nil
|
|
|
|
} else {
|
|
|
|
if h.ParentSplitParentID == nil {
|
|
|
|
h.ParentSplitParentID = new(refs.ObjectID)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = h.ParentSplitParentID.FromGRPCMessage(parSplitParentID)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-27 09:13:49 +00:00
|
|
|
if h.ParentAttributes, err = AttributesFromGRPC(v.GetParentAttributes()); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2024-03-19 06:55:23 +00:00
|
|
|
h.Index = v.GetIndex()
|
|
|
|
h.Total = v.GetTotal()
|
|
|
|
h.Header = v.GetHeader()
|
|
|
|
h.HeaderLength = v.GetHeaderLength()
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (h *Header) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.Header
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if h != nil {
|
|
|
|
m = new(object.Header)
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetVersion(h.version.ToGRPCMessage().(*refsGRPC.Version))
|
|
|
|
m.SetPayloadHash(h.payloadHash.ToGRPCMessage().(*refsGRPC.Checksum))
|
|
|
|
m.SetOwnerId(h.ownerID.ToGRPCMessage().(*refsGRPC.OwnerID))
|
|
|
|
m.SetHomomorphicHash(h.homoHash.ToGRPCMessage().(*refsGRPC.Checksum))
|
|
|
|
m.SetContainerId(h.cid.ToGRPCMessage().(*refsGRPC.ContainerID))
|
|
|
|
m.SetSessionToken(h.sessionToken.ToGRPCMessage().(*sessionGRPC.SessionToken))
|
|
|
|
m.SetSplit(h.split.ToGRPCMessage().(*object.Header_Split))
|
2024-03-19 06:55:23 +00:00
|
|
|
m.Ec = h.ec.ToGRPCMessage().(*object.Header_EC)
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetAttributes(AttributesToGRPC(h.attr))
|
|
|
|
m.SetPayloadLength(h.payloadLen)
|
|
|
|
m.SetCreationEpoch(h.creatEpoch)
|
|
|
|
m.SetObjectType(TypeToGRPCField(h.typ))
|
2020-08-17 17:26:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (h *Header) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.Header)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
2023-05-03 10:58:42 +00:00
|
|
|
if err := h.fillVersion(v); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := h.fillPayloadHash(v); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := h.fillOwnerID(v); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := h.fillHomomorphicHash(v); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := h.fillContainerID(v); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := h.fillSessionToken(v); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := h.fillSplitHeader(v); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2024-03-19 06:55:23 +00:00
|
|
|
if err := h.fillECHeader(v); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2023-05-03 10:58:42 +00:00
|
|
|
|
|
|
|
h.attr, err = AttributesFromGRPC(v.GetAttributes())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
h.payloadLen = v.GetPayloadLength()
|
|
|
|
h.creatEpoch = v.GetCreationEpoch()
|
|
|
|
h.typ = TypeFromGRPCField(v.GetObjectType())
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Header) fillVersion(v *object.Header) error {
|
2021-03-12 12:57:23 +00:00
|
|
|
version := v.GetVersion()
|
|
|
|
if version == nil {
|
|
|
|
h.version = nil
|
2023-05-03 10:58:42 +00:00
|
|
|
return nil
|
|
|
|
}
|
2021-03-12 12:57:23 +00:00
|
|
|
|
2023-05-03 10:58:42 +00:00
|
|
|
if h.version == nil {
|
|
|
|
h.version = new(refs.Version)
|
2020-08-17 17:26:25 +00:00
|
|
|
}
|
2023-05-03 10:58:42 +00:00
|
|
|
return h.version.FromGRPCMessage(version)
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2023-05-03 10:58:42 +00:00
|
|
|
func (h *Header) fillPayloadHash(v *object.Header) error {
|
2021-03-12 12:57:23 +00:00
|
|
|
payloadHash := v.GetPayloadHash()
|
|
|
|
if payloadHash == nil {
|
|
|
|
h.payloadHash = nil
|
2023-05-03 10:58:42 +00:00
|
|
|
return nil
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2023-05-03 10:58:42 +00:00
|
|
|
if h.payloadHash == nil {
|
|
|
|
h.payloadHash = new(refs.Checksum)
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
2023-05-03 10:58:42 +00:00
|
|
|
return h.payloadHash.FromGRPCMessage(payloadHash)
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2023-05-03 10:58:42 +00:00
|
|
|
func (h *Header) fillOwnerID(v *object.Header) error {
|
2021-03-12 12:57:23 +00:00
|
|
|
ownerID := v.GetOwnerId()
|
|
|
|
if ownerID == nil {
|
|
|
|
h.ownerID = nil
|
2023-05-03 10:58:42 +00:00
|
|
|
return nil
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2023-05-03 10:58:42 +00:00
|
|
|
if h.ownerID == nil {
|
|
|
|
h.ownerID = new(refs.OwnerID)
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
2023-05-03 10:58:42 +00:00
|
|
|
return h.ownerID.FromGRPCMessage(ownerID)
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2023-05-03 10:58:42 +00:00
|
|
|
func (h *Header) fillHomomorphicHash(v *object.Header) error {
|
2021-03-12 12:57:23 +00:00
|
|
|
homoHash := v.GetHomomorphicHash()
|
|
|
|
if homoHash == nil {
|
|
|
|
h.homoHash = nil
|
2023-05-03 10:58:42 +00:00
|
|
|
return nil
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2023-05-03 10:58:42 +00:00
|
|
|
if h.homoHash == nil {
|
|
|
|
h.homoHash = new(refs.Checksum)
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
2023-05-03 10:58:42 +00:00
|
|
|
return h.homoHash.FromGRPCMessage(homoHash)
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2023-05-03 10:58:42 +00:00
|
|
|
func (h *Header) fillContainerID(v *object.Header) error {
|
2021-03-12 12:57:23 +00:00
|
|
|
cid := v.GetContainerId()
|
|
|
|
if cid == nil {
|
|
|
|
h.cid = nil
|
2023-05-03 10:58:42 +00:00
|
|
|
return nil
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2023-05-03 10:58:42 +00:00
|
|
|
if h.cid == nil {
|
|
|
|
h.cid = new(refs.ContainerID)
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
2023-05-03 10:58:42 +00:00
|
|
|
return h.cid.FromGRPCMessage(cid)
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2023-05-03 10:58:42 +00:00
|
|
|
func (h *Header) fillSessionToken(v *object.Header) error {
|
2021-03-12 12:57:23 +00:00
|
|
|
sessionToken := v.GetSessionToken()
|
|
|
|
if sessionToken == nil {
|
|
|
|
h.sessionToken = nil
|
2023-05-03 10:58:42 +00:00
|
|
|
return nil
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2023-05-03 10:58:42 +00:00
|
|
|
if h.sessionToken == nil {
|
|
|
|
h.sessionToken = new(session.Token)
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
2023-05-03 10:58:42 +00:00
|
|
|
return h.sessionToken.FromGRPCMessage(sessionToken)
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2023-05-03 10:58:42 +00:00
|
|
|
func (h *Header) fillSplitHeader(v *object.Header) error {
|
2021-03-12 12:57:23 +00:00
|
|
|
split := v.GetSplit()
|
|
|
|
if split == nil {
|
|
|
|
h.split = nil
|
2023-05-03 10:58:42 +00:00
|
|
|
return nil
|
2020-08-17 17:26:25 +00:00
|
|
|
}
|
|
|
|
|
2023-05-03 10:58:42 +00:00
|
|
|
if h.split == nil {
|
|
|
|
h.split = new(SplitHeader)
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
2023-05-03 10:58:42 +00:00
|
|
|
return h.split.FromGRPCMessage(split)
|
2020-08-17 17:26:25 +00:00
|
|
|
}
|
|
|
|
|
2024-03-19 06:55:23 +00:00
|
|
|
func (h *Header) fillECHeader(v *object.Header) error {
|
|
|
|
ec := v.GetEc()
|
|
|
|
if ec == nil {
|
|
|
|
h.ec = nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if h.ec == nil {
|
|
|
|
h.ec = new(ECHeader)
|
|
|
|
}
|
|
|
|
return h.ec.FromGRPCMessage(ec)
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (h *HeaderWithSignature) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.HeaderWithSignature
|
2020-09-08 10:39:13 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if h != nil {
|
|
|
|
m = new(object.HeaderWithSignature)
|
2020-09-08 10:39:13 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetSignature(h.signature.ToGRPCMessage().(*refsGRPC.Signature))
|
|
|
|
m.SetHeader(h.header.ToGRPCMessage().(*object.Header))
|
|
|
|
}
|
2020-09-08 10:39:13 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (h *HeaderWithSignature) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.HeaderWithSignature)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-09-08 10:39:13 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-09-08 10:39:13 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
signature := v.GetSignature()
|
|
|
|
if signature == nil {
|
|
|
|
h.signature = nil
|
|
|
|
} else {
|
|
|
|
if h.signature == nil {
|
|
|
|
h.signature = new(refs.Signature)
|
|
|
|
}
|
2020-09-08 10:39:13 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = h.signature.FromGRPCMessage(signature)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-09-08 10:39:13 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
header := v.GetHeader()
|
|
|
|
if header == nil {
|
|
|
|
h.header = nil
|
|
|
|
} else {
|
|
|
|
if h.header == nil {
|
|
|
|
h.header = new(Header)
|
|
|
|
}
|
2020-09-08 10:39:13 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = h.header.FromGRPCMessage(header)
|
2020-08-17 17:26:25 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return err
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (o *Object) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.Object
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if o != nil {
|
|
|
|
m = new(object.Object)
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetObjectId(o.objectID.ToGRPCMessage().(*refsGRPC.ObjectID))
|
|
|
|
m.SetSignature(o.idSig.ToGRPCMessage().(*refsGRPC.Signature))
|
|
|
|
m.SetHeader(o.header.ToGRPCMessage().(*object.Header))
|
|
|
|
m.SetPayload(o.payload)
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (o *Object) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.Object)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-17 17:26:25 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
objectID := v.GetObjectId()
|
|
|
|
if objectID == nil {
|
|
|
|
o.objectID = nil
|
|
|
|
} else {
|
|
|
|
if o.objectID == nil {
|
|
|
|
o.objectID = new(refs.ObjectID)
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = o.objectID.FromGRPCMessage(objectID)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
idSig := v.GetSignature()
|
|
|
|
if idSig == nil {
|
|
|
|
o.idSig = nil
|
|
|
|
} else {
|
|
|
|
if o.idSig == nil {
|
|
|
|
o.idSig = new(refs.Signature)
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = o.idSig.FromGRPCMessage(idSig)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-17 17:26:25 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
header := v.GetHeader()
|
|
|
|
if header == nil {
|
|
|
|
o.header = nil
|
|
|
|
} else {
|
|
|
|
if o.header == nil {
|
|
|
|
o.header = new(Header)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = o.header.FromGRPCMessage(header)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-12-02 10:10:43 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
o.payload = v.GetPayload()
|
2020-12-02 10:10:43 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
|
|
|
}
|
2020-12-02 10:10:43 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (s *SplitInfo) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.SplitInfo
|
2020-12-02 10:10:43 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if s != nil {
|
|
|
|
m = new(object.SplitInfo)
|
|
|
|
|
|
|
|
m.SetLastPart(s.lastPart.ToGRPCMessage().(*refsGRPC.ObjectID))
|
|
|
|
m.SetLink(s.link.ToGRPCMessage().(*refsGRPC.ObjectID))
|
|
|
|
m.SetSplitId(s.splitID)
|
|
|
|
}
|
2020-12-02 10:10:43 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (s *SplitInfo) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.SplitInfo)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-12-02 10:10:43 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-12-02 10:10:43 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
lastPart := v.GetLastPart()
|
|
|
|
if lastPart == nil {
|
|
|
|
s.lastPart = nil
|
|
|
|
} else {
|
|
|
|
if s.lastPart == nil {
|
|
|
|
s.lastPart = new(refs.ObjectID)
|
|
|
|
}
|
2020-12-02 10:10:43 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = s.lastPart.FromGRPCMessage(lastPart)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-12-02 10:10:43 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
link := v.GetLink()
|
|
|
|
if link == nil {
|
|
|
|
s.link = nil
|
|
|
|
} else {
|
|
|
|
if s.link == nil {
|
|
|
|
s.link = new(refs.ObjectID)
|
|
|
|
}
|
2020-12-02 10:10:43 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = s.link.FromGRPCMessage(link)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
s.splitID = v.GetSplitId()
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2024-03-19 06:55:23 +00:00
|
|
|
func (s *ECInfo) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.ECInfo
|
|
|
|
|
|
|
|
if s != nil {
|
|
|
|
m = new(object.ECInfo)
|
|
|
|
|
|
|
|
if s.Chunks != nil {
|
2024-08-27 12:12:31 +00:00
|
|
|
chunks := make([]object.ECInfo_Chunk, len(s.Chunks))
|
2024-03-19 06:55:23 +00:00
|
|
|
for i := range chunks {
|
2024-08-27 12:12:31 +00:00
|
|
|
chunks[i] = *s.Chunks[i].ToGRPCMessage().(*object.ECInfo_Chunk)
|
2024-03-19 06:55:23 +00:00
|
|
|
}
|
|
|
|
m.Chunks = chunks
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *ECInfo) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.ECInfo)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
chunks := v.GetChunks()
|
|
|
|
if chunks == nil {
|
|
|
|
s.Chunks = nil
|
|
|
|
} else {
|
|
|
|
s.Chunks = make([]ECChunk, len(chunks))
|
|
|
|
for i := range chunks {
|
2024-08-27 12:12:31 +00:00
|
|
|
if err := s.Chunks[i].FromGRPCMessage(&chunks[i]); err != nil {
|
2024-03-19 06:55:23 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2024-04-22 10:25:29 +00:00
|
|
|
func (c *ECChunk) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.ECInfo_Chunk
|
|
|
|
|
|
|
|
if c != nil {
|
|
|
|
m = new(object.ECInfo_Chunk)
|
|
|
|
|
|
|
|
m.Total = c.Total
|
|
|
|
m.Index = c.Index
|
|
|
|
m.Id = c.ID.ToGRPCMessage().(*refsGRPC.ObjectID)
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *ECChunk) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.ECInfo_Chunk)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := c.ID.FromGRPCMessage(v.GetId()); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
c.Index = v.Index
|
|
|
|
c.Total = v.Total
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetRequestBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.GetRequest_Body
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.GetRequest_Body)
|
|
|
|
|
|
|
|
m.SetAddress(r.addr.ToGRPCMessage().(*refsGRPC.Address))
|
|
|
|
m.SetRaw(r.raw)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetRequestBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.GetRequest_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
addr := v.GetAddress()
|
|
|
|
if addr == nil {
|
|
|
|
r.addr = nil
|
|
|
|
} else {
|
|
|
|
if r.addr == nil {
|
|
|
|
r.addr = new(refs.Address)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.addr.FromGRPCMessage(addr)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
r.raw = v.GetRaw()
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetRequest) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.GetRequest
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.GetRequest)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetBody(r.body.ToGRPCMessage().(*object.GetRequest_Body))
|
|
|
|
r.RequestHeaders.ToMessage(m)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetRequest) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.GetRequest)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-18 10:23:26 +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-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return r.RequestHeaders.FromMessage(v)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetObjectPartInit) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.GetResponse_Body_Init
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.GetResponse_Body_Init)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetObjectId(r.id.ToGRPCMessage().(*refsGRPC.ObjectID))
|
|
|
|
m.SetSignature(r.sig.ToGRPCMessage().(*refsGRPC.Signature))
|
|
|
|
m.SetHeader(r.hdr.ToGRPCMessage().(*object.Header))
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetObjectPartInit) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.GetResponse_Body_Init)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
id := v.GetObjectId()
|
|
|
|
if id == nil {
|
|
|
|
r.id = nil
|
|
|
|
} else {
|
|
|
|
if r.id == nil {
|
|
|
|
r.id = new(refs.ObjectID)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.id.FromGRPCMessage(id)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-18 10:23:26 +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-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.sig.FromGRPCMessage(sig)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
hdr := v.GetHeader()
|
|
|
|
if hdr == nil {
|
|
|
|
r.hdr = nil
|
|
|
|
} else {
|
|
|
|
if r.hdr == nil {
|
|
|
|
r.hdr = new(Header)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.hdr.FromGRPCMessage(hdr)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *GetObjectPartChunk) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.GetResponse_Body_Chunk
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.GetResponse_Body_Chunk)
|
|
|
|
|
|
|
|
m.SetChunk(r.chunk)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetObjectPartChunk) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.GetResponse_Body_Chunk)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
r.chunk = v.GetChunk()
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetResponseBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.GetResponse_Body
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.GetResponse_Body)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
switch v := r.GetObjectPart(); t := v.(type) {
|
|
|
|
case nil:
|
|
|
|
m.ObjectPart = nil
|
|
|
|
case *GetObjectPartInit:
|
|
|
|
m.SetInit(t.ToGRPCMessage().(*object.GetResponse_Body_Init))
|
|
|
|
case *GetObjectPartChunk:
|
|
|
|
m.SetChunk(t.ToGRPCMessage().(*object.GetResponse_Body_Chunk))
|
|
|
|
case *SplitInfo:
|
|
|
|
m.SetSplitInfo(t.ToGRPCMessage().(*object.SplitInfo))
|
2024-04-22 10:25:29 +00:00
|
|
|
case *ECInfo:
|
2024-04-26 08:54:35 +00:00
|
|
|
m.SetEcInfo(t.ToGRPCMessage().(*object.ECInfo))
|
2021-03-12 12:57:23 +00:00
|
|
|
default:
|
|
|
|
panic(fmt.Sprintf("unknown get object part %T", t))
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetResponseBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.GetResponse_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
|
|
|
|
|
|
|
r.objPart = nil
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
switch pt := v.GetObjectPart().(type) {
|
2020-08-18 10:23:26 +00:00
|
|
|
case nil:
|
|
|
|
case *object.GetResponse_Body_Init_:
|
2021-03-12 12:57:23 +00:00
|
|
|
if pt != nil {
|
|
|
|
partInit := new(GetObjectPartInit)
|
|
|
|
r.objPart = partInit
|
|
|
|
err = partInit.FromGRPCMessage(pt.Init)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
case *object.GetResponse_Body_Chunk:
|
2021-03-12 12:57:23 +00:00
|
|
|
if pt != nil {
|
|
|
|
partChunk := new(GetObjectPartChunk)
|
|
|
|
r.objPart = partChunk
|
|
|
|
err = partChunk.FromGRPCMessage(pt)
|
|
|
|
}
|
2020-12-02 10:10:43 +00:00
|
|
|
case *object.GetResponse_Body_SplitInfo:
|
2021-03-12 12:57:23 +00:00
|
|
|
if pt != nil {
|
|
|
|
partSplit := new(SplitInfo)
|
|
|
|
r.objPart = partSplit
|
|
|
|
err = partSplit.FromGRPCMessage(pt.SplitInfo)
|
|
|
|
}
|
2024-04-22 10:25:29 +00:00
|
|
|
case *object.GetResponse_Body_EcInfo:
|
|
|
|
if pt != nil {
|
|
|
|
partEC := new(ECInfo)
|
|
|
|
r.objPart = partEC
|
|
|
|
err = partEC.FromGRPCMessage(pt.EcInfo)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
default:
|
2021-05-17 12:56:17 +00:00
|
|
|
err = fmt.Errorf("unknown get object part %T", pt)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return err
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetResponse) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.GetResponse
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.GetResponse)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetBody(r.body.ToGRPCMessage().(*object.GetResponse_Body))
|
|
|
|
r.ResponseHeaders.ToMessage(m)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetResponse) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.GetResponse)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-18 10:23:26 +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-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return r.ResponseHeaders.FromMessage(v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *PutObjectPartInit) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.PutRequest_Body_Init
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.PutRequest_Body_Init)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetObjectId(r.id.ToGRPCMessage().(*refsGRPC.ObjectID))
|
|
|
|
m.SetSignature(r.sig.ToGRPCMessage().(*refsGRPC.Signature))
|
|
|
|
m.SetHeader(r.hdr.ToGRPCMessage().(*object.Header))
|
|
|
|
m.SetCopiesNumber(r.copyNum)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return m
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *PutObjectPartInit) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.PutRequest_Body_Init)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
id := v.GetObjectId()
|
|
|
|
if id == nil {
|
|
|
|
r.id = nil
|
|
|
|
} else {
|
|
|
|
if r.id == nil {
|
|
|
|
r.id = new(refs.ObjectID)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.id.FromGRPCMessage(id)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-08-18 10:23:26 +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-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.sig.FromGRPCMessage(sig)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
hdr := v.GetHeader()
|
|
|
|
if hdr == nil {
|
|
|
|
r.hdr = nil
|
|
|
|
} else {
|
|
|
|
if r.hdr == nil {
|
|
|
|
r.hdr = new(Header)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.hdr.FromGRPCMessage(hdr)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
r.copyNum = v.GetCopiesNumber()
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *PutObjectPartChunk) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.PutRequest_Body_Chunk
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.PutRequest_Body_Chunk)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetChunk(r.chunk)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *PutObjectPartChunk) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.PutRequest_Body_Chunk)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
r.chunk = v.GetChunk()
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *PutRequestBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.PutRequest_Body
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.PutRequest_Body)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
switch v := r.GetObjectPart(); t := v.(type) {
|
|
|
|
case nil:
|
|
|
|
m.ObjectPart = nil
|
|
|
|
case *PutObjectPartInit:
|
|
|
|
m.SetInit(t.ToGRPCMessage().(*object.PutRequest_Body_Init))
|
|
|
|
case *PutObjectPartChunk:
|
|
|
|
m.SetChunk(t.ToGRPCMessage().(*object.PutRequest_Body_Chunk))
|
|
|
|
default:
|
|
|
|
panic(fmt.Sprintf("unknown put object part %T", t))
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *PutRequestBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.PutRequest_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
|
|
|
|
|
|
|
r.objPart = nil
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
switch pt := v.GetObjectPart().(type) {
|
2020-08-18 10:23:26 +00:00
|
|
|
case nil:
|
|
|
|
case *object.PutRequest_Body_Init_:
|
2021-03-12 12:57:23 +00:00
|
|
|
if pt != nil {
|
|
|
|
partInit := new(PutObjectPartInit)
|
|
|
|
r.objPart = partInit
|
|
|
|
err = partInit.FromGRPCMessage(pt.Init)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
case *object.PutRequest_Body_Chunk:
|
2021-03-12 12:57:23 +00:00
|
|
|
if pt != nil {
|
|
|
|
partChunk := new(PutObjectPartChunk)
|
|
|
|
r.objPart = partChunk
|
|
|
|
err = partChunk.FromGRPCMessage(pt)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
default:
|
2021-05-17 12:56:17 +00:00
|
|
|
err = fmt.Errorf("unknown put object part %T", pt)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return err
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *PutRequest) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.PutRequest
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.PutRequest)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetBody(r.body.ToGRPCMessage().(*object.PutRequest_Body))
|
|
|
|
r.RequestHeaders.ToMessage(m)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *PutRequest) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.PutRequest)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-18 10:23:26 +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-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return r.RequestHeaders.FromMessage(v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *PutResponseBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.PutResponse_Body
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.PutResponse_Body)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetObjectId(r.id.ToGRPCMessage().(*refsGRPC.ObjectID))
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *PutResponseBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.PutResponse_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
id := v.GetObjectId()
|
|
|
|
if id == nil {
|
|
|
|
r.id = nil
|
|
|
|
} else {
|
|
|
|
if r.id == nil {
|
|
|
|
r.id = new(refs.ObjectID)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.id.FromGRPCMessage(id)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *PutResponse) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.PutResponse
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.PutResponse)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetBody(r.body.ToGRPCMessage().(*object.PutResponse_Body))
|
|
|
|
r.ResponseHeaders.ToMessage(m)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *PutResponse) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.PutResponse)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-18 10:23:26 +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-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return r.ResponseHeaders.FromMessage(v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *DeleteRequestBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.DeleteRequest_Body
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.DeleteRequest_Body)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetAddress(r.addr.ToGRPCMessage().(*refsGRPC.Address))
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *DeleteRequestBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.DeleteRequest_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
addr := v.GetAddress()
|
|
|
|
if addr == nil {
|
|
|
|
r.addr = nil
|
|
|
|
} else {
|
|
|
|
if r.addr == nil {
|
|
|
|
r.addr = new(refs.Address)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.addr.FromGRPCMessage(addr)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *DeleteRequest) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.DeleteRequest
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.DeleteRequest)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetBody(r.body.ToGRPCMessage().(*object.DeleteRequest_Body))
|
|
|
|
r.RequestHeaders.ToMessage(m)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *DeleteRequest) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.DeleteRequest)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-18 10:23:26 +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-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return r.RequestHeaders.FromMessage(v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *DeleteResponseBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.DeleteResponse_Body
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.DeleteResponse_Body)
|
|
|
|
|
|
|
|
m.SetTombstone(r.tombstone.ToGRPCMessage().(*refsGRPC.Address))
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *DeleteResponseBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.DeleteResponse_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
tombstone := v.GetTombstone()
|
|
|
|
if tombstone == nil {
|
|
|
|
r.tombstone = nil
|
|
|
|
} else {
|
|
|
|
if r.tombstone == nil {
|
|
|
|
r.tombstone = new(refs.Address)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.tombstone.FromGRPCMessage(tombstone)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return err
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *DeleteResponse) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.DeleteResponse
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.DeleteResponse)
|
|
|
|
|
|
|
|
m.SetBody(r.body.ToGRPCMessage().(*object.DeleteResponse_Body))
|
|
|
|
r.ResponseHeaders.ToMessage(m)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *DeleteResponse) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.DeleteResponse)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-18 10:23:26 +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-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return r.ResponseHeaders.FromMessage(v)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *HeadRequestBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.HeadRequest_Body
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.HeadRequest_Body)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetAddress(r.addr.ToGRPCMessage().(*refsGRPC.Address))
|
|
|
|
m.SetRaw(r.raw)
|
|
|
|
m.SetMainOnly(r.mainOnly)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *HeadRequestBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.HeadRequest_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
addr := v.GetAddress()
|
|
|
|
if addr == nil {
|
|
|
|
r.addr = nil
|
|
|
|
} else {
|
|
|
|
if r.addr == nil {
|
|
|
|
r.addr = new(refs.Address)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.addr.FromGRPCMessage(addr)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
r.raw = v.GetRaw()
|
|
|
|
r.mainOnly = v.GetMainOnly()
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *HeadRequest) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.HeadRequest
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.HeadRequest)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetBody(r.body.ToGRPCMessage().(*object.HeadRequest_Body))
|
|
|
|
r.RequestHeaders.ToMessage(m)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *HeadRequest) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.HeadRequest)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-18 10:23:26 +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(HeadRequestBody)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return r.RequestHeaders.FromMessage(v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *HeadResponseBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.HeadResponse_Body
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.HeadResponse_Body)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
switch v := r.hdrPart.(type) {
|
|
|
|
case nil:
|
|
|
|
m.Head = nil
|
|
|
|
case *HeaderWithSignature:
|
|
|
|
m.SetHeader(v.ToGRPCMessage().(*object.HeaderWithSignature))
|
|
|
|
case *ShortHeader:
|
|
|
|
m.SetShortHeader(v.ToGRPCMessage().(*object.ShortHeader))
|
|
|
|
case *SplitInfo:
|
|
|
|
m.SetSplitInfo(v.ToGRPCMessage().(*object.SplitInfo))
|
2024-04-22 10:25:29 +00:00
|
|
|
case *ECInfo:
|
2024-04-26 08:54:35 +00:00
|
|
|
m.SetEcInfo(v.ToGRPCMessage().(*object.ECInfo))
|
2021-03-12 12:57:23 +00:00
|
|
|
default:
|
|
|
|
panic(fmt.Sprintf("unknown head part %T", v))
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *HeadResponseBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.HeadResponse_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
r.hdrPart = nil
|
|
|
|
|
|
|
|
switch pt := v.GetHead().(type) {
|
2020-08-18 10:23:26 +00:00
|
|
|
case nil:
|
|
|
|
case *object.HeadResponse_Body_Header:
|
2021-03-12 12:57:23 +00:00
|
|
|
if pt != nil {
|
|
|
|
partHdr := new(HeaderWithSignature)
|
|
|
|
r.hdrPart = partHdr
|
|
|
|
err = partHdr.FromGRPCMessage(pt.Header)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
case *object.HeadResponse_Body_ShortHeader:
|
2021-03-12 12:57:23 +00:00
|
|
|
if pt != nil {
|
|
|
|
partShort := new(ShortHeader)
|
|
|
|
r.hdrPart = partShort
|
|
|
|
err = partShort.FromGRPCMessage(pt.ShortHeader)
|
|
|
|
}
|
2020-12-07 15:59:01 +00:00
|
|
|
case *object.HeadResponse_Body_SplitInfo:
|
2021-03-12 12:57:23 +00:00
|
|
|
if pt != nil {
|
|
|
|
partSplit := new(SplitInfo)
|
|
|
|
r.hdrPart = partSplit
|
|
|
|
err = partSplit.FromGRPCMessage(pt.SplitInfo)
|
|
|
|
}
|
2024-04-22 10:25:29 +00:00
|
|
|
case *object.HeadResponse_Body_EcInfo:
|
|
|
|
if pt != nil {
|
|
|
|
partEC := new(ECInfo)
|
|
|
|
r.hdrPart = partEC
|
|
|
|
err = partEC.FromGRPCMessage(pt.EcInfo)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
default:
|
2021-05-17 12:56:17 +00:00
|
|
|
err = fmt.Errorf("unknown head part %T", pt)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return err
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *HeadResponse) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.HeadResponse
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.HeadResponse)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetBody(r.body.ToGRPCMessage().(*object.HeadResponse_Body))
|
|
|
|
r.ResponseHeaders.ToMessage(m)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *HeadResponse) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.HeadResponse)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-18 10:23:26 +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(HeadResponseBody)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return r.ResponseHeaders.FromMessage(v)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (f *SearchFilter) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.SearchRequest_Body_Filter
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if f != nil {
|
|
|
|
m = new(object.SearchRequest_Body_Filter)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetKey(f.key)
|
|
|
|
m.SetValue(f.val)
|
|
|
|
m.SetMatchType(MatchTypeToGRPCField(f.matchType))
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (f *SearchFilter) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.SearchRequest_Body_Filter)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
f.key = v.GetKey()
|
|
|
|
f.val = v.GetValue()
|
|
|
|
f.matchType = MatchTypeFromGRPCField(v.GetMatchType())
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2024-08-27 12:12:31 +00:00
|
|
|
func SearchFiltersToGRPC(fs []SearchFilter) (res []object.SearchRequest_Body_Filter) {
|
2021-03-12 12:57:23 +00:00
|
|
|
if fs != nil {
|
2024-08-27 12:12:31 +00:00
|
|
|
res = make([]object.SearchRequest_Body_Filter, 0, len(fs))
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
for i := range fs {
|
2024-08-27 12:12:31 +00:00
|
|
|
res = append(res, *fs[i].ToGRPCMessage().(*object.SearchRequest_Body_Filter))
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2024-08-27 12:12:31 +00:00
|
|
|
func SearchFiltersFromGRPC(fs []object.SearchRequest_Body_Filter) (res []SearchFilter, err error) {
|
2021-03-12 12:57:23 +00:00
|
|
|
if fs != nil {
|
2022-03-02 08:03:56 +00:00
|
|
|
res = make([]SearchFilter, len(fs))
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
for i := range fs {
|
2024-08-27 12:12:31 +00:00
|
|
|
err = res[i].FromGRPCMessage(&fs[i])
|
|
|
|
if err != nil {
|
|
|
|
return
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *SearchRequestBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.SearchRequest_Body
|
|
|
|
|
|
|
|
if r != nil {
|
|
|
|
m = new(object.SearchRequest_Body)
|
|
|
|
|
|
|
|
m.SetContainerId(r.cid.ToGRPCMessage().(*refsGRPC.ContainerID))
|
|
|
|
m.SetFilters(SearchFiltersToGRPC(r.filters))
|
|
|
|
m.SetVersion(r.version)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *SearchRequestBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.SearchRequest_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-18 10:23:26 +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-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.cid.FromGRPCMessage(cid)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
r.filters, err = SearchFiltersFromGRPC(v.GetFilters())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
r.version = v.GetVersion()
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *SearchRequest) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.SearchRequest
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.SearchRequest)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetBody(r.body.ToGRPCMessage().(*object.SearchRequest_Body))
|
|
|
|
r.RequestHeaders.ToMessage(m)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *SearchRequest) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.SearchRequest)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-18 10:23:26 +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(SearchRequestBody)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return r.RequestHeaders.FromMessage(v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *SearchResponseBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.SearchResponse_Body
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.SearchResponse_Body)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetIdList(refs.ObjectIDListToGRPCMessage(r.idList))
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *SearchResponseBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.SearchResponse_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
r.idList, err = refs.ObjectIDListFromGRPCMessage(v.GetIdList())
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return err
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *SearchResponse) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.SearchResponse
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.SearchResponse)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetBody(r.body.ToGRPCMessage().(*object.SearchResponse_Body))
|
|
|
|
r.ResponseHeaders.ToMessage(m)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *SearchResponse) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.SearchResponse)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-18 10:23:26 +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(SearchResponseBody)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return r.ResponseHeaders.FromMessage(v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *Range) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.Range
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.Range)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetLength(r.len)
|
|
|
|
m.SetOffset(r.off)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *Range) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.Range)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
r.len = v.GetLength()
|
|
|
|
r.off = v.GetOffset()
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2024-08-27 12:12:31 +00:00
|
|
|
func RangesToGRPC(rs []Range) (res []object.Range) {
|
2021-03-12 12:57:23 +00:00
|
|
|
if rs != nil {
|
2024-08-27 12:12:31 +00:00
|
|
|
res = make([]object.Range, 0, len(rs))
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
for i := range rs {
|
2024-08-27 12:12:31 +00:00
|
|
|
res = append(res, *rs[i].ToGRPCMessage().(*object.Range))
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2024-08-27 12:12:31 +00:00
|
|
|
func RangesFromGRPC(rs []object.Range) (res []Range, err error) {
|
2021-03-12 12:57:23 +00:00
|
|
|
if rs != nil {
|
2022-03-02 08:03:56 +00:00
|
|
|
res = make([]Range, len(rs))
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
for i := range rs {
|
2024-08-27 12:12:31 +00:00
|
|
|
err = res[i].FromGRPCMessage(&rs[i])
|
|
|
|
if err != nil {
|
|
|
|
return
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetRangeRequestBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.GetRangeRequest_Body
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.GetRangeRequest_Body)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetAddress(r.addr.ToGRPCMessage().(*refsGRPC.Address))
|
|
|
|
m.SetRange(r.rng.ToGRPCMessage().(*object.Range))
|
|
|
|
m.SetRaw(r.raw)
|
|
|
|
}
|
2020-12-07 15:59:01 +00:00
|
|
|
|
2020-08-18 10:23:26 +00:00
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetRangeRequestBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.GetRangeRequest_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
addr := v.GetAddress()
|
|
|
|
if addr == nil {
|
|
|
|
r.addr = nil
|
|
|
|
} else {
|
|
|
|
if r.addr == nil {
|
|
|
|
r.addr = new(refs.Address)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.addr.FromGRPCMessage(addr)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
rng := v.GetRange()
|
|
|
|
if rng == nil {
|
|
|
|
r.rng = nil
|
|
|
|
} else {
|
|
|
|
if r.rng == nil {
|
|
|
|
r.rng = new(Range)
|
|
|
|
}
|
2020-12-07 15:59:01 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.rng.FromGRPCMessage(rng)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
r.raw = v.GetRaw()
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *GetRangeRequest) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.GetRangeRequest
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.GetRangeRequest)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetBody(r.body.ToGRPCMessage().(*object.GetRangeRequest_Body))
|
|
|
|
r.RequestHeaders.ToMessage(m)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetRangeRequest) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.GetRangeRequest)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-18 10:23:26 +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(GetRangeRequestBody)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return r.RequestHeaders.FromMessage(v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetRangePartChunk) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.GetRangeResponse_Body_Chunk
|
2020-12-07 15:59:01 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.GetRangeResponse_Body_Chunk)
|
2020-12-07 15:59:01 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetChunk(r.chunk)
|
|
|
|
}
|
2020-12-07 15:59:01 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetRangePartChunk) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.GetRangeResponse_Body_Chunk)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-12-07 15:59:01 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
r.chunk = v.GetChunk()
|
2020-12-07 15:59:01 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
2020-12-07 15:59:01 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetRangeResponseBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.GetRangeResponse_Body
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.GetRangeResponse_Body)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
switch v := r.rngPart.(type) {
|
|
|
|
case nil:
|
|
|
|
m.RangePart = nil
|
|
|
|
case *GetRangePartChunk:
|
|
|
|
m.SetChunk(v.ToGRPCMessage().(*object.GetRangeResponse_Body_Chunk))
|
|
|
|
case *SplitInfo:
|
|
|
|
m.SetSplitInfo(v.ToGRPCMessage().(*object.SplitInfo))
|
2024-04-27 20:03:26 +00:00
|
|
|
case *ECInfo:
|
2024-04-26 08:54:35 +00:00
|
|
|
m.SetEcInfo(v.ToGRPCMessage().(*object.ECInfo))
|
2021-03-12 12:57:23 +00:00
|
|
|
default:
|
|
|
|
panic(fmt.Sprintf("unknown get range part %T", v))
|
|
|
|
}
|
2020-12-07 15:59:01 +00:00
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetRangeResponseBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.GetRangeResponse_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
r.rngPart = nil
|
|
|
|
|
|
|
|
switch pt := v.GetRangePart().(type) {
|
2020-12-07 15:59:01 +00:00
|
|
|
case nil:
|
|
|
|
case *object.GetRangeResponse_Body_Chunk:
|
2021-03-12 12:57:23 +00:00
|
|
|
if pt != nil {
|
|
|
|
partChunk := new(GetRangePartChunk)
|
|
|
|
r.rngPart = partChunk
|
|
|
|
err = partChunk.FromGRPCMessage(pt)
|
|
|
|
}
|
2020-12-07 15:59:01 +00:00
|
|
|
case *object.GetRangeResponse_Body_SplitInfo:
|
2021-03-12 12:57:23 +00:00
|
|
|
if pt != nil {
|
|
|
|
partSplit := new(SplitInfo)
|
|
|
|
r.rngPart = partSplit
|
2022-05-30 18:15:50 +00:00
|
|
|
err = partSplit.FromGRPCMessage(pt.SplitInfo)
|
2021-03-12 12:57:23 +00:00
|
|
|
}
|
2024-04-27 20:03:26 +00:00
|
|
|
case *object.GetRangeResponse_Body_EcInfo:
|
|
|
|
if pt != nil {
|
|
|
|
partEC := new(ECInfo)
|
|
|
|
r.rngPart = partEC
|
|
|
|
err = partEC.FromGRPCMessage(pt.EcInfo)
|
|
|
|
}
|
2020-12-07 15:59:01 +00:00
|
|
|
default:
|
2021-05-17 12:56:17 +00:00
|
|
|
err = fmt.Errorf("unknown get range part %T", pt)
|
2020-12-07 15:59:01 +00:00
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return err
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetRangeResponse) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.GetRangeResponse
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.GetRangeResponse)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetBody(r.body.ToGRPCMessage().(*object.GetRangeResponse_Body))
|
|
|
|
r.ResponseHeaders.ToMessage(m)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetRangeResponse) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.GetRangeResponse)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-18 10:23:26 +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(GetRangeResponseBody)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return r.ResponseHeaders.FromMessage(v)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetRangeHashRequestBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.GetRangeHashRequest_Body
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.GetRangeHashRequest_Body)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetAddress(r.addr.ToGRPCMessage().(*refsGRPC.Address))
|
|
|
|
m.SetRanges(RangesToGRPC(r.rngs))
|
|
|
|
m.SetType(refs.ChecksumTypeToGRPC(r.typ))
|
|
|
|
m.SetSalt(r.salt)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetRangeHashRequestBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.GetRangeHashRequest_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
addr := v.GetAddress()
|
|
|
|
if addr == nil {
|
|
|
|
r.addr = nil
|
|
|
|
} else {
|
|
|
|
if r.addr == nil {
|
|
|
|
r.addr = new(refs.Address)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.addr.FromGRPCMessage(addr)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
r.rngs, err = RangesFromGRPC(v.GetRanges())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
r.typ = refs.ChecksumTypeFromGRPC(v.GetType())
|
|
|
|
r.salt = v.GetSalt()
|
2020-08-20 08:48:35 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetRangeHashRequest) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.GetRangeHashRequest
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.GetRangeHashRequest)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetBody(r.body.ToGRPCMessage().(*object.GetRangeHashRequest_Body))
|
|
|
|
r.RequestHeaders.ToMessage(m)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetRangeHashRequest) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.GetRangeHashRequest)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-18 10:23:26 +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(GetRangeHashRequestBody)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return r.RequestHeaders.FromMessage(v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetRangeHashResponseBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.GetRangeHashResponse_Body
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.GetRangeHashResponse_Body)
|
2020-08-20 08:48:35 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetType(refs.ChecksumTypeToGRPC(r.typ))
|
|
|
|
m.SetHashList(r.hashList)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetRangeHashResponseBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.GetRangeHashResponse_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
r.typ = refs.ChecksumTypeFromGRPC(v.GetType())
|
|
|
|
r.hashList = v.GetHashList()
|
2020-08-20 08:48:35 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return nil
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetRangeHashResponse) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.GetRangeHashResponse
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
if r != nil {
|
|
|
|
m = new(object.GetRangeHashResponse)
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
m.SetBody(r.body.ToGRPCMessage().(*object.GetRangeHashResponse_Body))
|
|
|
|
r.ResponseHeaders.ToMessage(m)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (r *GetRangeHashResponse) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.GetRangeHashResponse)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
var err error
|
2020-08-18 10:23:26 +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(GetRangeHashResponseBody)
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
err = r.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-08-18 10:23:26 +00:00
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
return r.ResponseHeaders.FromMessage(v)
|
2020-08-18 10:23:26 +00:00
|
|
|
}
|
2023-06-30 12:00:51 +00:00
|
|
|
|
|
|
|
func (r *PutSingleRequestBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.PutSingleRequest_Body
|
|
|
|
|
|
|
|
if r != nil {
|
|
|
|
m = new(object.PutSingleRequest_Body)
|
|
|
|
m.SetObject(r.GetObject().ToGRPCMessage().(*object.Object))
|
|
|
|
m.SetCopiesNumber(r.GetCopiesNumber())
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *PutSingleRequestBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.PutSingleRequest_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
if v.GetObject() == nil {
|
|
|
|
r.object = nil
|
|
|
|
} else {
|
|
|
|
if r.object == nil {
|
|
|
|
r.object = new(Object)
|
|
|
|
}
|
|
|
|
|
|
|
|
err := r.object.FromGRPCMessage(v.GetObject())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
r.copyNum = v.GetCopiesNumber()
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *PutSingleRequest) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.PutSingleRequest
|
|
|
|
|
|
|
|
if r != nil {
|
|
|
|
m = new(object.PutSingleRequest)
|
|
|
|
|
|
|
|
m.SetBody(r.body.ToGRPCMessage().(*object.PutSingleRequest_Body))
|
|
|
|
r.RequestHeaders.ToMessage(m)
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *PutSingleRequest) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.PutSingleRequest)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
body := v.GetBody()
|
|
|
|
if body == nil {
|
|
|
|
r.body = nil
|
|
|
|
} else {
|
|
|
|
if r.body == nil {
|
|
|
|
r.body = new(PutSingleRequestBody)
|
|
|
|
}
|
|
|
|
|
|
|
|
err := r.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return r.RequestHeaders.FromMessage(v)
|
|
|
|
}
|
2023-06-30 13:05:37 +00:00
|
|
|
|
|
|
|
func (r *PutSingleResponseBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var b *object.PutSingleResponse_Body
|
|
|
|
if r != nil {
|
|
|
|
b = new(object.PutSingleResponse_Body)
|
|
|
|
}
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *PutSingleResponseBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.PutSingleResponse_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *PutSingleResponse) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.PutSingleResponse
|
|
|
|
|
|
|
|
if r != nil {
|
|
|
|
m = new(object.PutSingleResponse)
|
|
|
|
|
|
|
|
m.SetBody(r.body.ToGRPCMessage().(*object.PutSingleResponse_Body))
|
|
|
|
r.ResponseHeaders.ToMessage(m)
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *PutSingleResponse) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.PutSingleResponse)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
body := v.GetBody()
|
|
|
|
if body == nil {
|
|
|
|
r.body = nil
|
|
|
|
} else {
|
|
|
|
if r.body == nil {
|
|
|
|
r.body = new(PutSingleResponseBody)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = r.body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return r.ResponseHeaders.FromMessage(v)
|
|
|
|
}
|
2024-07-24 14:40:47 +00:00
|
|
|
|
|
|
|
func (r *PatchRequestBodyPatch) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.PatchRequest_Body_Patch
|
|
|
|
|
|
|
|
if r != nil {
|
|
|
|
m = new(object.PatchRequest_Body_Patch)
|
|
|
|
|
2024-08-13 15:50:51 +00:00
|
|
|
m.SetSourceRange(r.GetRange().ToGRPCMessage().(*object.Range))
|
|
|
|
m.SetChunk(r.GetChunk())
|
2024-07-24 14:40:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *PatchRequestBodyPatch) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.PatchRequest_Body_Patch)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
srcRange := v.GetSourceRange()
|
|
|
|
if srcRange == nil {
|
|
|
|
r.Range = nil
|
|
|
|
} else {
|
|
|
|
if r.Range == nil {
|
|
|
|
r.Range = new(Range)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = r.Range.FromGRPCMessage(srcRange)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
r.Chunk = v.GetChunk()
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *PatchRequestBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.PatchRequest_Body
|
|
|
|
|
|
|
|
if r != nil {
|
|
|
|
m = new(object.PatchRequest_Body)
|
|
|
|
|
2024-07-30 14:49:45 +00:00
|
|
|
m.SetAddress(r.address.ToGRPCMessage().(*refsGRPC.Address))
|
|
|
|
m.SetNewAttributes(AttributesToGRPC(r.newAttributes))
|
|
|
|
m.SetReplaceAttributes(r.replaceAttributes)
|
|
|
|
m.SetPatch(r.patch.ToGRPCMessage().(*object.PatchRequest_Body_Patch))
|
2024-07-24 14:40:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *PatchRequestBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.PatchRequest_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
addr := v.GetAddress()
|
|
|
|
if addr == nil {
|
2024-07-30 14:49:45 +00:00
|
|
|
r.address = nil
|
2024-07-24 14:40:47 +00:00
|
|
|
} else {
|
2024-07-30 14:49:45 +00:00
|
|
|
if r.address == nil {
|
|
|
|
r.address = new(refs.Address)
|
2024-07-24 14:40:47 +00:00
|
|
|
}
|
|
|
|
|
2024-07-30 14:49:45 +00:00
|
|
|
err = r.address.FromGRPCMessage(addr)
|
2024-07-24 14:40:47 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-30 14:49:45 +00:00
|
|
|
r.newAttributes, err = AttributesFromGRPC(v.GetNewAttributes())
|
2024-07-24 14:40:47 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2024-07-30 14:49:45 +00:00
|
|
|
r.replaceAttributes = v.GetReplaceAttributes()
|
2024-07-24 14:40:47 +00:00
|
|
|
|
|
|
|
patch := v.GetPatch()
|
|
|
|
if patch == nil {
|
2024-07-30 14:49:45 +00:00
|
|
|
r.patch = nil
|
2024-07-24 14:40:47 +00:00
|
|
|
} else {
|
2024-07-30 14:49:45 +00:00
|
|
|
if r.patch == nil {
|
|
|
|
r.patch = new(PatchRequestBodyPatch)
|
2024-07-24 14:40:47 +00:00
|
|
|
}
|
|
|
|
|
2024-07-30 14:49:45 +00:00
|
|
|
err = r.patch.FromGRPCMessage(patch)
|
2024-07-24 14:40:47 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *PatchRequest) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.PatchRequest
|
|
|
|
|
|
|
|
if r != nil {
|
|
|
|
m = new(object.PatchRequest)
|
|
|
|
|
2024-07-30 14:49:45 +00:00
|
|
|
m.SetBody(r.body.ToGRPCMessage().(*object.PatchRequest_Body))
|
2024-07-24 14:40:47 +00:00
|
|
|
r.RequestHeaders.ToMessage(m)
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *PatchRequest) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.PatchRequest)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
body := v.GetBody()
|
|
|
|
if body == nil {
|
2024-07-30 14:49:45 +00:00
|
|
|
r.body = nil
|
2024-07-24 14:40:47 +00:00
|
|
|
} else {
|
2024-07-30 14:49:45 +00:00
|
|
|
if r.body == nil {
|
|
|
|
r.body = new(PatchRequestBody)
|
2024-07-24 14:40:47 +00:00
|
|
|
}
|
|
|
|
|
2024-07-30 14:49:45 +00:00
|
|
|
err = r.body.FromGRPCMessage(body)
|
2024-07-24 14:40:47 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return r.RequestHeaders.FromMessage(v)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *PatchResponseBody) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.PatchResponse_Body
|
|
|
|
|
|
|
|
if r != nil {
|
|
|
|
m = new(object.PatchResponse_Body)
|
|
|
|
|
2024-04-25 12:13:10 +00:00
|
|
|
m.SetObjectId(r.ObjectID.ToGRPCMessage().(*refsGRPC.ObjectID))
|
2024-07-24 14:40:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *PatchResponseBody) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.PatchResponse_Body)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
objID := v.GetObjectId()
|
|
|
|
if objID == nil {
|
|
|
|
r.ObjectID = nil
|
|
|
|
} else {
|
|
|
|
if r.ObjectID == nil {
|
|
|
|
r.ObjectID = new(refs.ObjectID)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = r.ObjectID.FromGRPCMessage(objID)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *PatchResponse) ToGRPCMessage() grpc.Message {
|
|
|
|
var m *object.PatchResponse
|
|
|
|
|
|
|
|
if r != nil {
|
|
|
|
m = new(object.PatchResponse)
|
|
|
|
|
|
|
|
m.SetBody(r.Body.ToGRPCMessage().(*object.PatchResponse_Body))
|
|
|
|
r.ResponseHeaders.ToMessage(m)
|
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *PatchResponse) FromGRPCMessage(m grpc.Message) error {
|
|
|
|
v, ok := m.(*object.PatchResponse)
|
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
body := v.GetBody()
|
|
|
|
if body == nil {
|
|
|
|
r.Body = nil
|
|
|
|
} else {
|
|
|
|
if r.Body == nil {
|
|
|
|
r.Body = new(PatchResponseBody)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = r.Body.FromGRPCMessage(body)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return r.ResponseHeaders.FromMessage(v)
|
|
|
|
}
|