Update structure with grpc subdir

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2020-08-14 19:00:16 +03:00 committed by Stanislav Bogatyrev
parent 6191903326
commit 60e9c3d0d3
40 changed files with 432 additions and 406 deletions

View file

@ -16,13 +16,16 @@ cd $API_PATH
ARGS=$(find ./ -name '*.proto' -not -path './vendor/*') ARGS=$(find ./ -name '*.proto' -not -path './vendor/*')
for file in $ARGS; do for file in $ARGS; do
dir=$(dirname $file) dir=$(dirname $file)
cp -r $dir $API_GO_PATH/$prefix mkdir -p $API_GO_PATH/$prefix/$dir/grpc
cp -r $dir/* $API_GO_PATH/$prefix/$dir/grpc
done done
# MODIFY FILES # MODIFY FILES
cd $API_GO_PATH/$prefix cd $API_GO_PATH/$prefix
for file in $ARGS; do ARGS2=$(find ./ -name '*.proto')
sed -i "s/import\ \"\(.*\)\";/import\ \"$prefix\/\1\";/" $file for file in $ARGS2; do
echo $file
sed -i "s/import\ \"\(.*\)\/\(.*\)\.proto\";/import\ \"$prefix\/\1\/grpc\/\2\.proto\";/" $file
done done
cd $API_GO_PATH cd $API_GO_PATH
@ -30,7 +33,7 @@ cd $API_GO_PATH
make protoc make protoc
# REMOVE PROTO DEFINITIONS # REMOVE PROTO DEFINITIONS
ARGS=$(find ./ -name '*.proto' -not -path './vendor/*') ARGS=$(find ./$prefix -name '*.proto' -not -path './vendor/*')
for file in $ARGS; do for file in $ARGS; do
rm $file rm $file
done done

View file

@ -1,18 +1,23 @@
package v2 package accounting
import (
"github.com/nspcc-dev/neofs-api-go/v2/refs"
"github.com/nspcc-dev/neofs-api-go/v2/service"
)
type BalanceRequestBody struct { type BalanceRequestBody struct {
ownerID *OwnerID ownerID *refs.OwnerID
} }
type BalanceRequest struct { type BalanceRequest struct {
body *BalanceRequestBody body *BalanceRequestBody
metaHeader *RequestMetaHeader metaHeader *service.RequestMetaHeader
verifyHeader *RequestVerificationHeader verifyHeader *service.RequestVerificationHeader
} }
func (b *BalanceRequestBody) GetOwnerID() *OwnerID { func (b *BalanceRequestBody) GetOwnerID() *refs.OwnerID {
if b != nil { if b != nil {
return b.ownerID return b.ownerID
} }
@ -20,7 +25,7 @@ func (b *BalanceRequestBody) GetOwnerID() *OwnerID {
return nil return nil
} }
func (b *BalanceRequestBody) SetOwnerID(v *OwnerID) { func (b *BalanceRequestBody) SetOwnerID(v *refs.OwnerID) {
if b != nil { if b != nil {
b.ownerID = v b.ownerID = v
} }
@ -56,7 +61,7 @@ func (b *BalanceRequest) SetBody(v *BalanceRequestBody) {
} }
} }
func (b *BalanceRequest) GetRequestMetaHeader() *RequestMetaHeader { func (b *BalanceRequest) GetRequestMetaHeader() *service.RequestMetaHeader {
if b != nil { if b != nil {
return b.metaHeader return b.metaHeader
} }
@ -64,13 +69,13 @@ func (b *BalanceRequest) GetRequestMetaHeader() *RequestMetaHeader {
return nil return nil
} }
func (b *BalanceRequest) SetRequestMetaHeader(v *RequestMetaHeader) { func (b *BalanceRequest) SetRequestMetaHeader(v *service.RequestMetaHeader) {
if b != nil { if b != nil {
b.metaHeader = v b.metaHeader = v
} }
} }
func (b *BalanceRequest) GetRequestVerificationHeader() *RequestVerificationHeader { func (b *BalanceRequest) GetRequestVerificationHeader() *service.RequestVerificationHeader {
if b != nil { if b != nil {
return b.verifyHeader return b.verifyHeader
} }
@ -78,7 +83,7 @@ func (b *BalanceRequest) GetRequestVerificationHeader() *RequestVerificationHead
return nil return nil
} }
func (b *BalanceRequest) SetRequestVerificationHeader(v *RequestVerificationHeader) { func (b *BalanceRequest) SetRequestVerificationHeader(v *service.RequestVerificationHeader) {
if b != nil { if b != nil {
b.verifyHeader = v b.verifyHeader = v
} }

106
v2/accounting/convert.go Normal file
View file

@ -0,0 +1,106 @@
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"
grpcService "github.com/nspcc-dev/neofs-api-go/v2/service/grpc"
)
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 headersToGRPC(
src interface {
GetRequestMetaHeader() *service.RequestMetaHeader
GetRequestVerificationHeader() *service.RequestVerificationHeader
},
dst interface {
SetMetaHeader(*grpcService.RequestMetaHeader)
SetVerifyHeader(*grpcService.RequestVerificationHeader)
},
) {
dst.SetMetaHeader(
service.RequestMetaHeaderToGRPCMessage(src.GetRequestMetaHeader()),
)
dst.SetVerifyHeader(
service.RequestVerificationHeaderToGRPCMessage(src.GetRequestVerificationHeader()),
)
}
func headersFromGRPC(
src interface {
GetMetaHeader() *grpcService.RequestMetaHeader
GetVerifyHeader() *grpcService.RequestVerificationHeader
},
dst interface {
SetRequestMetaHeader(*service.RequestMetaHeader)
SetRequestVerificationHeader(*service.RequestVerificationHeader)
},
) {
dst.SetRequestMetaHeader(
service.RequestMetaHeaderFromGRPCMessage(src.GetMetaHeader()),
)
dst.SetRequestVerificationHeader(
service.RequestVerificationHeaderFromGRPCMessage(src.GetVerifyHeader()),
)
}
func BalanceRequestToGRPCMessage(b *BalanceRequest) *accounting.BalanceRequest {
if b == nil {
return nil
}
m := new(accounting.BalanceRequest)
m.SetBody(
BalanceRequestBodyToGRPCMessage(b.GetBody()),
)
headersToGRPC(b, m)
return m
}
func BalanceRequestFromGRPCMessage(m *accounting.BalanceRequest) *BalanceRequest {
if m == nil {
return nil
}
b := new(BalanceRequest)
b.SetBody(
BalanceRequestBodyFromGRPCMessage(m.GetBody()),
)
headersFromGRPC(m, b)
return b
}

View file

@ -1,8 +1,8 @@
package accounting package accounting
import ( import (
"github.com/nspcc-dev/neofs-api-go/v2/refs" refs "github.com/nspcc-dev/neofs-api-go/v2/refs/grpc"
"github.com/nspcc-dev/neofs-api-go/v2/service" service "github.com/nspcc-dev/neofs-api-go/v2/service/grpc"
) )
// SetValue sets value of the decimal number. // SetValue sets value of the decimal number.

View file

@ -1,7 +1,7 @@
package acl package acl
import ( import (
"github.com/nspcc-dev/neofs-api-go/v2/refs" refs "github.com/nspcc-dev/neofs-api-go/v2/refs/grpc"
) )
// SetContainerId sets container identifier of the eACL table. // SetContainerId sets container identifier of the eACL table.

View file

@ -3,8 +3,8 @@ package container
import ( import (
"testing" "testing"
"github.com/nspcc-dev/neofs-api-go/v2/netmap" netmap "github.com/nspcc-dev/neofs-api-go/v2/netmap/grpc"
"github.com/nspcc-dev/neofs-api-go/v2/refs" refs "github.com/nspcc-dev/neofs-api-go/v2/refs/grpc"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View file

@ -1,9 +1,9 @@
package container package container
import ( import (
"github.com/nspcc-dev/neofs-api-go/v2/acl" acl "github.com/nspcc-dev/neofs-api-go/v2/acl/grpc"
"github.com/nspcc-dev/neofs-api-go/v2/refs" refs "github.com/nspcc-dev/neofs-api-go/v2/refs/grpc"
"github.com/nspcc-dev/neofs-api-go/v2/service" service "github.com/nspcc-dev/neofs-api-go/v2/service/grpc"
) )
// SetContainer sets container of the request. // SetContainer sets container of the request.

View file

@ -1,8 +1,8 @@
package container package container
import ( import (
"github.com/nspcc-dev/neofs-api-go/v2/netmap" netmap "github.com/nspcc-dev/neofs-api-go/v2/netmap/grpc"
"github.com/nspcc-dev/neofs-api-go/v2/refs" refs "github.com/nspcc-dev/neofs-api-go/v2/refs/grpc"
) )
// SetKey sets key to the container attribute. // SetKey sets key to the container attribute.

View file

@ -1,351 +1 @@
package v2 package v2
import (
"github.com/nspcc-dev/neofs-api-go/v2/accounting"
"github.com/nspcc-dev/neofs-api-go/v2/refs"
"github.com/nspcc-dev/neofs-api-go/v2/service"
)
func SignatureToGRPCMessage(s *Signature) *service.Signature {
if s == nil {
return nil
}
m := new(service.Signature)
m.SetKey(s.GetKey())
m.SetSign(s.GetSign())
return m
}
func SignatureFromGRPCMessage(m *service.Signature) *Signature {
if m == nil {
return nil
}
s := new(Signature)
s.SetKey(m.GetKey())
s.SetSign(m.GetSign())
return s
}
func VersionToGRPCMessage(v *Version) *service.Version {
if v == nil {
return nil
}
msg := new(service.Version)
msg.SetMajor(v.GetMajor())
msg.SetMinor(v.GetMinor())
return msg
}
func VersionFromGRPCMessage(m *service.Version) *Version {
if m == nil {
return nil
}
v := new(Version)
v.SetMajor(m.GetMajor())
v.SetMinor(m.GetMinor())
return v
}
func XHeaderToGRPCMessage(x *XHeader) *service.XHeader {
if x == nil {
return nil
}
m := new(service.XHeader)
m.SetKey(x.GetKey())
m.SetValue(x.GetValue())
return m
}
func XHeaderFromGRPCMessage(m *service.XHeader) *XHeader {
if m == nil {
return nil
}
x := new(XHeader)
x.SetKey(m.GetKey())
x.SetValue(m.GetValue())
return x
}
func SessionTokenToGRPCMessage(t *SessionToken) *service.SessionToken {
// TODO: fill me
return nil
}
func SessionTokenFromGRPCMessage(m *service.SessionToken) *SessionToken {
// TODO: fill me
return nil
}
func BearerTokenToGRPCMessage(t *BearerToken) *service.BearerToken {
// TODO: fill me
return nil
}
func BearerTokenFromGRPCMessage(m *service.BearerToken) *BearerToken {
// TODO: fill me
return nil
}
func RequestVerificationHeaderToGRPCMessage(r *RequestVerificationHeader) *service.RequestVerificationHeader {
if r == nil {
return nil
}
m := new(service.RequestVerificationHeader)
m.SetBodySignature(
SignatureToGRPCMessage(r.GetBodySignature()),
)
m.SetMetaSignature(
SignatureToGRPCMessage(r.GetMetaSignature()),
)
m.SetOriginSignature(
SignatureToGRPCMessage(r.GetOriginSignature()),
)
m.SetOrigin(
RequestVerificationHeaderToGRPCMessage(r.GetOrigin()),
)
return m
}
func RequestVerificationHeaderFromGRPCMessage(m *service.RequestVerificationHeader) *RequestVerificationHeader {
if m == nil {
return nil
}
r := new(RequestVerificationHeader)
r.SetBodySignature(
SignatureFromGRPCMessage(m.GetBodySignature()),
)
r.SetMetaSignature(
SignatureFromGRPCMessage(m.GetMetaSignature()),
)
r.SetOriginSignature(
SignatureFromGRPCMessage(m.GetOriginSignature()),
)
r.SetOrigin(
RequestVerificationHeaderFromGRPCMessage(m.GetOrigin()),
)
return r
}
func RequestMetaHeaderToGRPCMessage(r *RequestMetaHeader) *service.RequestMetaHeader {
if r == nil {
return nil
}
m := new(service.RequestMetaHeader)
m.SetTtl(r.GetTTL())
m.SetEpoch(r.GetEpoch())
m.SetVersion(
VersionToGRPCMessage(r.GetVersion()),
)
m.SetSessionToken(
SessionTokenToGRPCMessage(r.GetSessionToken()),
)
m.SetBearerToken(
BearerTokenToGRPCMessage(r.GetBearerToken()),
)
m.SetOrigin(
RequestMetaHeaderToGRPCMessage(r.GetOrigin()),
)
xHeaders := r.GetXHeaders()
xHdrMsg := make([]*service.XHeader, 0, len(xHeaders))
for i := range xHeaders {
xHdrMsg = append(xHdrMsg, XHeaderToGRPCMessage(xHeaders[i]))
}
return m
}
func RequestMetaHeaderFromGRPCMessage(m *service.RequestMetaHeader) *RequestMetaHeader {
if m == nil {
return nil
}
r := new(RequestMetaHeader)
r.SetTTL(m.GetTtl())
r.SetEpoch(m.GetEpoch())
r.SetVersion(
VersionFromGRPCMessage(m.GetVersion()),
)
r.SetSessionToken(
SessionTokenFromGRPCMessage(m.GetSessionToken()),
)
r.SetBearerToken(
BearerTokenFromGRPCMessage(m.GetBearerToken()),
)
r.SetOrigin(
RequestMetaHeaderFromGRPCMessage(m.GetOrigin()),
)
xHdrMsg := m.GetXHeaders()
xHeaders := make([]*XHeader, 0, len(xHdrMsg))
for i := range xHdrMsg {
xHeaders = append(xHeaders, XHeaderFromGRPCMessage(xHdrMsg[i]))
}
return r
}
func OwnerIDToGRPCMessage(o *OwnerID) *refs.OwnerID {
if o == nil {
return nil
}
m := new(refs.OwnerID)
m.SetValue(o.GetValue())
return m
}
func OwnerIDFromGRPCMessage(m *refs.OwnerID) *OwnerID {
if m == nil {
return nil
}
o := new(OwnerID)
o.SetValue(m.GetValue())
return o
}
func BalanceRequestBodyToGRPCMessage(b *BalanceRequestBody) *accounting.BalanceRequest_Body {
if b == nil {
return nil
}
m := new(accounting.BalanceRequest_Body)
m.SetOwnerId(
OwnerIDToGRPCMessage(b.GetOwnerID()),
)
return m
}
func BalanceRequestBodyFromGRPCMessage(m *accounting.BalanceRequest_Body) *BalanceRequestBody {
if m == nil {
return nil
}
b := new(BalanceRequestBody)
b.SetOwnerID(
OwnerIDFromGRPCMessage(m.GetOwnerId()),
)
return b
}
func headersToGRPC(
src interface {
GetRequestMetaHeader() *RequestMetaHeader
GetRequestVerificationHeader() *RequestVerificationHeader
},
dst interface {
SetMetaHeader(*service.RequestMetaHeader)
SetVerifyHeader(*service.RequestVerificationHeader)
},
) {
dst.SetMetaHeader(
RequestMetaHeaderToGRPCMessage(src.GetRequestMetaHeader()),
)
dst.SetVerifyHeader(
RequestVerificationHeaderToGRPCMessage(src.GetRequestVerificationHeader()),
)
}
func headersFromGRPC(
src interface {
GetMetaHeader() *service.RequestMetaHeader
GetVerifyHeader() *service.RequestVerificationHeader
},
dst interface {
SetRequestMetaHeader(*RequestMetaHeader)
SetRequestVerificationHeader(*RequestVerificationHeader)
},
) {
dst.SetRequestMetaHeader(
RequestMetaHeaderFromGRPCMessage(src.GetMetaHeader()),
)
dst.SetRequestVerificationHeader(
RequestVerificationHeaderFromGRPCMessage(src.GetVerifyHeader()),
)
}
func BalanceRequestToGRPCMessage(b *BalanceRequest) *accounting.BalanceRequest {
if b == nil {
return nil
}
m := new(accounting.BalanceRequest)
m.SetBody(
BalanceRequestBodyToGRPCMessage(b.GetBody()),
)
headersToGRPC(b, m)
return m
}
func BalanceRequestFromGRPCMessage(m *accounting.BalanceRequest) *BalanceRequest {
if m == nil {
return nil
}
b := new(BalanceRequest)
b.SetBody(
BalanceRequestBodyFromGRPCMessage(m.GetBody()),
)
headersFromGRPC(m, b)
return b
}

View file

@ -1,8 +1,8 @@
package object package object
import ( import (
"github.com/nspcc-dev/neofs-api-go/v2/refs" refs "github.com/nspcc-dev/neofs-api-go/v2/refs/grpc"
"github.com/nspcc-dev/neofs-api-go/v2/service" service "github.com/nspcc-dev/neofs-api-go/v2/service/grpc"
) )
// SetAddress sets address of the requested object. // SetAddress sets address of the requested object.

View file

@ -1,8 +1,8 @@
package object package object
import ( import (
"github.com/nspcc-dev/neofs-api-go/v2/refs" refs "github.com/nspcc-dev/neofs-api-go/v2/refs/grpc"
"github.com/nspcc-dev/neofs-api-go/v2/service" service "github.com/nspcc-dev/neofs-api-go/v2/service/grpc"
) )
// SetKey sets key to the object attribute. // SetKey sets key to the object attribute.

29
v2/refs/convert.go Normal file
View file

@ -0,0 +1,29 @@
package refs
import (
refs "github.com/nspcc-dev/neofs-api-go/v2/refs/grpc"
)
func OwnerIDToGRPCMessage(o *OwnerID) *refs.OwnerID {
if o == nil {
return nil
}
m := new(refs.OwnerID)
m.SetValue(o.GetValue())
return m
}
func OwnerIDFromGRPCMessage(m *refs.OwnerID) *OwnerID {
if m == nil {
return nil
}
o := new(OwnerID)
o.SetValue(m.GetValue())
return o
}

19
v2/refs/owner.go Normal file
View file

@ -0,0 +1,19 @@
package refs
type OwnerID struct {
val []byte
}
func (o *OwnerID) GetValue() []byte {
if o != nil {
return o.val
}
return nil
}
func (o *OwnerID) SetValue(v []byte) {
if o != nil {
o.val = v
}
}

201
v2/service/convert.go Normal file
View file

@ -0,0 +1,201 @@
package service
import (
service "github.com/nspcc-dev/neofs-api-go/v2/service/grpc"
)
func VersionToGRPCMessage(v *Version) *service.Version {
if v == nil {
return nil
}
msg := new(service.Version)
msg.SetMajor(v.GetMajor())
msg.SetMinor(v.GetMinor())
return msg
}
func VersionFromGRPCMessage(m *service.Version) *Version {
if m == nil {
return nil
}
v := new(Version)
v.SetMajor(m.GetMajor())
v.SetMinor(m.GetMinor())
return v
}
func XHeaderToGRPCMessage(x *XHeader) *service.XHeader {
if x == nil {
return nil
}
m := new(service.XHeader)
m.SetKey(x.GetKey())
m.SetValue(x.GetValue())
return m
}
func XHeaderFromGRPCMessage(m *service.XHeader) *XHeader {
if m == nil {
return nil
}
x := new(XHeader)
x.SetKey(m.GetKey())
x.SetValue(m.GetValue())
return x
}
func SessionTokenToGRPCMessage(t *SessionToken) *service.SessionToken {
// TODO: fill me
return nil
}
func SessionTokenFromGRPCMessage(m *service.SessionToken) *SessionToken {
// TODO: fill me
return nil
}
func BearerTokenToGRPCMessage(t *BearerToken) *service.BearerToken {
// TODO: fill me
return nil
}
func BearerTokenFromGRPCMessage(m *service.BearerToken) *BearerToken {
// TODO: fill me
return nil
}
func RequestVerificationHeaderToGRPCMessage(r *RequestVerificationHeader) *service.RequestVerificationHeader {
if r == nil {
return nil
}
m := new(service.RequestVerificationHeader)
m.SetBodySignature(
SignatureToGRPCMessage(r.GetBodySignature()),
)
m.SetMetaSignature(
SignatureToGRPCMessage(r.GetMetaSignature()),
)
m.SetOriginSignature(
SignatureToGRPCMessage(r.GetOriginSignature()),
)
m.SetOrigin(
RequestVerificationHeaderToGRPCMessage(r.GetOrigin()),
)
return m
}
func RequestVerificationHeaderFromGRPCMessage(m *service.RequestVerificationHeader) *RequestVerificationHeader {
if m == nil {
return nil
}
r := new(RequestVerificationHeader)
r.SetBodySignature(
SignatureFromGRPCMessage(m.GetBodySignature()),
)
r.SetMetaSignature(
SignatureFromGRPCMessage(m.GetMetaSignature()),
)
r.SetOriginSignature(
SignatureFromGRPCMessage(m.GetOriginSignature()),
)
r.SetOrigin(
RequestVerificationHeaderFromGRPCMessage(m.GetOrigin()),
)
return r
}
func RequestMetaHeaderToGRPCMessage(r *RequestMetaHeader) *service.RequestMetaHeader {
if r == nil {
return nil
}
m := new(service.RequestMetaHeader)
m.SetTtl(r.GetTTL())
m.SetEpoch(r.GetEpoch())
m.SetVersion(
VersionToGRPCMessage(r.GetVersion()),
)
m.SetSessionToken(
SessionTokenToGRPCMessage(r.GetSessionToken()),
)
m.SetBearerToken(
BearerTokenToGRPCMessage(r.GetBearerToken()),
)
m.SetOrigin(
RequestMetaHeaderToGRPCMessage(r.GetOrigin()),
)
xHeaders := r.GetXHeaders()
xHdrMsg := make([]*service.XHeader, 0, len(xHeaders))
for i := range xHeaders {
xHdrMsg = append(xHdrMsg, XHeaderToGRPCMessage(xHeaders[i]))
}
return m
}
func RequestMetaHeaderFromGRPCMessage(m *service.RequestMetaHeader) *RequestMetaHeader {
if m == nil {
return nil
}
r := new(RequestMetaHeader)
r.SetTTL(m.GetTtl())
r.SetEpoch(m.GetEpoch())
r.SetVersion(
VersionFromGRPCMessage(m.GetVersion()),
)
r.SetSessionToken(
SessionTokenFromGRPCMessage(m.GetSessionToken()),
)
r.SetBearerToken(
BearerTokenFromGRPCMessage(m.GetBearerToken()),
)
r.SetOrigin(
RequestMetaHeaderFromGRPCMessage(m.GetOrigin()),
)
xHdrMsg := m.GetXHeaders()
xHeaders := make([]*XHeader, 0, len(xHdrMsg))
for i := range xHdrMsg {
xHeaders = append(xHeaders, XHeaderFromGRPCMessage(xHdrMsg[i]))
}
return r
}

View file

@ -1,8 +1,8 @@
package service package service
import ( import (
"github.com/nspcc-dev/neofs-api-go/v2/acl" acl "github.com/nspcc-dev/neofs-api-go/v2/acl/grpc"
"github.com/nspcc-dev/neofs-api-go/v2/refs" refs "github.com/nspcc-dev/neofs-api-go/v2/refs/grpc"
) )
// SetKey sets key to the X-Header. // SetKey sets key to the X-Header.

View file

@ -1,4 +1,8 @@
package v2 package service
import (
service "github.com/nspcc-dev/neofs-api-go/v2/service/grpc"
)
type Signature struct { type Signature struct {
key, sign []byte key, sign []byte
@ -42,10 +46,6 @@ type RequestMetaHeader struct {
origin *RequestMetaHeader origin *RequestMetaHeader
} }
type OwnerID struct {
val []byte
}
func (s *Signature) GetKey() []byte { func (s *Signature) GetKey() []byte {
if s != nil { if s != nil {
return s.key return s.key
@ -316,16 +316,28 @@ func (r *RequestMetaHeader) StableSize() int {
return RequestMetaHeaderToGRPCMessage(r).Size() return RequestMetaHeaderToGRPCMessage(r).Size()
} }
func (o *OwnerID) GetValue() []byte { func SignatureToGRPCMessage(s *Signature) *service.Signature {
if o != nil { if s == nil {
return o.val return nil
} }
return nil m := new(service.Signature)
m.SetKey(s.GetKey())
m.SetSign(s.GetSign())
return m
} }
func (o *OwnerID) SetValue(v []byte) { func SignatureFromGRPCMessage(m *service.Signature) *Signature {
if o != nil { if m == nil {
o.val = v return nil
} }
s := new(Signature)
s.SetKey(m.GetKey())
s.SetSign(m.GetSign())
return s
} }

View file

@ -1,8 +1,8 @@
package session package session
import ( import (
"github.com/nspcc-dev/neofs-api-go/v2/refs" refs "github.com/nspcc-dev/neofs-api-go/v2/refs/grpc"
"github.com/nspcc-dev/neofs-api-go/v2/service" service "github.com/nspcc-dev/neofs-api-go/v2/service/grpc"
) )
// SetOwnerId sets identifier of the session initiator. // SetOwnerId sets identifier of the session initiator.

View file

@ -5,14 +5,15 @@ import (
"fmt" "fmt"
"github.com/nspcc-dev/neofs-api-go/util/signature" "github.com/nspcc-dev/neofs-api-go/util/signature"
v2 "github.com/nspcc-dev/neofs-api-go/v2" "github.com/nspcc-dev/neofs-api-go/v2/accounting"
"github.com/nspcc-dev/neofs-api-go/v2/service"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
type SignedRequest interface { type SignedRequest interface {
GetRequestMetaHeader() *v2.RequestMetaHeader GetRequestMetaHeader() *service.RequestMetaHeader
GetRequestVerificationHeader() *v2.RequestVerificationHeader GetRequestVerificationHeader() *service.RequestVerificationHeader
SetRequestVerificationHeader(*v2.RequestVerificationHeader) SetRequestVerificationHeader(*service.RequestVerificationHeader)
} }
type stableMarshaler interface { type stableMarshaler interface {
@ -32,14 +33,14 @@ func (s stableMarshalerWrapper) SignedDataSize() int {
return s.sm.StableSize() return s.sm.StableSize()
} }
func keySignatureHandler(s *v2.Signature) signature.KeySignatureHandler { func keySignatureHandler(s *service.Signature) signature.KeySignatureHandler {
return func(key []byte, sig []byte) { return func(key []byte, sig []byte) {
s.SetKey(key) s.SetKey(key)
s.SetSign(sig) s.SetSign(sig)
} }
} }
func keySignatureSource(s *v2.Signature) signature.KeySignatureSource { func keySignatureSource(s *service.Signature) signature.KeySignatureSource {
return func() ([]byte, []byte) { return func() ([]byte, []byte) {
return s.GetKey(), s.GetSign() return s.GetKey(), s.GetSign()
} }
@ -47,7 +48,7 @@ func keySignatureSource(s *v2.Signature) signature.KeySignatureSource {
func requestBody(req SignedRequest) stableMarshaler { func requestBody(req SignedRequest) stableMarshaler {
switch v := req.(type) { switch v := req.(type) {
case *v2.BalanceRequest: case *accounting.BalanceRequest:
return v.GetBody() return v.GetBody()
default: default:
panic(fmt.Sprintf("unknown request %T", req)) panic(fmt.Sprintf("unknown request %T", req))
@ -60,7 +61,7 @@ func SignRequest(key *ecdsa.PrivateKey, req SignedRequest) error {
} }
// create new level of matryoshka // create new level of matryoshka
verifyHdr := new(v2.RequestVerificationHeader) verifyHdr := new(service.RequestVerificationHeader)
// attach the previous matryoshka // attach the previous matryoshka
verifyHdr.SetOrigin(req.GetRequestVerificationHeader()) verifyHdr.SetOrigin(req.GetRequestVerificationHeader())
@ -86,8 +87,8 @@ func SignRequest(key *ecdsa.PrivateKey, req SignedRequest) error {
return nil return nil
} }
func signRequestPart(key *ecdsa.PrivateKey, part stableMarshaler, sigWrite func(*v2.Signature)) error { func signRequestPart(key *ecdsa.PrivateKey, part stableMarshaler, sigWrite func(*service.Signature)) error {
sig := new(v2.Signature) sig := new(service.Signature)
// sign part // sign part
if err := signature.SignDataWithHandler( if err := signature.SignDataWithHandler(
@ -125,7 +126,7 @@ func VerifyRequest(req SignedRequest) error {
return nil return nil
} }
func verifyRequestPart(part stableMarshaler, sigRdr func() *v2.Signature) error { func verifyRequestPart(part stableMarshaler, sigRdr func() *service.Signature) error {
if err := signature.VerifyDataWithSource( if err := signature.VerifyDataWithSource(
&stableMarshalerWrapper{part}, &stableMarshalerWrapper{part},
keySignatureSource(sigRdr()), keySignatureSource(sigRdr()),

View file

@ -1,7 +1,7 @@
package storagegroup package storagegroup
import ( import (
"github.com/nspcc-dev/neofs-api-go/v2/refs" refs "github.com/nspcc-dev/neofs-api-go/v2/refs/grpc"
) )
// SetValidationDataSize sets the total size of the payloads of the storage group. // SetValidationDataSize sets the total size of the payloads of the storage group.