frostfs-api-go/v2/accounting/convert.go
Leonard Lyubich 1d5773b6ff v2/service: Replace request header converters
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-09-18 10:41:34 +03:00

67 lines
1.2 KiB
Go

package accounting
import (
accounting "github.com/nspcc-dev/neofs-api-go/v2/accounting/grpc"
"github.com/nspcc-dev/neofs-api-go/v2/refs"
"github.com/nspcc-dev/neofs-api-go/v2/service"
)
func BalanceRequestBodyToGRPCMessage(b *BalanceRequestBody) *accounting.BalanceRequest_Body {
if b == nil {
return nil
}
m := new(accounting.BalanceRequest_Body)
m.SetOwnerId(
refs.OwnerIDToGRPCMessage(b.GetOwnerID()),
)
return m
}
func BalanceRequestBodyFromGRPCMessage(m *accounting.BalanceRequest_Body) *BalanceRequestBody {
if m == nil {
return nil
}
b := new(BalanceRequestBody)
b.SetOwnerID(
refs.OwnerIDFromGRPCMessage(m.GetOwnerId()),
)
return b
}
func BalanceRequestToGRPCMessage(b *BalanceRequest) *accounting.BalanceRequest {
if b == nil {
return nil
}
m := new(accounting.BalanceRequest)
m.SetBody(
BalanceRequestBodyToGRPCMessage(b.GetBody()),
)
service.RequestHeadersToGRPC(b, m)
return m
}
func BalanceRequestFromGRPCMessage(m *accounting.BalanceRequest) *BalanceRequest {
if m == nil {
return nil
}
b := new(BalanceRequest)
b.SetBody(
BalanceRequestBodyFromGRPCMessage(m.GetBody()),
)
service.RequestHeadersFromGRPC(m, b)
return b
}