diff --git a/accounting/v2/service.pb.go b/accounting/v2/service.pb.go new file mode 100644 index 00000000..7d8eba9c Binary files /dev/null and b/accounting/v2/service.pb.go differ diff --git a/accounting/v2/service.proto b/accounting/v2/service.proto new file mode 100644 index 00000000..6c12c6ba --- /dev/null +++ b/accounting/v2/service.proto @@ -0,0 +1,75 @@ +syntax = "proto3"; + +package accounting.v2; + +option go_package = "github.com/nspcc-dev/neofs-api-go/accounting/v2"; +option csharp_namespace = "NeoFS.API.Accounting"; + +import "refs/v2/types.proto"; +import "service/v2/meta.proto"; +import "service/v2/verify.proto"; + +// The service provides methods for obtaining information +// about the account balance in NeoFS system. +service Accounting { + // Returns the amount of funds for the requested NeoFS account. + rpc Balance (BalanceRequest) returns (BalanceResponse); +} + +// Message defines the request body of Balance method. +// +// To indicate the account for which the balance is requested, it's identifier +// is used. +// +// To gain access to the requested information, the request body must be formed +// according to the requirements from the system specification. +message BalanceRequest { + message Body { + // Carries user identifier in NeoFS system for which the balance + // is requested. + refs.v2.OwnerID owner_id = 1; + } + + // Body of the balance request message. + Body body = 1; + + // Carries request meta information. Header data is used only to regulate + // message transport and does not affect request execution. + service.v2.RequestMetaHeader meta_header = 2; + + // Carries request verification information. This header is used to + // authenticate the nodes of the message route and check the correctness + // of transmission. + service.v2.RequestVerificationHeader verify_header = 3; +} + +// Decimal represents the decimal numbers. +message Decimal { + // value carries number value. + int64 value = 1; + + // precision carries value precision. + uint32 precision = 2; +} + +// Message defines the response body of Balance method. +// +// The amount of funds is calculated in decimal numbers. +message BalanceResponse { + message Body { + // Carries the amount of funds on the account. + Decimal balance = 1; + } + + // Body of the balance response message. + Body body = 1; + + // Carries response meta information. Header data is used only to regulate + // message transport and does not affect request execution. + service.v2.ResponseMetaHeader meta_header = 2; + + // Carries response verification information. This header is used to + // authenticate the nodes of the message route and check the correctness + // of transmission. + service.v2.ResponseVerificationHeader verify_header = 3; +} diff --git a/acl/v2/types.pb.go b/acl/v2/types.pb.go new file mode 100644 index 00000000..06711e24 Binary files /dev/null and b/acl/v2/types.pb.go differ diff --git a/acl/v2/types.proto b/acl/v2/types.proto new file mode 100644 index 00000000..58bbe255 --- /dev/null +++ b/acl/v2/types.proto @@ -0,0 +1,106 @@ +syntax = "proto3"; + +package acl.v2; + +option go_package = "github.com/nspcc-dev/neofs-api-go/acl/v2"; +option csharp_namespace = "NeoFS.API.Acl"; + +import "refs/v2/types.proto"; + +// Target of the access control rule in access control list. +enum Target { + // Unknown target, default value. + UNKNOWN = 0; + + // User target rule is applied if sender is the owner of the container.v2. + USER = 1; + + // System target rule is applied if sender is the storage node within the + // container or inner ring node. + SYSTEM = 2; + + // Others target rule is applied if sender is not user or system target. + OTHERS = 3; +} + +// EACLRecord groups information about extended ACL rule. +message EACLRecord { + // Operation is an enumeration of operation types. + enum Operation { + OPERATION_UNKNOWN = 0; + GET = 1; + HEAD = 2; + PUT = 3; + DELETE = 4; + SEARCH = 5; + GETRANGE = 6; + GETRANGEHASH = 7; + } + + // Operation carries type of operation. + Operation operation = 1 [json_name = "Operation"]; + + // Action is an enumeration of EACL actions. + enum Action { + ACTION_UNKNOWN = 0; + ALLOW = 1; + DENY = 2; + } + + // Action carries ACL target action. + Action action = 2 [json_name = "Action"]; + + // FilterInfo groups information about filter. + message FilterInfo { + // Header is an enumeration of filtering header types. + enum Header { + HEADER_UNKNOWN = 0; + REQUEST = 1; + OBJECT = 2; + } + + // Header carries type of header. + Header header = 1 [json_name = "HeaderType"]; + + // MatchType is an enumeration of match types. + enum MatchType { + MATCH_UNKNOWN = 0; + STRING_EQUAL = 1; + STRING_NOT_EQUAL = 2; + } + + // MatchType carries type of match. + MatchType match_type = 2 [json_name = "MatchType"]; + + // header_name carries name of filtering header. + string header_name = 3 [json_name="Name"]; + + // header_val carries value of filtering header. + string header_val = 4 [json_name="Value"]; + } + + // filters carries set of filters. + repeated FilterInfo filters = 3 [json_name="Filters"]; + + // TargetInfo groups information about extended ACL target. + message TargetInfo { + // target carries target of ACL rule. + acl.v2.Target target = 1 [json_name="Role"]; + + // key_list carries public keys of ACL target. + repeated bytes key_list = 2 [json_name="Keys"]; + } + + // targets carries information about extended ACL target list. + repeated TargetInfo targets = 4 [json_name="Targets"]; +} + +// EACLRecord carries the information about extended ACL rules. +message EACLTable { + // Carries identifier of the container that should use given + // access control rules. + refs.v2.ContainerID container_id = 1 [json_name="ContainerID"]; + + // Records carries list of extended ACL rule records. + repeated EACLRecord records = 2 [json_name="Records"]; +} diff --git a/container/v2/service.pb.go b/container/v2/service.pb.go new file mode 100644 index 00000000..29fd6330 Binary files /dev/null and b/container/v2/service.pb.go differ diff --git a/container/v2/service.proto b/container/v2/service.proto new file mode 100644 index 00000000..720abc6d --- /dev/null +++ b/container/v2/service.proto @@ -0,0 +1,285 @@ +syntax = "proto3"; + +package container.v2; + +option go_package = "github.com/nspcc-dev/neofs-api-go/container/v2"; +option csharp_namespace = "NeoFS.API.Container"; + +import "acl/v2/types.proto"; +import "container/v2/types.proto"; +import "refs/v2/types.proto"; +import "service/v2/meta.proto"; +import "service/v2/verify.proto"; + +// Service provides API to access container smart-contract in morph chain +// via NeoFS node. +service Service { + // Put invokes 'Put' method in container smart-contract and returns + // response immediately. After new block in morph chain, request is verified + // by inner ring nodes. After one more block in morph chain, container + // added into smart-contract storage. + rpc Put(PutRequest) returns (PutResponse); + + // Delete invokes 'Delete' method in container smart-contract and returns + // response immediately. After new block in morph chain, request is verified + // by inner ring nodes. After one more block in morph chain, container + // removed from smart-contract storage. + rpc Delete(DeleteRequest) returns (DeleteResponse); + + // Get returns container from container smart-contract storage. + rpc Get(GetRequest) returns (GetResponse); + + // List returns all owner's containers from container smart-contract + // storage. + rpc List(ListRequest) returns (ListResponse); + + // SetExtendedACL invokes 'SetEACL' method in container smart-contract and + // returns response immediately. After new block in morph chain, + // Extended ACL added into smart-contract storage. + rpc SetExtendedACL(SetExtendedACLRequest) returns (SetExtendedACLResponse); + + // GetExtendedACL returns Extended ACL table and signature from container + // smart-contract storage. + rpc GetExtendedACL(GetExtendedACLRequest) returns (GetExtendedACLResponse); +} + +message PutRequest { + message Body { + // Container to create in NeoFS. + container.v2.Container container = 1; + + // Public Key of container owner. It can be public key of the owner + // or it can be public key that bound in neofs.id smart-contract. + bytes public_key = 2; + + // Signature of stable-marshalled container according to RFC-6979. + bytes signature = 3; + } + + // Body of container put request message. + Body body = 1; + + // Carries request meta information. Header data is used only to regulate + // message transport and does not affect request execution. + service.v2.RequestMetaHeader meta_header = 2; + + // Carries request verification information. This header is used to + // authenticate the nodes of the message route and check the correctness + // of transmission. + service.v2.RequestVerificationHeader verify_header = 3; +} + +message PutResponse { + message Body { + // container_id carries identifier of the new container.v2. + refs.v2.ContainerID container_id = 1; + } + + // Body of container put response message. + Body body = 1; + + // Carries response meta information. Header data is used only to regulate + // message transport and does not affect request execution. + service.v2.ResponseMetaHeader meta_header = 2; + + // Carries response verification information. This header is used to + // authenticate the nodes of the message route and check the correctness + // of transmission. + service.v2.ResponseVerificationHeader verify_header = 3; +} + +message DeleteRequest { + message Body { + // container_id carries identifier of the container to delete + // from NeoFS. + refs.v2.ContainerID container_id = 1; + + // Signature of container id according to RFC-6979. + bytes signature = 2; + } + + // Body of container delete request message. + Body body = 1; + + // Carries request meta information. Header data is used only to regulate + // message transport and does not affect request execution. + service.v2.RequestMetaHeader meta_header = 2; + + // Carries request verification information. This header is used to + // authenticate the nodes of the message route and check the correctness + // of transmission. + service.v2.RequestVerificationHeader verify_header = 3; +} + +// DeleteResponse is empty because delete operation is asynchronous and done +// via consensus in inner ring nodes +message DeleteResponse { + message Body {} + + // Body of container delete response message. + Body body = 1; + + // Carries response meta information. Header data is used only to regulate + // message transport and does not affect request execution. + service.v2.ResponseMetaHeader meta_header = 2; + + // Carries response verification information. This header is used to + // authenticate the nodes of the message route and check the correctness + // of transmission. + service.v2.ResponseVerificationHeader verify_header = 3; +} + +message GetRequest { + message Body { + // container_id carries identifier of the container to get. + refs.v2.ContainerID container_id = 1; + } + + // Body of container get request message. + Body body = 1; + + // Carries request meta information. Header data is used only to regulate + // message transport and does not affect request execution. + service.v2.RequestMetaHeader meta_header = 2; + + // Carries request verification information. This header is used to + // authenticate the nodes of the message route and check the correctness + // of transmission. + service.v2.RequestVerificationHeader verify_header = 3; +} + +message GetResponse { + message Body { + // Container that has been requested. + container.v2.Container container = 1; + } + + // Body of container get response message. + Body body = 1; + + // Carries response meta information. Header data is used only to regulate + // message transport and does not affect request execution. + service.v2.ResponseMetaHeader meta_header = 2; + + // Carries response verification information. This header is used to + // authenticate the nodes of the message route and check the correctness + // of transmission. + service.v2.ResponseVerificationHeader verify_header = 3; +} + +message ListRequest { + message Body { + // owner_id carries identifier of the container owner. + refs.v2.OwnerID owner_id = 1; + } + + // Body of list containers request message. + Body body = 1; + + // Carries request meta information. Header data is used only to regulate + // message transport and does not affect request execution. + service.v2.RequestMetaHeader meta_header = 2; + + // Carries request verification information. This header is used to + // authenticate the nodes of the message route and check the correctness + // of transmission. + service.v2.RequestVerificationHeader verify_header = 3; +} + +message ListResponse { + message Body { + // ContainerIDs carries list of identifiers of the containers that belong to the owner. + repeated refs.v2.ContainerID container_ids = 1; + } + + // Body of list containers response message. + Body body = 1; + + // Carries response meta information. Header data is used only to regulate + // message transport and does not affect request execution. + service.v2.ResponseMetaHeader meta_header = 2; + + // Carries response verification information. This header is used to + // authenticate the nodes of the message route and check the correctness + // of transmission. + service.v2.ResponseVerificationHeader verify_header = 3; +} + +message SetExtendedACLRequest { + message Body { + // Extended ACL to set for the container.v2. + acl.v2.EACLTable eacl = 1; + + // Signature of stable-marshalled Extended ACL according to RFC-6979. + bytes signature = 2; + } + + // Body of set extended acl request message. + Body body = 1; + + // Carries request meta information. Header data is used only to regulate + // message transport and does not affect request execution. + service.v2.RequestMetaHeader meta_header = 2; + + // Carries request verification information. This header is used to + // authenticate the nodes of the message route and check the correctness + // of transmission. + service.v2.RequestVerificationHeader verify_header = 3; +} + +message SetExtendedACLResponse { + message Body { } + + // Body of set extended acl response message. + Body body = 1; + + // Carries response meta information. Header data is used only to regulate + // message transport and does not affect request execution. + service.v2.ResponseMetaHeader meta_header = 2; + + // Carries response verification information. This header is used to + // authenticate the nodes of the message route and check the correctness + // of transmission. + service.v2.ResponseVerificationHeader verify_header = 3; +} + +message GetExtendedACLRequest { + message Body { + // container_id carries identifier of the container that has Extended ACL. + refs.v2.ContainerID container_id = 1; + } + + // Body of get extended acl request message. + Body body = 1; + + // Carries request meta information. Header data is used only to regulate + // message transport and does not affect request execution. + service.v2.RequestMetaHeader meta_header = 2; + + // Carries request verification information. This header is used to + // authenticate the nodes of the message route and check the correctness + // of transmission. + service.v2.RequestVerificationHeader verify_header = 3; +} + +message GetExtendedACLResponse { + message Body { + // Extended ACL that has been requested if it was set up. + acl.v2.EACLTable eacl = 1; + + // Signature of stable-marshalled Extended ACL according to RFC-6979. + bytes signature = 2; + } + + // Body of get extended acl response message. + Body body = 1; + + // Carries response meta information. Header data is used only to regulate + // message transport and does not affect request execution. + service.v2.ResponseMetaHeader meta_header = 2; + + // Carries response verification information. This header is used to + // authenticate the nodes of the message route and check the correctness + // of transmission. + service.v2.ResponseVerificationHeader verify_header = 3; +} diff --git a/container/v2/types.pb.go b/container/v2/types.pb.go new file mode 100644 index 00000000..28c03d76 Binary files /dev/null and b/container/v2/types.pb.go differ diff --git a/container/v2/types.proto b/container/v2/types.proto new file mode 100644 index 00000000..5897b8c1 --- /dev/null +++ b/container/v2/types.proto @@ -0,0 +1,40 @@ +syntax = "proto3"; + +package container.v2; + +option go_package = "github.com/nspcc-dev/neofs-api-go/container/v2"; +option csharp_namespace = "NeoFS.API.Container"; + +import "netmap/v2/types.proto"; +import "refs/v2/types.proto"; + +// Container is a structure that defines object placement behaviour. Objects +// can be stored only within containers. They define placement rule, attributes +// and access control information. ID of the container is a 32 byte long +// SHA256 hash of stable-marshalled container message. +message Container { + // OwnerID carries identifier of the container owner. + refs.v2.OwnerID owner_id = 1; + + // Nonce is a 16 byte UUID, used to avoid collisions of container id. + bytes nonce = 2; + + // BasicACL contains access control rules for owner, system, others groups and + // permission bits for bearer token and Extended ACL. + uint32 basic_acl = 3; + + // Attribute is a key-value pair of strings. + message Attribute { + // Key of immutable container attribute. + string key = 1; + + // Value of immutable container attribute. + string value = 2; + } + + // Attributes define any immutable characteristics of container.v2. + repeated Attribute attributes = 4; + + // Rules define storage policy for the object inside the container.v2. + netmap.v2.PlacementRule rules = 5; +} diff --git a/netmap/v2/types.pb.go b/netmap/v2/types.pb.go new file mode 100644 index 00000000..a83e1951 Binary files /dev/null and b/netmap/v2/types.pb.go differ diff --git a/netmap/v2/types.proto b/netmap/v2/types.proto new file mode 100644 index 00000000..2d12ea55 --- /dev/null +++ b/netmap/v2/types.proto @@ -0,0 +1,92 @@ +syntax = "proto3"; + +package netmap.v2; + +option go_package = "github.com/nspcc-dev/neofs-api-go/netmap/v2"; +option csharp_namespace = "NeoFS.API.Netmap"; + +message PlacementRule { + uint32 repl_factor = 1; + + message SFGroup { + message Filter { + string key = 1; + + message SimpleFilters { + repeated SimpleFilter filters = 1; + } + + message SimpleFilter { + enum Operation { + NP = 0; + EQ = 1; + NE = 2; + GT = 3; + GE = 4; + LT = 5; + LE = 6; + OR = 7; + AND = 8; + } + + Operation op = 1; + + oneof args { + string value = 2; + SimpleFilters f_args = 3; + } + } + + SimpleFilter f = 2; + } + + repeated Filter filters = 1; + + message Selector { + uint32 count = 1; + string key = 2; + } + + repeated Selector selectors = 2; + + repeated uint32 exclude = 3; + } + + repeated SFGroup sf_groups = 2; +} + +// Groups the information about the NeoFS node. +message NodeInfo { + // Carries network address of the NeoFS node. + string address = 1; + + // Carries public key of the NeoFS node in a binary format. + bytes public_key = 2; + + // Groups attributes of the NeoFS node. + message Attribute { + // Carries string key to the node attribute. + string key = 1; + + // Carries string value of the node attribute. + string value = 2; + } + + // Carries list of the NeoFS node attributes in a string key-value format. + repeated Attribute attributes = 3; + + // Represents the enumeration of various states of the NeoFS node. + enum State { + // Undefined state. + UNKNOWN = 0; + + // Active state in the network. + ONLINE = 1; + + // Network unavailable state. + OFFLINE = 2; + } + + // Carries state of the NeoFS node. + State state = 4; +} \ No newline at end of file diff --git a/object/v2/service.pb.go b/object/v2/service.pb.go new file mode 100644 index 00000000..ce67752e Binary files /dev/null and b/object/v2/service.pb.go differ diff --git a/object/v2/service.proto b/object/v2/service.proto new file mode 100644 index 00000000..85e6d3ef --- /dev/null +++ b/object/v2/service.proto @@ -0,0 +1,407 @@ +syntax = "proto3"; + +package object.v2; + +option go_package = "github.com/nspcc-dev/neofs-api-go/object/v2"; +option csharp_namespace = "NeoFS.API.Object"; + +import "object/v2/types.proto"; +import "refs/v2/types.proto"; +import "service/v2/meta.proto"; +import "service/v2/verify.proto"; + +// Object service provides API for manipulating with the object.v2. +service Service { + // Get the object from container.v2. Response uses gRPC stream. First response + // message carry object of requested address. Chunk messages are parts of + // the object's payload if it is needed. All messages except first carry + // chunks. Requested object can be restored by concatenation of object + // message payload and all chunks keeping receiving order. + rpc Get(GetRequest) returns (stream GetResponse); + + // Put the object into container.v2. Request uses gRPC stream. First message + // SHOULD BE type of PutHeader. Container id and Owner id of object SHOULD + // BE set. Session token SHOULD BE obtained before put operation (see + // session package). Chunk messages considered by server as part of object + // payload. All messages except first SHOULD BE chunks. Chunk messages + // SHOULD BE sent in direct order of fragmentation. + rpc Put(stream PutRequest) returns (PutResponse); + + // Delete the object from a container + rpc Delete(DeleteRequest) returns (DeleteResponse); + + // Head returns the object without data payload. Object in the + // response has system header only. If full headers flag is set, extended + // headers are also present. + rpc Head(HeadRequest) returns (HeadResponse); + + // Search objects in container.v2. Version of query language format SHOULD BE + // set to 1. Search query represented in serialized format (see query + // package). + rpc Search(SearchRequest) returns (stream SearchResponse); + + // GetRange of data payload. Range is a pair (offset, length). + // Requested range can be restored by concatenation of all chunks + // keeping receiving order. + rpc GetRange(GetRangeRequest) returns (stream GetRangeResponse); + + // GetRangeHash returns homomorphic hash of object payload range after XOR + // operation. Ranges are set of pairs (offset, length). Hashes order in + // response corresponds to ranges order in request. Homomorphic hash is + // calculated for XORed data. + rpc GetRangeHash(GetRangeHashRequest) returns (GetRangeHashResponse); +} + +message GetRequest { + message Body { + // Address of the requested object.v2. + refs.v2.Address address = 1; + + // Carries the raw option flag of the request. + // Raw request is sent to receive only the objects + // that are physically stored on the server. + bool raw = 2; + } + // Body of get object request message. + Body body = 1; + + // Carries request meta information. Header data is used only to regulate message + // transport and does not affect request execution. + service.v2.RequestMetaHeader meta_header = 2; + + // Carries request verification information. This header is used to authenticate + // the nodes of the message route and check the correctness of transmission. + service.v2.RequestVerificationHeader verify_header = 3; +} + +message GetResponse { + message Body { + // Initialization parameters of the object got from NeoFS. + message Init { + // Object ID + refs.v2.ObjectID object_id = 1; + // Object signature + service.v2.Signature signature =2; + // Object header. + Header header = 3; + } + // Carries the single message of the response stream. + oneof object_part { + // Initialization parameters of the object stream. + Init init =1; + // Part of the object payload. + bytes chunk = 2; + } + } + // Body of get object response message. + Body body = 1; + + // Carries response meta information. Header data is used only to regulate + // message transport and does not affect request execution. + service.v2.ResponseMetaHeader meta_header = 2; + + // Carries response verification information. This header is used to + // authenticate the nodes of the message route and check the correctness + // of transmission. + service.v2.ResponseVerificationHeader verify_header = 3; +} + +message PutRequest { + message Body { + // Groups initialization parameters of object placement in NeoFS. + message Init { + // Object ID, where available + refs.v2.ObjectID object_id = 1; + // Object signature, were available + service.v2.Signature signature =2; + // Header of the object to save in the system. + Header header = 3; + // Number of the object copies to store within the RPC call. + // Default zero value is processed according to the + // container placement rules. + uint32 copies_number = 4; + } + + // Carries the single part of the query stream. + oneof object_part { + // Carries the initialization parameters of the object stream. + Init init = 1; + // Carries part of the object payload. + bytes chunk = 2; + } + } + // Body of put object request message. + Body body = 1; + + // Carries request meta information. Header data is used only to regulate message + // transport and does not affect request execution. + service.v2.RequestMetaHeader meta_header = 2; + + // Carries request verification information. This header is used to authenticate + // the nodes of the message route and check the correctness of transmission. + service.v2.RequestVerificationHeader verify_header = 3; +} + +message PutResponse { + message Body { + // Carries identifier of the saved object.v2. + // It is used to access an object in the container.v2. + refs.v2.ObjectID object_id = 1; + } + // Body of put object response message. + Body body = 1; + + // Carries response meta information. Header data is used only to regulate + // message transport and does not affect request execution. + service.v2.ResponseMetaHeader meta_header = 2; + + // Carries response verification information. This header is used to + // authenticate the nodes of the message route and check the correctness + // of transmission. + service.v2.ResponseVerificationHeader verify_header = 3; +} + +message DeleteRequest { + message Body { + // Carries the address of the object to be deleted. + refs.v2.Address address = 1; + // Carries identifier the object owner. + refs.v2.OwnerID owner_id = 2; + } + // Body of delete object request message. + Body body = 1; + + // Carries request meta information. Header data is used only to regulate message + // transport and does not affect request execution. + service.v2.RequestMetaHeader meta_header = 2; + + // Carries request verification information. This header is used to authenticate + // the nodes of the message route and check the correctness of transmission. + service.v2.RequestVerificationHeader verify_header = 3; +} + +// DeleteResponse is empty because we cannot guarantee permanent object removal +// in distributed system. +message DeleteResponse { + message Body { } + + // Body of delete object response message. + Body body = 1; + + // Carries response meta information. Header data is used only to regulate + // message transport and does not affect request execution. + service.v2.ResponseMetaHeader meta_header = 2; + + // Carries response verification information. This header is used to + // authenticate the nodes of the message route and check the correctness + // of transmission. + service.v2.ResponseVerificationHeader verify_header = 3; +} + +message HeadRequest { + message Body { + // Address of the object with the requested header. + refs.v2.Address address = 1; + // Return only minimal header subset + bool main_only = 2; + // Carries the raw option flag of the request. + // Raw request is sent to receive only the headers of the objects + // that are physically stored on the server. + bool raw = 3; + } + // Body of head object request message. + Body body = 1; + + // Carries request meta information. Header data is used only to regulate message + // transport and does not affect request execution. + service.v2.RequestMetaHeader meta_header = 2; + + // Carries request verification information. This header is used to authenticate + // the nodes of the message route and check the correctness of transmission. + service.v2.RequestVerificationHeader verify_header = 3; +} + +message HeadResponse { + message Body { + message ShortHeader { + // Object format version. + service.v2.Version version = 1; + // Epoch when the object was created + uint64 creation_epoch = 2; + // Object's owner + refs.v2.OwnerID owner_id = 3; + // Type of the object payload content + ObjectType object_type = 4; + // Size of payload in bytes. + // 0xFFFFFFFFFFFFFFFF means `payload_length` is unknown + uint64 payload_length = 5; + } + // Carries the requested object header or it's part + oneof head{ + Header header = 1; + ShortHeader short_header = 2; + } + } + // Body of head object response message. + Body body = 1; + + // Carries response meta information. Header data is used only to regulate + // message transport and does not affect request execution. + service.v2.ResponseMetaHeader meta_header = 2; + + // Carries response verification information. This header is used to + // authenticate the nodes of the message route and check the correctness + // of transmission. + service.v2.ResponseVerificationHeader verify_header = 3; +} + +message SearchRequest { + message Body { + // Carries search container identifier. + refs.v2.ContainerID container_id = 1; + + message Query { + uint32 version = 1; + + message Filter { + enum MatchType { + MATCH_UNKNOWN = 0; + STRING_EQUAL = 1; + } + + MatchType match_type = 1; + + string name = 2; + + string value = 3; + } + + repeated Filter filters = 2; + } + + Query query = 2; + } + + // Body of search object request message. + Body body = 1; + + // Carries request meta information. Header data is used only to regulate message + // transport and does not affect request execution. + service.v2.RequestMetaHeader meta_header = 2; + + // Carries request verification information. This header is used to authenticate + // the nodes of the message route and check the correctness of transmission. + service.v2.RequestVerificationHeader verify_header = 3; +} + +message SearchResponse { + message Body { + // Carries list of object identifiers that match the search query. + repeated refs.v2.ObjectID id_list = 1; + } + + // Body of search object response message. + Body body = 1; + + // Carries response meta information. Header data is used only to regulate + // message transport and does not affect request execution. + service.v2.ResponseMetaHeader meta_header = 2; + + // Carries response verification information. This header is used to + // authenticate the nodes of the message route and check the correctness + // of transmission. + service.v2.ResponseVerificationHeader verify_header = 3; +} + +// Range groups the parameters of object payload range. +message Range { + // Carries the offset of the range from the object payload start. + uint64 offset = 1; + + // Carries the length of the object payload range. + uint64 length = 2; +} + +message GetRangeRequest { + message Body { + // Address carries address of the object that contains the requested payload range. + refs.v2.Address address = 1; + + // Range carries the parameters of the requested payload range. + Range range = 2; + } + + // Body of get range object request message. + Body body = 1; + + // Carries request meta information. Header data is used only to regulate message + // transport and does not affect request execution. + service.v2.RequestMetaHeader meta_header = 2; + + // Carries request verification information. This header is used to authenticate + // the nodes of the message route and check the correctness of transmission. + service.v2.RequestVerificationHeader verify_header = 3; +} + +message GetRangeResponse { + message Body { + // Carries part of the object payload. + bytes chunk = 1; + } + + // Body of get range object response message. + Body body = 1; + + // Carries response meta information. Header data is used only to regulate + // message transport and does not affect request execution. + service.v2.ResponseMetaHeader meta_header = 2; + + // Carries response verification information. This header is used to + // authenticate the nodes of the message route and check the correctness + // of transmission. + service.v2.ResponseVerificationHeader verify_header = 3; +} + +message GetRangeHashRequest { + message Body { + // Carries address of the object that contains the requested payload range. + refs.v2.Address address = 1; + + // Carries the list of object payload range to calculate homomorphic hash. + repeated Range ranges = 2; + + // Carries binary salt to XOR object payload ranges before hash calculation. + bytes salt = 3; + } + + // Body of get range hash object request message. + Body body = 1; + + // Carries request meta information. Header data is used only to regulate message + // transport and does not affect request execution. + service.v2.RequestMetaHeader meta_header = 2; + + // Carries request verification information. This header is used to authenticate + // the nodes of the message route and check the correctness of transmission. + service.v2.RequestVerificationHeader verify_header = 3; +} + +message GetRangeHashResponse { + message Body { + // Carries list of homomorphic hashes in a binary format. + repeated bytes hash_list = 1; + } + + // Body of get range hash object response message. + Body body = 1; + + // Carries response meta information. Header data is used only to regulate + // message transport and does not affect request execution. + service.v2.ResponseMetaHeader meta_header = 2; + + // Carries response verification information. This header is used to + // authenticate the nodes of the message route and check the correctness + // of transmission. + service.v2.ResponseVerificationHeader verify_header = 3; +} + diff --git a/object/v2/types.pb.go b/object/v2/types.pb.go new file mode 100644 index 00000000..bae2d04c Binary files /dev/null and b/object/v2/types.pb.go differ diff --git a/object/v2/types.proto b/object/v2/types.proto new file mode 100644 index 00000000..9462bc04 --- /dev/null +++ b/object/v2/types.proto @@ -0,0 +1,85 @@ +syntax = "proto3"; + +package object.v2; + +option go_package = "github.com/nspcc-dev/neofs-api-go/object/v2"; +option csharp_namespace = "NeoFS.API.Object"; + +import "refs/v2/types.proto"; +import "service/v2/meta.proto"; +import "service/v2/verify.proto"; + +// Type of the object payload content +enum ObjectType { + // Just a normal object + REGULAR = 0; + // Used internally to identify deleted objects + TOMBSTONE = 1; + // Identifies that the object holds StorageGroup information + STORAGE_GROUP = 2; +} + +message Header { + // Object's container + refs.v2.ContainerID container_id = 1; + // Object's owner + refs.v2.OwnerID owner_id = 2; + // Epoch when the object was created + uint64 creation_epoch = 3; + // Object format version. + // Effectively the version of API library used to create particular object + service.v2.Version version = 4; + // Size of payload in bytes. + // 0xFFFFFFFFFFFFFFFF means `payload_length` is unknown + uint64 payload_length = 5; + // Hash of payload bytes + bytes payload_hash = 6; + ObjectType object_type = 7; + // Homomorphic hash of the object payload. + bytes homomorphic_hash = 8; + // Session token, if it was used during Object creation. + // Need it to verify integrity and authenticity out of Request scope. + service.v2.SessionToken session_token = 9; + + // Attribute groups the user-defined Key-Value pairs attached to the object + message Attribute { + // string key to the object attribute + string key = 1; + // string value of the object attribute + string value = 2; + } + repeated Attribute attributes = 10; + + // Information about spawning the objects through a payload splitting. + message Split { + // Identifier of the origin object.v2. + // Parent and children objects must be within the same container.v2. + // Parent object_id is known only to the minor child. + refs.v2.ObjectID parent = 1; + // Previous carries identifier of the left split neighbor. + refs.v2.ObjectID previous = 2; + // `signature` field of the parent object.v2. Used to reconstruct parent. + service.v2.Signature parent_signature = 3; + // `header` field of the parent object.v2. Used to reconstruct parent. + Header parent_header = 4; + // Children carries list of identifiers of the objects generated by splitting the current. + repeated refs.v2.ObjectID children = 5; + } + // Position of the object in the split hierarchy. + Split split = 11; +} + +// Object structure. +message Object { + // Object's unique identifier. + // Object is content-addressed. It means id will change if header or payload + // changes. It's calculated as a hash of header field, which contains hash of + // object's payload + refs.v2.ObjectID object_id = 1; + // Signed object_id + service.v2.Signature signature = 2; + // Object metadata headers + Header header = 3; + // Payload bytes. + bytes payload = 4; +} diff --git a/refs/v2/types.pb.go b/refs/v2/types.pb.go new file mode 100644 index 00000000..c76f97c9 Binary files /dev/null and b/refs/v2/types.pb.go differ diff --git a/refs/v2/types.proto b/refs/v2/types.proto new file mode 100644 index 00000000..82049b43 --- /dev/null +++ b/refs/v2/types.proto @@ -0,0 +1,32 @@ +syntax = "proto3"; + +package refs.v2; + +option go_package = "github.com/nspcc-dev/neofs-api-go/refs/v2"; +option csharp_namespace = "NeoFS.API.Refs"; + +// Address of object (container id + object id) +message Address { + // container_id carries container identifier. + ContainerID container_id = 1; + // object_id carries object identifier. + ObjectID object_id = 2; +} + +// NeoFS object identifier. +message ObjectID { + // value carries the object identifier in a binary format. + bytes value = 1; +} + +// NeoFS container identifier. +message ContainerID { + // value carries the container identifier in a binary format. + bytes value = 1; +} + +// OwnerID group information about the owner of the NeoFS container.v2. +message OwnerID { + // value carries the identifier of the container owner in a binary format. + bytes value = 1; +} \ No newline at end of file diff --git a/service/v2/meta.pb.go b/service/v2/meta.pb.go new file mode 100644 index 00000000..34d2eb79 Binary files /dev/null and b/service/v2/meta.pb.go differ diff --git a/service/v2/meta.proto b/service/v2/meta.proto new file mode 100644 index 00000000..c1a4ddfc --- /dev/null +++ b/service/v2/meta.proto @@ -0,0 +1,129 @@ +syntax = "proto3"; + +package service.v2; + +option go_package = "github.com/nspcc-dev/neofs-api-go/service/v2"; +option csharp_namespace = "NeoFS.API.Service"; + +import "acl/v2/types.proto"; +import "refs/v2/types.proto"; +import "service/v2/verify.proto"; + +message XHeader { + // Key of the X-Header. + string key = 1; + // Value of the X-Header. + string value = 2; +} + +// Represents API version used by node. +message Version { + // Major API version. + uint32 major = 1; + // Minor API version. + uint32 minor = 2; +} + +// Lifetime parameters of the token. Filed names taken from rfc7519. +message TokenLifetime { + // Expiration Epoch + uint64 exp = 1; + // Not valid before Epoch + uint64 nbf = 2; + // Issued at Epoch + uint64 iat = 3; +} + +// NeoFS session token. +message SessionToken { + message Body { + // ID is a token identifier. valid UUIDv4 represented in bytes + bytes id = 1; + // OwnerID carries identifier of the session initiator. + refs.v2.OwnerID owner_id = 2; + // Verb is an enumeration of session request types + enum Verb { + // Refers to object.Put RPC call + OBJECT_PUT = 0; + // Refers to object.Get RPC call + OBJECT_GET = 1; + // Refers to object.Head RPC call + OBJECT_HEAD = 2; + // Refers to object.Search RPC call + OBJECT_SEARCH = 3; + // Refers to object.Delete RPC call + OBJECT_DELETE = 4; + // Refers to object.GetRange RPC call + OBJECT_RANGE = 5; + // Refers to object.GetRangeHash RPC call + OBJECT_RANGEHASH = 6; + } + // Verb is a type of request for which the token is issued + Verb verb = 3; + // Lifetime is a lifetime of the session + TokenLifetime lifetime = 4; + // SessionKey is a public key of session key + bytes session_key = 5; + // Carries context of the session. + oneof context { + // object_address represents the object session context. + refs.v2.Address object_address = 6; + } + } + // Session Token body + Body token = 1; + + // Signature is a signature of session token information + Signature signature = 2; +} + +// BearerToken has information about request ACL rules with limited lifetime +message BearerToken { + message Body { + // EACLTable carries table of extended ACL rules + acl.v2.EACLTable eacl_table = 1; + // OwnerID carries identifier of the token owner + refs.v2.OwnerID owner_id = 2; + // Token expiration and valid time period parameters + TokenLifetime lifetime = 3; + } + // Bearer Token body + Body token = 1; + + // Signature of BearerToken body + Signature signature = 2; +} + +// Information about the request +message RequestMetaHeader { + // Client API version. + Version version = 1; + // Client local epoch number. Set to 0 if unknown. + uint64 epoch = 2; + // Maximum number of nodes in the request route. + uint32 ttl = 3; + // Request X-Headers. + repeated XHeader x_headers = 4; + // Token is a token of the session within which the request is sent + SessionToken token = 5; + // Bearer is a Bearer token of the request + BearerToken bearer = 6; + + // RequestMetaHeader of the origin request. + RequestMetaHeader origin = 7; +} + +// Information about the response +message ResponseMetaHeader { + // Server API version. + Version version = 1; + // Server local epoch number. + uint64 epoch = 2; + // Maximum number of nodes in the response route. + uint32 ttl = 3; + // Response X-Headers. + repeated XHeader x_headers = 4; + + // Carries response meta header of the origin response. + ResponseMetaHeader origin = 5; +} diff --git a/service/v2/verify.pb.go b/service/v2/verify.pb.go new file mode 100644 index 00000000..6f1cd42a Binary files /dev/null and b/service/v2/verify.pb.go differ diff --git a/service/v2/verify.proto b/service/v2/verify.proto new file mode 100644 index 00000000..29338969 --- /dev/null +++ b/service/v2/verify.proto @@ -0,0 +1,43 @@ +syntax = "proto3"; + +package service.v2; + +option go_package = "github.com/nspcc-dev/neofs-api-go/service/v2"; +option csharp_namespace = "NeoFS.API.Service"; + +import "acl/v2/types.proto"; +import "refs/v2/types.proto"; + +// Signature of something in NeoFS +message Signature { + // Public key used for signing. + bytes key = 1; + // Signature + bytes sign = 2; +} + +// Verification info for request signed by all intermediate nodes +message RequestVerificationHeader { + // Request Body signature. Should be generated once by request initiator. + Signature body_signature = 1; + // Request Meta signature is added and signed by any intermediate node + Signature meta_signature = 2; + // Sign previous hops + Signature origin_signature = 3; + + // Chain of previous hops signatures + RequestVerificationHeader origin = 4; +} + +// Verification info for response signed by all intermediate nodes +message ResponseVerificationHeader { + // Response Body signature. Should be generated once by answering node. + Signature body_signature = 1; + // Response Meta signature is added and signed by any intermediate node + Signature meta_signature = 2; + // Sign previous hops + Signature origin_signature = 3; + + // Chain of previous hops signatures + ResponseVerificationHeader origin = 4; +} diff --git a/session/v2/service.pb.go b/session/v2/service.pb.go new file mode 100644 index 00000000..9d5d8af6 Binary files /dev/null and b/session/v2/service.pb.go differ diff --git a/session/v2/service.proto b/session/v2/service.proto new file mode 100644 index 00000000..c980dcf0 --- /dev/null +++ b/session/v2/service.proto @@ -0,0 +1,60 @@ +syntax = "proto3"; + +package session.v2; + +option go_package = "github.com/nspcc-dev/neofs-api-go/session/v2"; +option csharp_namespace = "NeoFS.API.Session"; + +import "refs/v2/types.proto"; +import "service/v2/meta.proto"; +import "service/v2/verify.proto"; + +service Session { + // Create opens new session between the client and the server. + rpc Create (CreateRequest) returns (CreateResponse); +} + +// CreateRequest carries an information necessary for opening a session.v2. +message CreateRequest { + message Body { + // Carries an identifier of a session initiator. + refs.v2.OwnerID owner_id = 1; + + // Carries a lifetime of the session.v2. + service.v2.TokenLifetime lifetime = 2; + } + + // Body of create session token request message. + Body body = 1; + + // Carries request meta information. Header data is used only to regulate message + // transport and does not affect request execution. + service.v2.RequestMetaHeader meta_header = 2; + + // Carries request verification information. This header is used to authenticate + // the nodes of the message route and check the correctness of transmission. + service.v2.RequestVerificationHeader verify_header = 3; +} + +// CreateResponse carries an information about the opened session.v2. +message CreateResponse { + message Body { + // id carries an identifier of session token. + bytes id = 1; + + // session_key carries a session public key. + bytes session_key = 2; + } + + // Body of create session token response message. + Body body = 1; + + // Carries response meta information. Header data is used only to regulate + // message transport and does not affect request execution. + service.v2.ResponseMetaHeader meta_header = 2; + + // Carries response verification information. This header is used to + // authenticate the nodes of the message route and check the correctness + // of transmission. + service.v2.ResponseVerificationHeader verify_header = 3; +} diff --git a/storagegroup/v2/types.pb.go b/storagegroup/v2/types.pb.go new file mode 100644 index 00000000..e0991496 Binary files /dev/null and b/storagegroup/v2/types.pb.go differ diff --git a/storagegroup/v2/types.proto b/storagegroup/v2/types.proto new file mode 100644 index 00000000..3d89a675 --- /dev/null +++ b/storagegroup/v2/types.proto @@ -0,0 +1,30 @@ +syntax = "proto3"; + +package storagegroup.v2; + +option go_package = "github.com/nspcc-dev/neofs-api-go/storagegroup/v2"; +option csharp_namespace = "NeoFS.API.StorageGroup"; + +import "refs/v2/types.proto"; + +// StorageGroup groups the information about the NeoFS storage group. +// The storage group consists of objects from single container. +message StorageGroup { + // validation_data_size carries the total size of the payloads of the storage + // group members. + uint64 validation_data_size = 1; + + // validation_hash carries homomorphic hash from the concatenation of the + // payloads of the storage group members + // The order of concatenation is the same as the order of the members in the + // Members field. + bytes validation_hash = 2; + + // expiration_epoch carries last NeoFS epoch number of the storage group + // lifetime. + uint64 expiration_epoch = 3; + + // Members carries the list of identifiers of the object storage group members. + // The list is strictly ordered. + repeated refs.v2.ObjectID members = 4; +}