frostfs-sdk-go/api/tree/convert.go
Nikita Zinkevich 0352b5b191
[#185] Implement rpc/client for tree service
Signed-off-by: Nikita Zinkevich <n.zinkevich@yadro.com>
2024-11-29 15:23:14 +03:00

1591 lines
29 KiB
Go

package tree
import (
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/grpc"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/message"
tree "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/pool/tree/service"
)
func metaToGRPC(m []*KeyValue) (res []*tree.KeyValue) {
if m != nil {
res = make([]*tree.KeyValue, 0, len(m))
for i := range m {
res = append(res, m[i].ToGRPCMessage().(*tree.KeyValue))
}
}
return
}
func metaFromGRPC(m []*tree.KeyValue) (res []*KeyValue, err error) {
if m != nil {
res = make([]*KeyValue, len(m))
for i := range m {
res[i] = new(KeyValue)
err = res[i].FromGRPCMessage(m[i])
if err != nil {
return
}
}
}
return
}
func (r *AddResponse) ToGRPCMessage() grpc.Message {
var m *tree.AddResponse
if r != nil {
m = new(tree.AddResponse)
m.Body = r.body.ToGRPCMessage().(*tree.AddResponse_Body)
m.SetSignature(r.signature.ToGRPCMessage().(*tree.Signature))
}
return m
}
func (r *AddResponse) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.AddResponse)
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(AddResponseBody)
}
err = r.body.FromGRPCMessage(body)
}
return err
}
func (r *AddResponseBody) ToGRPCMessage() grpc.Message {
var m *tree.AddResponse_Body
if r != nil {
m = new(tree.AddResponse_Body)
m.NodeId = r.nodeID
}
return m
}
func (r *AddResponseBody) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.AddResponse_Body)
if !ok {
return message.NewUnexpectedMessageType(m, v)
}
r.nodeID = v.GetNodeId()
return nil
}
func (r *AddByPathRequest) ToGRPCMessage() grpc.Message {
var m *tree.AddByPathRequest
if r != nil {
m = new(tree.AddByPathRequest)
m.Body = r.body.ToGRPCMessage().(*tree.AddByPathRequest_Body)
m.SetSignature(r.signature.ToGRPCMessage().(*tree.Signature))
}
return m
}
func (r *AddByPathRequest) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.AddByPathRequest)
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(AddByPathRequestBody)
}
err = r.body.FromGRPCMessage(body)
if err != nil {
return err
}
}
sig := v.GetSignature()
if sig == nil {
r.signature = nil
} else {
if r.signature == nil {
r.signature = new(Signature)
}
err = r.signature.FromGRPCMessage(sig)
}
return err
}
func (r *AddByPathRequestBody) ToGRPCMessage() grpc.Message {
var m *tree.AddByPathRequest_Body
if r != nil {
m = new(tree.AddByPathRequest_Body)
m.ContainerId = r.containerID
m.Path = r.path
m.BearerToken = r.bearerToken
m.PathAttribute = r.pathAttribute
m.TreeId = r.treeID
m.Meta = metaToGRPC(r.meta)
}
return m
}
func (r *AddByPathRequestBody) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.AddByPathRequest_Body)
if !ok {
return message.NewUnexpectedMessageType(m, v)
}
var err error
meta := v.GetMeta()
if meta == nil {
r.meta = nil
} else {
r.meta, err = metaFromGRPC(meta)
if err != nil {
return err
}
}
r.containerID = v.GetContainerId()
r.bearerToken = v.GetBearerToken()
r.path = v.GetPath()
r.pathAttribute = v.GetPathAttribute()
r.treeID = v.GetTreeId()
return err
}
func (r *MoveResponse) ToGRPCMessage() grpc.Message {
var m *tree.MoveResponse
if r != nil {
m = new(tree.MoveResponse)
m.Body = r.body.ToGRPCMessage().(*tree.MoveResponse_Body)
m.SetSignature(r.signature.ToGRPCMessage().(*tree.Signature))
}
return m
}
func (r *MoveResponse) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.MoveResponse)
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(MoveResponseBody)
}
err = r.body.FromGRPCMessage(body)
}
return err
}
func (r *MoveResponseBody) ToGRPCMessage() grpc.Message {
return new(tree.MoveResponse_Body)
}
func (r *MoveResponseBody) FromGRPCMessage(grpc.Message) error {
return nil
}
func (r *MoveRequest) ToGRPCMessage() grpc.Message {
var m *tree.MoveRequest
if r != nil {
m = new(tree.MoveRequest)
m.Body = r.body.ToGRPCMessage().(*tree.MoveRequest_Body)
m.SetSignature(r.signature.ToGRPCMessage().(*tree.Signature))
}
return m
}
func (r *MoveRequest) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.MoveRequest)
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(MoveRequestBody)
}
err = r.body.FromGRPCMessage(body)
if err != nil {
return err
}
}
sig := v.GetSignature()
if sig == nil {
r.signature = nil
} else {
if r.signature == nil {
r.signature = new(Signature)
}
err = r.signature.FromGRPCMessage(sig)
if err != nil {
return err
}
}
return nil
}
func (r *MoveRequestBody) ToGRPCMessage() grpc.Message {
var m *tree.MoveRequest_Body
if r != nil {
m = new(tree.MoveRequest_Body)
m.ContainerId = r.containerID
m.Meta = metaToGRPC(r.meta)
m.TreeId = r.treeID
m.ParentId = r.parentID
m.BearerToken = r.bearerToken
m.NodeId = r.nodeID
}
return m
}
func (r *MoveRequestBody) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.MoveRequest_Body)
if !ok {
return message.NewUnexpectedMessageType(m, v)
}
var err error
r.meta, err = metaFromGRPC(v.GetMeta())
if err != nil {
return err
}
r.treeID = v.GetTreeId()
r.nodeID = v.GetNodeId()
r.containerID = v.GetContainerId()
r.parentID = v.GetParentId()
r.bearerToken = v.GetBearerToken()
return nil
}
func (r *RemoveRequest) ToGRPCMessage() grpc.Message {
var m *tree.RemoveRequest
if r != nil {
m = new(tree.RemoveRequest)
m.Body = r.body.ToGRPCMessage().(*tree.RemoveRequest_Body)
m.SetSignature(r.signature.ToGRPCMessage().(*tree.Signature))
}
return m
}
func (r *RemoveRequest) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.RemoveRequest)
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(RemoveRequestBody)
}
err = r.body.FromGRPCMessage(body)
}
return err
}
func (r *RemoveRequestBody) ToGRPCMessage() grpc.Message {
var m *tree.RemoveRequest_Body
if r != nil {
m = new(tree.RemoveRequest_Body)
m.NodeId = r.nodeID
m.TreeId = r.treeID
m.BearerToken = r.bearerToken
m.ContainerId = r.containerID
}
return m
}
func (r *RemoveRequestBody) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.RemoveRequest_Body)
if !ok {
return message.NewUnexpectedMessageType(m, v)
}
r.nodeID = v.GetNodeId()
r.treeID = v.GetTreeId()
r.containerID = v.GetContainerId()
r.bearerToken = v.GetBearerToken()
return nil
}
func (r *AddByPathResponse) ToGRPCMessage() grpc.Message {
var m *tree.AddByPathResponse
if r != nil {
m = new(tree.AddByPathResponse)
m.Body = r.body.ToGRPCMessage().(*tree.AddByPathResponse_Body)
m.SetSignature(r.signature.ToGRPCMessage().(*tree.Signature))
}
return m
}
func (r *AddByPathResponse) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.AddByPathResponse)
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(AddByPathResponseBody)
}
err = r.body.FromGRPCMessage(body)
}
return err
}
func (r *AddByPathResponseBody) ToGRPCMessage() grpc.Message {
var m *tree.AddByPathResponse_Body
if r != nil {
m = new(tree.AddByPathResponse_Body)
m.ParentId = r.parentID
m.Nodes = r.nodes
}
return m
}
func (r *AddByPathResponseBody) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.AddByPathResponse_Body)
if !ok {
return message.NewUnexpectedMessageType(m, v)
}
r.nodes = v.GetNodes()
r.parentID = v.GetParentId()
return nil
}
func (r *AddRequest) ToGRPCMessage() grpc.Message {
var m *tree.AddRequest
if r != nil {
m = new(tree.AddRequest)
m.Body = r.body.ToGRPCMessage().(*tree.AddRequest_Body)
m.SetSignature(r.signature.ToGRPCMessage().(*tree.Signature))
}
return m
}
func (r *AddRequest) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.AddRequest)
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(AddRequestBody)
}
err = r.body.FromGRPCMessage(body)
}
sig := v.GetSignature()
if sig == nil {
r.signature = nil
} else {
if r.signature == nil {
r.signature = new(Signature)
}
err = r.signature.FromGRPCMessage(sig)
}
return err
}
func (r *AddRequestBody) ToGRPCMessage() grpc.Message {
var m *tree.AddRequest_Body
if r != nil {
m = new(tree.AddRequest_Body)
m.Meta = metaToGRPC(r.meta)
m.TreeId = r.treeID
m.ParentId = r.parentID
m.ContainerId = r.containerID
m.BearerToken = r.bearerToken
}
return m
}
func (r *AddRequestBody) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.AddRequest_Body)
if !ok {
return message.NewUnexpectedMessageType(m, v)
}
var err error
r.meta, err = metaFromGRPC(v.GetMeta())
if err != nil {
return err
}
r.bearerToken = v.GetBearerToken()
r.treeID = v.GetTreeId()
r.containerID = v.GetContainerId()
r.parentID = v.GetParentId()
return err
}
func (r *RemoveResponse) ToGRPCMessage() grpc.Message {
var m *tree.RemoveResponse
if r != nil {
m = new(tree.RemoveResponse)
m.Body = r.body.ToGRPCMessage().(*tree.RemoveResponse_Body)
}
return m
}
func (r *RemoveResponse) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.RemoveResponse)
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(RemoveResponseBody)
}
err = r.body.FromGRPCMessage(body)
}
sig := v.GetSignature()
if sig == nil {
r.signature = nil
} else {
if r.signature == nil {
r.signature = new(Signature)
}
err = r.signature.FromGRPCMessage(sig)
}
return err
}
func (r *RemoveResponseBody) ToGRPCMessage() grpc.Message {
return new(tree.RemoveResponse_Body)
}
func (r *RemoveResponseBody) FromGRPCMessage(grpc.Message) error {
return nil
}
func (r *GetNodeByPathRequest) ToGRPCMessage() grpc.Message {
var m *tree.GetNodeByPathRequest
if r != nil {
m = new(tree.GetNodeByPathRequest)
m.Body = r.body.ToGRPCMessage().(*tree.GetNodeByPathRequest_Body)
m.Signature = r.signature.ToGRPCMessage().(*tree.Signature)
}
return m
}
func (r *GetNodeByPathRequest) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.GetNodeByPathRequest)
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(GetNodeByPathRequestBody)
}
err = r.body.FromGRPCMessage(body)
}
return err
}
func (r *GetNodeByPathRequestBody) ToGRPCMessage() grpc.Message {
var m *tree.GetNodeByPathRequest_Body
if r != nil {
m = new(tree.GetNodeByPathRequest_Body)
m.TreeId = r.treeID
m.Path = r.path
m.BearerToken = r.bearerToken
m.ContainerId = r.containerID
m.Attributes = r.attributes
m.PathAttribute = r.pathAttribute
m.AllAttributes = r.allAttributes
m.LatestOnly = r.latestOnly
}
return m
}
func (r *GetNodeByPathRequestBody) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.GetNodeByPathRequest_Body)
if !ok {
return message.NewUnexpectedMessageType(m, v)
}
r.treeID = v.GetTreeId()
r.path = v.GetPath()
r.attributes = v.GetAttributes()
r.latestOnly = v.GetLatestOnly()
r.allAttributes = v.GetAllAttributes()
r.pathAttribute = v.GetPathAttribute()
r.containerID = v.GetContainerId()
r.bearerToken = v.GetBearerToken()
return nil
}
func (r *GetNodeByPathResponse) ToGRPCMessage() grpc.Message {
var m *tree.GetNodeByPathResponse
if r != nil {
m = new(tree.GetNodeByPathResponse)
m.Body = r.body.ToGRPCMessage().(*tree.GetNodeByPathResponse_Body)
m.SetSignature(r.signature.ToGRPCMessage().(*tree.Signature))
}
return m
}
func (r *GetNodeByPathResponse) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.GetNodeByPathResponse)
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(GetNodeByPathResponseBody)
}
err = r.body.FromGRPCMessage(body)
if err != nil {
return err
}
}
sig := v.GetSignature()
if sig == nil {
r.signature = nil
} else {
if r.signature == nil {
r.signature = new(Signature)
}
err = r.signature.FromGRPCMessage(sig)
}
return err
}
func (r *GetNodeByPathResponseBody) ToGRPCMessage() grpc.Message {
var m *tree.GetNodeByPathResponse_Body
if r != nil {
m = new(tree.GetNodeByPathResponse_Body)
m.Nodes = GetNodeByPathInfoToGRPC(r.nodes)
}
return m
}
func (r *GetNodeByPathResponseBody) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.GetNodeByPathResponse_Body)
if !ok {
return message.NewUnexpectedMessageType(m, v)
}
var err error
r.nodes, err = GetNodeByPathInfoFromGRPC(v.GetNodes())
return err
}
func GetNodeByPathInfoToGRPC(m []*GetNodeByPathResponseInfo) (res []*tree.GetNodeByPathResponse_Info) {
if m != nil {
res = make([]*tree.GetNodeByPathResponse_Info, 0, len(m))
for i := range m {
res = append(res, m[i].ToGRPCMessage().(*tree.GetNodeByPathResponse_Info))
}
}
return
}
func GetNodeByPathInfoFromGRPC(m []*tree.GetNodeByPathResponse_Info) (res []*GetNodeByPathResponseInfo, err error) {
if m != nil {
res = make([]*GetNodeByPathResponseInfo, len(m))
for i := range m {
res[i] = new(GetNodeByPathResponseInfo)
err = res[i].FromGRPCMessage(m[i])
if err != nil {
return
}
}
}
return
}
func (r *GetNodeByPathResponseInfo) ToGRPCMessage() grpc.Message {
var m *tree.GetNodeByPathResponse_Info
if r != nil {
m = new(tree.GetNodeByPathResponse_Info)
m.Meta = metaToGRPC(r.meta)
m.NodeId = r.nodeID
m.Timestamp = r.timestamp
m.ParentId = r.parentID
}
return m
}
func (r *GetNodeByPathResponseInfo) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.GetNodeByPathResponse_Info)
if !ok {
return message.NewUnexpectedMessageType(m, v)
}
var err error
r.meta, err = metaFromGRPC(v.GetMeta())
if err != nil {
return err
}
r.timestamp = v.GetTimestamp()
r.nodeID = v.GetNodeId()
r.parentID = v.GetParentId()
return err
}
func (r *ListRequest) ToGRPCMessage() grpc.Message {
var m *tree.TreeListRequest
if r != nil {
m = new(tree.TreeListRequest)
m.Body = r.body.ToGRPCMessage().(*tree.TreeListRequest_Body)
m.SetSignature(r.signature.ToGRPCMessage().(*tree.Signature))
}
return m
}
func (r *ListRequest) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.TreeListRequest)
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(ListRequestBody)
}
err = r.body.FromGRPCMessage(body)
if err != nil {
return err
}
}
sig := v.GetSignature()
if sig == nil {
r.signature = nil
} else {
if r.signature == nil {
r.signature = new(Signature)
}
err = r.signature.FromGRPCMessage(sig)
}
return err
}
func (r *ListRequestBody) ToGRPCMessage() grpc.Message {
var m *tree.TreeListRequest_Body
if r != nil {
m = new(tree.TreeListRequest_Body)
m.ContainerId = r.containerID
}
return m
}
func (r *ListRequestBody) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.TreeListRequest_Body)
if !ok {
return message.NewUnexpectedMessageType(m, v)
}
r.containerID = v.GetContainerId()
return nil
}
func (r *ListResponse) ToGRPCMessage() grpc.Message {
var m *tree.TreeListResponse
if r != nil {
m = new(tree.TreeListResponse)
m.Body = r.body.ToGRPCMessage().(*tree.TreeListResponse_Body)
m.Signature = r.signature.ToGRPCMessage().(*tree.Signature)
}
return m
}
func (r *ListResponse) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.TreeListResponse)
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(ListResponseBody)
}
err = r.body.FromGRPCMessage(body)
if err != nil {
return err
}
}
sig := v.GetSignature()
if sig == nil {
r.signature = nil
} else {
if r.signature == nil {
r.signature = new(Signature)
}
err = r.signature.FromGRPCMessage(sig)
}
return err
}
func (r *ListResponseBody) ToGRPCMessage() grpc.Message {
var m *tree.TreeListResponse_Body
if r != nil {
m = new(tree.TreeListResponse_Body)
m.Ids = r.ids
}
return m
}
func (r *ListResponseBody) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.TreeListResponse_Body)
if !ok {
return message.NewUnexpectedMessageType(m, v)
}
r.ids = v.GetIds()
return nil
}
func (r *ApplyRequest) ToGRPCMessage() grpc.Message {
var m *tree.ApplyRequest
if r != nil {
m = new(tree.ApplyRequest)
m.Body = r.body.ToGRPCMessage().(*tree.ApplyRequest_Body)
m.SetSignature(r.signature.ToGRPCMessage().(*tree.Signature))
}
return m
}
func (r *ApplyRequest) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.ApplyRequest)
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(ApplyRequestBody)
}
err = r.body.FromGRPCMessage(body)
if err != nil {
return err
}
}
sig := v.GetSignature()
if sig == nil {
r.signature = nil
} else {
if r.signature == nil {
r.signature = new(Signature)
}
err = r.signature.FromGRPCMessage(sig)
}
return err
}
func (r *ApplyRequestBody) ToGRPCMessage() grpc.Message {
var m *tree.ApplyRequest_Body
if r != nil {
m = new(tree.ApplyRequest_Body)
m.TreeId = r.treeID
m.ContainerId = r.containerID
m.Operation = r.operation.ToGRPCMessage().(*tree.LogMove)
}
return m
}
func (r *ApplyRequestBody) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.ApplyRequest_Body)
if !ok {
return message.NewUnexpectedMessageType(m, v)
}
var err error
r.treeID = v.GetTreeId()
r.containerID = v.GetContainerId()
op := v.GetOperation()
if op == nil {
r.operation = nil
} else {
if r.operation == nil {
r.operation = new(LogMove)
}
err = r.operation.FromGRPCMessage(op)
}
return err
}
func (r *ApplyResponse) ToGRPCMessage() grpc.Message {
var m *tree.ApplyResponse
if r != nil {
m = new(tree.ApplyResponse)
m.Body = r.body.ToGRPCMessage().(*tree.ApplyResponse_Body)
m.SetSignature(r.signature.ToGRPCMessage().(*tree.Signature))
}
return m
}
func (r *ApplyResponse) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.ApplyResponse)
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(ApplyResponseBody)
}
err = r.body.FromGRPCMessage(body)
if err != nil {
return err
}
}
sig := v.GetSignature()
if sig == nil {
r.signature = nil
} else {
if r.signature == nil {
r.signature = new(Signature)
}
err = r.signature.FromGRPCMessage(sig)
}
return err
}
func (r *ApplyResponseBody) ToGRPCMessage() grpc.Message {
return new(tree.ApplyResponse_Body)
}
func (r *ApplyResponseBody) FromGRPCMessage(grpc.Message) error {
return nil
}
func (r *HealthcheckRequest) ToGRPCMessage() grpc.Message {
var m *tree.HealthcheckRequest
if r != nil {
m = new(tree.HealthcheckRequest)
m.Body = r.body.ToGRPCMessage().(*tree.HealthcheckRequest_Body)
m.SetSignature(r.signature.ToGRPCMessage().(*tree.Signature))
}
return m
}
func (r *HealthcheckRequest) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.HealthcheckRequest)
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(HealthcheckRequestBody)
}
err = r.body.FromGRPCMessage(body)
if err != nil {
return err
}
}
sig := v.GetSignature()
if sig == nil {
r.signature = nil
} else {
if r.signature == nil {
r.signature = new(Signature)
}
err = r.signature.FromGRPCMessage(sig)
}
return err
}
func (r *HealthcheckRequestBody) ToGRPCMessage() grpc.Message {
return new(tree.HealthcheckRequest_Body)
}
func (r *HealthcheckRequestBody) FromGRPCMessage(grpc.Message) error {
return nil
}
func (r *HealthcheckResponse) ToGRPCMessage() grpc.Message {
var m *tree.HealthcheckResponse
if r != nil {
m = new(tree.HealthcheckResponse)
m.Body = r.body.ToGRPCMessage().(*tree.HealthcheckResponse_Body)
m.SetSignature(r.signature.ToGRPCMessage().(*tree.Signature))
}
return m
}
func (r *HealthcheckResponse) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.HealthcheckResponse)
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(HealthcheckResponseBody)
}
err = r.body.FromGRPCMessage(body)
if err != nil {
return err
}
}
sig := v.GetSignature()
if sig == nil {
r.signature = nil
} else {
if r.signature == nil {
r.signature = new(Signature)
}
err = r.signature.FromGRPCMessage(sig)
}
return err
}
func (r *HealthcheckResponseBody) ToGRPCMessage() grpc.Message {
return new(tree.HealthcheckResponse_Body)
}
func (r *HealthcheckResponseBody) FromGRPCMessage(grpc.Message) error {
return nil
}
func (r *GetSubTreeResponse) ToGRPCMessage() grpc.Message {
var m *tree.GetSubTreeResponse
if r != nil {
m = new(tree.GetSubTreeResponse)
m.Body = r.body.ToGRPCMessage().(*tree.GetSubTreeResponse_Body)
m.SetSignature(r.signature.ToGRPCMessage().(*tree.Signature))
}
return m
}
func (r *GetSubTreeResponse) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.GetSubTreeResponse)
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(GetSubTreeResponseBody)
}
err = r.body.FromGRPCMessage(body)
if err != nil {
return err
}
}
sig := v.GetSignature()
if sig == nil {
r.signature = nil
} else {
if r.signature == nil {
r.signature = new(Signature)
}
err = r.signature.FromGRPCMessage(sig)
}
return err
}
func (r *GetOpLogRequest) ToGRPCMessage() grpc.Message {
var m *tree.GetOpLogRequest
if r != nil {
m = new(tree.GetOpLogRequest)
m.Body = r.body.ToGRPCMessage().(*tree.GetOpLogRequest_Body)
m.SetSignature(r.signature.ToGRPCMessage().(*tree.Signature))
}
return m
}
func (r *GetOpLogRequest) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.GetOpLogRequest)
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(GetOpLogRequestBody)
}
err = r.body.FromGRPCMessage(body)
if err != nil {
return err
}
}
sig := v.GetSignature()
if sig == nil {
r.signature = nil
} else {
if r.signature == nil {
r.signature = new(Signature)
}
err = r.signature.FromGRPCMessage(sig)
}
return err
}
func (r *GetOpLogRequestBody) ToGRPCMessage() grpc.Message {
var m *tree.GetOpLogRequest_Body
if r != nil {
m = new(tree.GetOpLogRequest_Body)
m.TreeId = r.treeID
m.Count = r.count
m.ContainerId = r.containerID
m.Height = r.height
}
return m
}
func (r *GetOpLogRequestBody) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.GetOpLogRequest_Body)
if !ok {
return message.NewUnexpectedMessageType(m, v)
}
var err error
r.count = v.GetCount()
r.containerID = v.GetContainerId()
r.height = v.GetHeight()
r.treeID = v.GetTreeId()
return err
}
func (r *GetOpLogResponse) ToGRPCMessage() grpc.Message {
var m *tree.GetOpLogResponse
if r != nil {
m = new(tree.GetOpLogResponse)
m.Body = r.body.ToGRPCMessage().(*tree.GetOpLogResponse_Body)
m.SetSignature(r.signature.ToGRPCMessage().(*tree.Signature))
}
return m
}
func (r *GetOpLogResponse) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.GetOpLogResponse)
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(GetOpLogResponseBody)
}
err = r.body.FromGRPCMessage(body)
if err != nil {
return err
}
}
sig := v.GetSignature()
if sig == nil {
r.signature = nil
} else {
if r.signature == nil {
r.signature = new(Signature)
}
err = r.signature.FromGRPCMessage(sig)
}
return err
}
func (r *GetOpLogResponseBody) ToGRPCMessage() grpc.Message {
var m *tree.GetOpLogResponse_Body
if r != nil {
m = new(tree.GetOpLogResponse_Body)
m.Operation = r.operation.ToGRPCMessage().(*tree.LogMove)
}
return m
}
func (r *GetOpLogResponseBody) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.GetOpLogResponse_Body)
if !ok {
return message.NewUnexpectedMessageType(m, v)
}
var err error
oper := v.GetOperation()
if oper == nil {
r.operation = nil
} else {
if r.operation == nil {
r.operation = new(LogMove)
}
err = r.operation.FromGRPCMessage(oper)
}
return err
}
func (s *Signature) ToGRPCMessage() grpc.Message {
var m *tree.Signature
if s != nil {
m = new(tree.Signature)
m.Sign = s.sign
m.Key = s.key
}
return m
}
func (s *Signature) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.Signature)
if !ok {
return message.NewUnexpectedMessageType(m, v)
}
s.sign = v.GetSign()
s.key = v.GetKey()
return nil
}
func (k *KeyValue) ToGRPCMessage() grpc.Message {
var m *tree.KeyValue
if k != nil {
m = new(tree.KeyValue)
m.Key = k.key
m.Value = k.value
}
return m
}
func (k *KeyValue) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.KeyValue)
if !ok {
return message.NewUnexpectedMessageType(m, v)
}
k.key = v.GetKey()
k.value = v.GetValue()
return nil
}
func (g *LogMove) ToGRPCMessage() grpc.Message {
var m *tree.LogMove
if g != nil {
m = new(tree.LogMove)
m.Meta = g.meta
m.ParentId = g.parentID
m.ChildId = g.childID
}
return m
}
func (g *LogMove) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.LogMove)
if !ok {
return message.NewUnexpectedMessageType(m, v)
}
g.meta = v.GetMeta()
g.parentID = v.GetParentId()
g.childID = v.GetChildId()
return nil
}
func (r *GetSubTreeRequest) ToGRPCMessage() grpc.Message {
var m *tree.GetSubTreeRequest
if r != nil {
m = new(tree.GetSubTreeRequest)
m.Body = r.body.ToGRPCMessage().(*tree.GetSubTreeRequest_Body)
m.SetSignature(r.signature.ToGRPCMessage().(*tree.Signature))
}
return m
}
func (r *GetSubTreeRequest) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.GetSubTreeRequest)
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(GetSubTreeRequestBody)
}
err = r.body.FromGRPCMessage(body)
if err != nil {
return err
}
}
sig := v.GetSignature()
if sig == nil {
r.signature = nil
} else {
if r.signature == nil {
r.signature = new(Signature)
}
err = r.signature.FromGRPCMessage(sig)
}
return err
}
func (r *GetSubTreeRequestBody) ToGRPCMessage() grpc.Message {
var m *tree.GetSubTreeRequest_Body
if r != nil {
m = new(tree.GetSubTreeRequest_Body)
m.TreeId = r.treeID
m.BearerToken = r.bearerToken
m.Depth = r.depth
m.RootId = r.rootID
m.ContainerId = r.containerID
m.OrderBy = r.orderBy.ToGRPCMessage().(*tree.GetSubTreeRequest_Body_Order)
}
return m
}
func (r *GetSubTreeRequestBody) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.GetSubTreeRequest_Body)
if !ok {
return message.NewUnexpectedMessageType(m, v)
}
r.rootID = v.GetRootId()
r.depth = v.GetDepth()
r.containerID = v.GetContainerId()
r.bearerToken = v.GetBearerToken()
r.treeID = v.GetTreeId()
var err error
order := v.GetOrderBy()
if order == nil {
r.orderBy = nil
} else {
if r.orderBy == nil {
r.orderBy = new(GetSubTreeRequestBodyOrder)
}
err = r.orderBy.FromGRPCMessage(order)
if err != nil {
return err
}
}
return err
}
func (r *GetSubTreeRequestBodyOrder) ToGRPCMessage() grpc.Message {
var m *tree.GetSubTreeRequest_Body_Order
if r != nil {
m = new(tree.GetSubTreeRequest_Body_Order)
m.Direction = tree.GetSubTreeRequest_Body_Order_Direction(r.direction)
}
return m
}
func (r *GetSubTreeRequestBodyOrder) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.GetSubTreeRequest_Body_Order)
if !ok {
return message.NewUnexpectedMessageType(m, v)
}
r.direction = GetSubTreeRequestBodyOrderDirection(v.GetDirection())
return nil
}
func (r *GetSubTreeResponseBody) ToGRPCMessage() grpc.Message {
var m *tree.GetSubTreeResponse_Body
if r != nil {
m = new(tree.GetSubTreeResponse_Body)
m.Meta = metaToGRPC(r.meta)
m.ParentId = r.parentID
m.NodeId = r.nodeID
m.Timestamp = r.timestamp
}
return m
}
func (r *GetSubTreeResponseBody) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tree.GetSubTreeResponse_Body)
if !ok {
return message.NewUnexpectedMessageType(m, v)
}
var err error
r.nodeID = v.GetNodeId()
r.timestamp = v.GetTimestamp()
r.parentID = v.GetParentId()
r.meta, err = metaFromGRPC(v.GetMeta())
return err
}