Skip to content

Commit 146097b

Browse files
committed
container: Provide API for attribute management
Closes #360. Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
1 parent 3759d4d commit 146097b

5 files changed

Lines changed: 373 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
- Container `__NEOFS__LOCK_UNTIL` attribute (#357)
88
- `CONTAINER_LOCKED` status (#357)
99
- `CONTAINER_AWAIT_TIMEOUT` status (#358)
10+
- `SetAttribute` and `RemoveAttribute` RPC to `ContainerService` (#362)
11+
- `SETATTRIBUTE` and `REMOVEATTRIBUTE` verbs for container sessions V1 (#362)
1012

1113
### Changed
1214
- `ContainerService`'s `Put`, `Delete` and `SetExtendedACL` RPC are async/await now (#358)

container/service.proto

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import "acl/types.proto";
66
import "container/types.proto";
77
import "refs/types.proto";
88
import "session/types.proto";
9+
import "status/types.proto";
910

1011
option csharp_namespace = "Neo.FileStorage.API.Container";
1112
option go_package = "github.com/nspcc-dev/neofs-sdk-go/proto/container";
@@ -100,6 +101,32 @@ service ContainerService {
100101
// DEPRECATED: every storage node must send storage load directly to `container`
101102
// contract.
102103
rpc AnnounceUsedSpace(AnnounceUsedSpaceRequest) returns (AnnounceUsedSpaceResponse);
104+
105+
// Sends transaction calling contract method to set container attribute, and
106+
// waits for the transaction to be executed. Deadline is determined by the
107+
// transport protocol (e.g. `grpc-timeout` header). If the deadline is not
108+
// set, server waits 15s after submitting the transaction.
109+
//
110+
// Statuses:
111+
// - **OK** (0, SECTION_SUCCESS): \
112+
// attribute successfully set;
113+
// - Common failures (SECTION_FAILURE_COMMON);
114+
// - **CONTAINER_AWAIT_TIMEOUT** (3075, SECTION_CONTAINER): \
115+
// transaction was sent but not executed within the deadline.
116+
rpc SetAttribute(SetAttributeRequest) returns (SetAttributeResponse);
117+
118+
// Sends transaction calling contract method to remove container attribute,
119+
// and waits for the transaction to be executed. Deadline is determined by
120+
// the transport protocol (e.g. `grpc-timeout` header). If the deadline is
121+
// not set, server waits 15s after submitting the transaction.
122+
//
123+
// Statuses:
124+
// - **OK** (0, SECTION_SUCCESS): \
125+
// attribute successfully removed;
126+
// - Common failures (SECTION_FAILURE_COMMON);
127+
// - **CONTAINER_AWAIT_TIMEOUT** (3075, SECTION_CONTAINER): \
128+
// transaction was sent but not executed within the deadline.
129+
rpc RemoveAttribute(RemoveAttributeRequest) returns (RemoveAttributeResponse);
103130
}
104131

105132
// New NeoFS Container creation request
@@ -436,3 +463,139 @@ message AnnounceUsedSpaceResponse {
436463
// transmission.
437464
neo.fs.v2.session.ResponseVerificationHeader verify_header = 3;
438465
}
466+
467+
// Attribute setting request
468+
message SetAttributeRequest {
469+
// Request payload message.
470+
message Body {
471+
// Op parameters message.
472+
//
473+
// If container does not have the `attribute`, it is added. Otherwise, its
474+
// value is swapped.
475+
//
476+
// `attribute` must be one of:
477+
// - `CORS`;
478+
// - `__NEOFS__LOCK_UNTIL`.
479+
//
480+
// In general, requirements for `value` are the same as for container
481+
// creation. Attribute-specific requirements:
482+
// - `__NEOFS__LOCK_UNTIL`: new timestamp must be after the current one if any
483+
message Parameters {
484+
// Identifier of the container to set attribute for.
485+
neo.fs.v2.refs.ContainerID container_id = 1;
486+
487+
// Attribute to be set.
488+
string attribute = 2;
489+
490+
// New attribute value.
491+
string value = 3;
492+
}
493+
494+
// Op parameters.
495+
Parameters parameters = 1;
496+
497+
// N3 witness of stable-marshalled `parameters` field. The
498+
// signature must authenticate either container owner or one of subjects in
499+
// the `session_token` field if any. Signature according to
500+
// `ECDSA_RFC6979_SHA256` scheme is also supported.
501+
neo.fs.v2.refs.SignatureRFC6979 signature = 2;
502+
503+
// Optional session token. The token must be issued by the container owner.
504+
// The token must have at least one subject authenticated by `signature`
505+
// field. The token must have at least one context with this container and
506+
// `CONTAINER_SETATTRIBUTE` verb.
507+
neo.fs.v2.session.SessionTokenV2 session_token = 3;
508+
509+
// Optional session token (V1). It must not be set together with
510+
// `session_token` field that is highly recommended to be used instead.
511+
// Requirements are the same for both.
512+
neo.fs.v2.session.SessionToken session_token_v1 = 4;
513+
}
514+
515+
// Request payload.
516+
Body body = 1;
517+
518+
// Signature of stable-marshalled `body` field.
519+
neo.fs.v2.refs.Signature body_signature = 2;
520+
}
521+
522+
// Attribute setting response
523+
message SetAttributeResponse {
524+
// Request result message.
525+
message Body {
526+
// Operation execution status.
527+
neo.fs.v2.status.Status status = 1;
528+
}
529+
530+
// Request result.
531+
Body body = 1;
532+
533+
// Signature of stable-marshalled `body` field.
534+
neo.fs.v2.refs.Signature body_signature = 2;
535+
}
536+
537+
// Attribute removal request
538+
message RemoveAttributeRequest {
539+
// Request payload message.
540+
message Body {
541+
// Op parameters message.
542+
//
543+
// If container does not have the `attribute`, nothing is done and status
544+
// `OK` is returned.
545+
//
546+
// `attribute` must be one of:
547+
// - `CORS`;
548+
// - `__NEOFS__LOCK_UNTIL`.
549+
//
550+
// Attribute-specific requirements:
551+
// - `__NEOFS__LOCK_UNTIL`: current timestamp must have already passed if any
552+
message Parameters {
553+
// Identifier of the container to remove attribute from.
554+
neo.fs.v2.refs.ContainerID container_id = 1;
555+
556+
// Attribute to be removed.
557+
string attribute = 2;
558+
}
559+
560+
// Op parameters.
561+
Parameters parameters = 1;
562+
563+
// N3 witness of stable-marshalled `parameters` field. The
564+
// signature must authenticate either container owner or one of subjects in
565+
// the `session_token` field if any. Signature according to
566+
// `ECDSA_RFC6979_SHA256` scheme is also supported.
567+
neo.fs.v2.refs.SignatureRFC6979 signature = 2;
568+
569+
// Optional session token. The token must be issued by the container owner.
570+
// The token must have at least one subject authenticated by `signature`
571+
// field. The token must have at least one context with this container and
572+
// `CONTAINER_REMOVEATTRIBUTE` verb.
573+
neo.fs.v2.session.SessionTokenV2 session_token = 3;
574+
575+
// Optional session token (V1). It must not be set together with
576+
// `session_token` field that is highly recommended to be used instead.
577+
// Requirements are the same for both.
578+
neo.fs.v2.session.SessionToken session_token_v1 = 4;
579+
}
580+
581+
// Request payload.
582+
Body body = 1;
583+
584+
// Signature of stable-marshalled `body` field.
585+
neo.fs.v2.refs.Signature body_signature = 2;
586+
}
587+
588+
// Attribute removal response
589+
message RemoveAttributeResponse {
590+
// Request result message.
591+
message Body {
592+
// Operation execution status.
593+
neo.fs.v2.status.Status status = 1;
594+
}
595+
596+
// Request result.
597+
Body body = 1;
598+
599+
// Signature of stable-marshalled `body` field.
600+
neo.fs.v2.refs.Signature body_signature = 2;
601+
}

0 commit comments

Comments
 (0)