frostfs-api-go/v2/audit/convert.go
Alex Vanin aafeb70bdb [#235] v2/audit: Regenerate protobuf
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2020-12-25 16:20:34 +03:00

94 lines
1.8 KiB
Go

package audit
import (
audit "github.com/nspcc-dev/neofs-api-go/v2/audit/grpc"
"github.com/nspcc-dev/neofs-api-go/v2/refs"
)
// DataAuditResultToGRPCMessage converts unified DataAuditResult structure
// into gRPC DataAuditResult message.
func DataAuditResultToGRPCMessage(a *DataAuditResult) *audit.DataAuditResult {
if a == nil {
return nil
}
m := new(audit.DataAuditResult)
m.SetVersion(
refs.VersionToGRPCMessage(a.GetVersion()),
)
m.SetAuditEpoch(a.GetAuditEpoch())
m.SetContainerId(
refs.ContainerIDToGRPCMessage(a.GetContainerID()),
)
m.SetPublicKey(a.GetPublicKey())
m.SetComplete(a.GetComplete())
m.SetPassSg(
refs.ObjectIDListToGRPCMessage(a.GetPassSG()),
)
m.SetFailSg(
refs.ObjectIDListToGRPCMessage(a.GetFailSG()),
)
m.SetRequests(a.GetRequests())
m.SetRetries(a.GetRetries())
m.SetHit(a.GetHit())
m.SetMiss(a.GetMiss())
m.SetFail(a.GetFail())
m.SetPassNodes(a.GetPassNodes())
m.SetFailNodes(a.GetFailNodes())
return m
}
// DataAuditResultFromGRPCMessage converts gRPC message DataAuditResult
// into unified DataAuditResult structure.
func DataAuditResultFromGRPCMessage(m *audit.DataAuditResult) *DataAuditResult {
if m == nil {
return nil
}
a := new(DataAuditResult)
a.SetVersion(
refs.VersionFromGRPCMessage(m.GetVersion()),
)
a.SetAuditEpoch(m.GetAuditEpoch())
a.SetContainerID(
refs.ContainerIDFromGRPCMessage(m.GetContainerId()),
)
a.SetPublicKey(m.GetPublicKey())
a.SetComplete(m.GetComplete())
a.SetPassSG(
refs.ObjectIDListFromGRPCMessage(m.GetPassSg()),
)
a.SetFailSG(
refs.ObjectIDListFromGRPCMessage(m.GetFailSg()),
)
a.SetRequests(m.GetRequests())
a.SetRetries(m.GetRetries())
a.SetHit(m.GetHit())
a.SetMiss(m.GetMiss())
a.SetFail(m.GetFail())
a.SetPassNodes(m.GetPassNodes())
a.SetFailNodes(m.GetFailNodes())
return a
}