forked from TrueCloudLab/frostfs-api-go
[#371] Support recent changes in NeoFS API protocol
Support: * new status codes (object, container, session); * object `Lock` message; * different signature schemes. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
a4349f6692
commit
99370889d1
41 changed files with 1139 additions and 129 deletions
17
container/grpc/service.pb.go
generated
17
container/grpc/service.pb.go
generated
|
@ -1,7 +1,7 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.27.1
|
||||
// protoc v3.19.1
|
||||
// protoc v3.19.4
|
||||
// source: container/grpc/service.proto
|
||||
|
||||
package container
|
||||
|
@ -1016,7 +1016,8 @@ type PutRequest_Body struct {
|
|||
|
||||
// Container structure to register in NeoFS
|
||||
Container *Container `protobuf:"bytes,1,opt,name=container,proto3" json:"container,omitempty"`
|
||||
// Signature of a stable-marshalled container according to RFC-6979
|
||||
// Signature of a stable-marshalled container according to RFC-6979.
|
||||
// Signature scheme must be either UNSPECIFIED or ECDSA_RFC6979_SHA256.
|
||||
Signature *grpc1.Signature `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"`
|
||||
}
|
||||
|
||||
|
@ -1128,7 +1129,8 @@ type DeleteRequest_Body struct {
|
|||
|
||||
// Identifier of the container to delete from NeoFS
|
||||
ContainerId *grpc1.ContainerID `protobuf:"bytes,1,opt,name=container_id,json=containerId,proto3" json:"container_id,omitempty"`
|
||||
// `ContainerID` signed with the container owner's key according to RFC-6979
|
||||
// `ContainerID` signed with the container owner's key according to RFC-6979.
|
||||
// Signature scheme must be either UNSPECIFIED or ECDSA_RFC6979_SHA256.
|
||||
Signature *grpc1.Signature `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"`
|
||||
}
|
||||
|
||||
|
@ -1276,7 +1278,8 @@ type GetResponse_Body struct {
|
|||
|
||||
// Requested container structure
|
||||
Container *Container `protobuf:"bytes,1,opt,name=container,proto3" json:"container,omitempty"`
|
||||
// Signature of a stable-marshalled container according to RFC-6979
|
||||
// Signature of a stable-marshalled container according to RFC-6979.
|
||||
// Signature scheme must be either UNSPECIFIED or ECDSA_RFC6979_SHA256.
|
||||
Signature *grpc1.Signature `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"`
|
||||
// Session token if the container was created within a session
|
||||
SessionToken *grpc.SessionToken `protobuf:"bytes,3,opt,name=session_token,json=sessionToken,proto3" json:"session_token,omitempty"`
|
||||
|
@ -1442,7 +1445,8 @@ type SetExtendedACLRequest_Body struct {
|
|||
|
||||
// Extended ACL table to set for container
|
||||
Eacl *grpc2.EACLTable `protobuf:"bytes,1,opt,name=eacl,proto3" json:"eacl,omitempty"`
|
||||
// Signature of stable-marshalled Extended ACL table according to RFC-6979
|
||||
// Signature of stable-marshalled Extended ACL table according to RFC-6979.
|
||||
// Signature scheme must be either UNSPECIFIED or ECDSA_RFC6979_SHA256.
|
||||
Signature *grpc1.Signature `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"`
|
||||
}
|
||||
|
||||
|
@ -1592,7 +1596,8 @@ type GetExtendedACLResponse_Body struct {
|
|||
|
||||
// Extended ACL requested, if available
|
||||
Eacl *grpc2.EACLTable `protobuf:"bytes,1,opt,name=eacl,proto3" json:"eacl,omitempty"`
|
||||
// Signature of stable-marshalled Extended ACL according to RFC-6979
|
||||
// Signature of stable-marshalled Extended ACL according to RFC-6979.
|
||||
// Signature scheme must be either UNSPECIFIED or ECDSA_RFC6979_SHA256.
|
||||
Signature *grpc1.Signature `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"`
|
||||
// Session token if Extended ACL was set within a session
|
||||
SessionToken *grpc.SessionToken `protobuf:"bytes,3,opt,name=session_token,json=sessionToken,proto3" json:"session_token,omitempty"`
|
||||
|
|
76
container/grpc/service_grpc.pb.go
generated
76
container/grpc/service_grpc.pb.go
generated
|
@ -1,4 +1,8 @@
|
|||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.2.0
|
||||
// - protoc v3.19.4
|
||||
// source: container/grpc/service.proto
|
||||
|
||||
package container
|
||||
|
||||
|
@ -24,8 +28,8 @@ type ContainerServiceClient interface {
|
|||
// is added into smart contract storage.
|
||||
//
|
||||
// Statuses:
|
||||
// - **OK** (0, SECTION_SUCCESS):
|
||||
// request to save the container has been sent to the sidechain;
|
||||
// - **OK** (0, SECTION_SUCCESS): \
|
||||
// request to save the container has been sent to the sidechain;
|
||||
// - Common failures (SECTION_FAILURE_COMMON).
|
||||
Put(ctx context.Context, in *PutRequest, opts ...grpc.CallOption) (*PutResponse, error)
|
||||
// `Delete` invokes `Container` smart contract's `Delete` method and returns
|
||||
|
@ -34,22 +38,24 @@ type ContainerServiceClient interface {
|
|||
// is added into smart contract storage.
|
||||
//
|
||||
// Statuses:
|
||||
// - **OK** (0, SECTION_SUCCESS):
|
||||
// request to remove the container has been sent to the sidechain;
|
||||
// - **OK** (0, SECTION_SUCCESS): \
|
||||
// request to remove the container has been sent to the sidechain;
|
||||
// - Common failures (SECTION_FAILURE_COMMON).
|
||||
Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*DeleteResponse, error)
|
||||
// Returns container structure from `Container` smart contract storage.
|
||||
//
|
||||
// Statuses:
|
||||
// - **OK** (0, SECTION_SUCCESS):
|
||||
// container has been successfully read;
|
||||
// - Common failures (SECTION_FAILURE_COMMON).
|
||||
// - **OK** (0, SECTION_SUCCESS): \
|
||||
// container has been successfully read;
|
||||
// - Common failures (SECTION_FAILURE_COMMON);
|
||||
// - **CONTAINER_NOT_FOUND** (3072, SECTION_CONTAINER): \
|
||||
// requested container not found.
|
||||
Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error)
|
||||
// Returns all owner's containers from 'Container` smart contract' storage.
|
||||
//
|
||||
// Statuses:
|
||||
// - **OK** (0, SECTION_SUCCESS):
|
||||
// container list has been successfully read;
|
||||
// - **OK** (0, SECTION_SUCCESS): \
|
||||
// container list has been successfully read;
|
||||
// - Common failures (SECTION_FAILURE_COMMON).
|
||||
List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error)
|
||||
// Invokes 'SetEACL' method of 'Container` smart contract and returns response
|
||||
|
@ -57,23 +63,25 @@ type ContainerServiceClient interface {
|
|||
// added into smart contract storage.
|
||||
//
|
||||
// Statuses:
|
||||
// - **OK** (0, SECTION_SUCCESS):
|
||||
// request to save container eACL has been sent to the sidechain;
|
||||
// - **OK** (0, SECTION_SUCCESS): \
|
||||
// request to save container eACL has been sent to the sidechain;
|
||||
// - Common failures (SECTION_FAILURE_COMMON).
|
||||
SetExtendedACL(ctx context.Context, in *SetExtendedACLRequest, opts ...grpc.CallOption) (*SetExtendedACLResponse, error)
|
||||
// Returns Extended ACL table and signature from `Container` smart contract
|
||||
// storage.
|
||||
//
|
||||
// Statuses:
|
||||
// - **OK** (0, SECTION_SUCCESS):
|
||||
// container eACL has been successfully read;
|
||||
// - Common failures (SECTION_FAILURE_COMMON).
|
||||
// - **OK** (0, SECTION_SUCCESS): \
|
||||
// container eACL has been successfully read;
|
||||
// - Common failures (SECTION_FAILURE_COMMON);
|
||||
// - **CONTAINER_NOT_FOUND** (3072, SECTION_CONTAINER): \
|
||||
// container not found.
|
||||
GetExtendedACL(ctx context.Context, in *GetExtendedACLRequest, opts ...grpc.CallOption) (*GetExtendedACLResponse, error)
|
||||
// Announce container used space values for P2P synchronization.
|
||||
//
|
||||
// Statuses:
|
||||
// - **OK** (0, SECTION_SUCCESS):
|
||||
// estimation of used space has been successfully announced;
|
||||
// - **OK** (0, SECTION_SUCCESS): \
|
||||
// estimation of used space has been successfully announced;
|
||||
// - Common failures (SECTION_FAILURE_COMMON).
|
||||
AnnounceUsedSpace(ctx context.Context, in *AnnounceUsedSpaceRequest, opts ...grpc.CallOption) (*AnnounceUsedSpaceResponse, error)
|
||||
}
|
||||
|
@ -159,8 +167,8 @@ type ContainerServiceServer interface {
|
|||
// is added into smart contract storage.
|
||||
//
|
||||
// Statuses:
|
||||
// - **OK** (0, SECTION_SUCCESS):
|
||||
// request to save the container has been sent to the sidechain;
|
||||
// - **OK** (0, SECTION_SUCCESS): \
|
||||
// request to save the container has been sent to the sidechain;
|
||||
// - Common failures (SECTION_FAILURE_COMMON).
|
||||
Put(context.Context, *PutRequest) (*PutResponse, error)
|
||||
// `Delete` invokes `Container` smart contract's `Delete` method and returns
|
||||
|
@ -169,22 +177,24 @@ type ContainerServiceServer interface {
|
|||
// is added into smart contract storage.
|
||||
//
|
||||
// Statuses:
|
||||
// - **OK** (0, SECTION_SUCCESS):
|
||||
// request to remove the container has been sent to the sidechain;
|
||||
// - **OK** (0, SECTION_SUCCESS): \
|
||||
// request to remove the container has been sent to the sidechain;
|
||||
// - Common failures (SECTION_FAILURE_COMMON).
|
||||
Delete(context.Context, *DeleteRequest) (*DeleteResponse, error)
|
||||
// Returns container structure from `Container` smart contract storage.
|
||||
//
|
||||
// Statuses:
|
||||
// - **OK** (0, SECTION_SUCCESS):
|
||||
// container has been successfully read;
|
||||
// - Common failures (SECTION_FAILURE_COMMON).
|
||||
// - **OK** (0, SECTION_SUCCESS): \
|
||||
// container has been successfully read;
|
||||
// - Common failures (SECTION_FAILURE_COMMON);
|
||||
// - **CONTAINER_NOT_FOUND** (3072, SECTION_CONTAINER): \
|
||||
// requested container not found.
|
||||
Get(context.Context, *GetRequest) (*GetResponse, error)
|
||||
// Returns all owner's containers from 'Container` smart contract' storage.
|
||||
//
|
||||
// Statuses:
|
||||
// - **OK** (0, SECTION_SUCCESS):
|
||||
// container list has been successfully read;
|
||||
// - **OK** (0, SECTION_SUCCESS): \
|
||||
// container list has been successfully read;
|
||||
// - Common failures (SECTION_FAILURE_COMMON).
|
||||
List(context.Context, *ListRequest) (*ListResponse, error)
|
||||
// Invokes 'SetEACL' method of 'Container` smart contract and returns response
|
||||
|
@ -192,23 +202,25 @@ type ContainerServiceServer interface {
|
|||
// added into smart contract storage.
|
||||
//
|
||||
// Statuses:
|
||||
// - **OK** (0, SECTION_SUCCESS):
|
||||
// request to save container eACL has been sent to the sidechain;
|
||||
// - **OK** (0, SECTION_SUCCESS): \
|
||||
// request to save container eACL has been sent to the sidechain;
|
||||
// - Common failures (SECTION_FAILURE_COMMON).
|
||||
SetExtendedACL(context.Context, *SetExtendedACLRequest) (*SetExtendedACLResponse, error)
|
||||
// Returns Extended ACL table and signature from `Container` smart contract
|
||||
// storage.
|
||||
//
|
||||
// Statuses:
|
||||
// - **OK** (0, SECTION_SUCCESS):
|
||||
// container eACL has been successfully read;
|
||||
// - Common failures (SECTION_FAILURE_COMMON).
|
||||
// - **OK** (0, SECTION_SUCCESS): \
|
||||
// container eACL has been successfully read;
|
||||
// - Common failures (SECTION_FAILURE_COMMON);
|
||||
// - **CONTAINER_NOT_FOUND** (3072, SECTION_CONTAINER): \
|
||||
// container not found.
|
||||
GetExtendedACL(context.Context, *GetExtendedACLRequest) (*GetExtendedACLResponse, error)
|
||||
// Announce container used space values for P2P synchronization.
|
||||
//
|
||||
// Statuses:
|
||||
// - **OK** (0, SECTION_SUCCESS):
|
||||
// estimation of used space has been successfully announced;
|
||||
// - **OK** (0, SECTION_SUCCESS): \
|
||||
// estimation of used space has been successfully announced;
|
||||
// - Common failures (SECTION_FAILURE_COMMON).
|
||||
AnnounceUsedSpace(context.Context, *AnnounceUsedSpaceRequest) (*AnnounceUsedSpaceResponse, error)
|
||||
}
|
||||
|
|
2
container/grpc/types.pb.go
generated
2
container/grpc/types.pb.go
generated
|
@ -1,7 +1,7 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.27.1
|
||||
// protoc v3.19.1
|
||||
// protoc v3.19.4
|
||||
// source: container/grpc/types.proto
|
||||
|
||||
package container
|
||||
|
|
28
container/status.go
Normal file
28
container/status.go
Normal file
|
@ -0,0 +1,28 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"github.com/nspcc-dev/neofs-api-go/v2/status"
|
||||
statusgrpc "github.com/nspcc-dev/neofs-api-go/v2/status/grpc"
|
||||
)
|
||||
|
||||
// LocalizeFailStatus checks if passed global status.Code is related to container failure and:
|
||||
// then localizes the code and returns true,
|
||||
// else leaves the code unchanged and returns false.
|
||||
//
|
||||
// Arg must not be nil.
|
||||
func LocalizeFailStatus(c *status.Code) bool {
|
||||
return status.LocalizeIfInSection(c, uint32(statusgrpc.Section_SECTION_CONTAINER))
|
||||
}
|
||||
|
||||
// GlobalizeFail globalizes local code of container failure.
|
||||
//
|
||||
// Arg must not be nil.
|
||||
func GlobalizeFail(c *status.Code) {
|
||||
c.GlobalizeSection(uint32(statusgrpc.Section_SECTION_CONTAINER))
|
||||
}
|
||||
|
||||
const (
|
||||
// StatusNotFound is a local status.Code value for
|
||||
// CONTAINER_NOT_FOUND container failure.
|
||||
StatusNotFound status.Code = iota
|
||||
)
|
14
container/status_test.go
Normal file
14
container/status_test.go
Normal file
|
@ -0,0 +1,14 @@
|
|||
package container_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/v2/container"
|
||||
statustest "github.com/nspcc-dev/neofs-api-go/v2/status/test"
|
||||
)
|
||||
|
||||
func TestStatusCodes(t *testing.T) {
|
||||
statustest.TestCodes(t, container.LocalizeFailStatus, container.GlobalizeFail,
|
||||
container.StatusNotFound, 3072,
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue