Skip to content

Commit 87b95a6

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

5 files changed

Lines changed: 365 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: 156 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,132 @@ 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+
// RFC-6979 signature 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.
500+
neo.fs.v2.refs.SignatureRFC6979 signature = 2;
501+
502+
// Optional session token. The token must be issued by the container owner.
503+
// The token must have at least one subject authenticated by `signature`
504+
// field. The token must have at least one context with this container and
505+
// `CONTAINER_SETATTRIBUTE` verb.
506+
neo.fs.v2.session.SessionTokenV2 session_token = 3;
507+
}
508+
509+
// Request payload.
510+
Body body = 1;
511+
512+
// Signature of stable-marshalled `body` field.
513+
neo.fs.v2.refs.Signature body_signature = 2;
514+
}
515+
516+
// Attribute setting response
517+
message SetAttributeResponse {
518+
// Request result message.
519+
message Body {
520+
// Operation execution status.
521+
neo.fs.v2.status.Status status = 1;
522+
}
523+
524+
// Request result.
525+
Body body = 1;
526+
527+
// Signature of stable-marshalled `body` field.
528+
neo.fs.v2.refs.Signature body_signature = 2;
529+
}
530+
531+
// Attribute removal request
532+
message RemoveAttributeRequest {
533+
// Request payload message.
534+
message Body {
535+
// Op parameters message.
536+
//
537+
// If container does not have the `attribute`, nothing is done and status
538+
// `OK` is returned.
539+
//
540+
// `attribute` must be one of:
541+
// - `CORS`;
542+
// - `__NEOFS__LOCK_UNTIL`.
543+
//
544+
// Attribute-specific requirements:
545+
// - `__NEOFS__LOCK_UNTIL`: current timestamp must have already passed if any
546+
message Parameters {
547+
// Identifier of the container to remove attribute from.
548+
neo.fs.v2.refs.ContainerID container_id = 1;
549+
550+
// Attribute to be removed.
551+
string attribute = 2;
552+
}
553+
554+
// Op parameters.
555+
Parameters parameters = 1;
556+
557+
// RFC-6979 signature of stable-marshalled `parameters` field. The
558+
// signature must authenticate either container owner or one of subjects in
559+
// the `session_token` field if any.
560+
neo.fs.v2.refs.SignatureRFC6979 signature = 2;
561+
562+
// Optional session token. The token must be issued by the container owner.
563+
// The token must have at least one subject authenticated by `signature`
564+
// field. The token must have at least one context with this container and
565+
// `CONTAINER_REMOVEATTRIBUTE` verb.
566+
neo.fs.v2.session.SessionTokenV2 session_token = 3;
567+
568+
// Optional session token (V1). It must not be set together with
569+
// `session_token` field that is highly recommended to be used instead.
570+
// Requirements are the same for both.
571+
neo.fs.v2.session.SessionToken session_token_v1 = 4;
572+
}
573+
574+
// Request payload.
575+
Body body = 1;
576+
577+
// Signature of stable-marshalled `body` field.
578+
neo.fs.v2.refs.Signature body_signature = 2;
579+
}
580+
581+
// Attribute removal response
582+
message RemoveAttributeResponse {
583+
// Request result message.
584+
message Body {
585+
// Operation execution status.
586+
neo.fs.v2.status.Status status = 1;
587+
}
588+
589+
// Request result.
590+
Body body = 1;
591+
592+
// Signature of stable-marshalled `body` field.
593+
neo.fs.v2.refs.Signature body_signature = 2;
594+
}

proto-docs/container.md

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@
3333
- [PutRequest.Body](#neo.fs.v2.container.PutRequest.Body)
3434
- [PutResponse](#neo.fs.v2.container.PutResponse)
3535
- [PutResponse.Body](#neo.fs.v2.container.PutResponse.Body)
36+
- [RemoveAttributeRequest](#neo.fs.v2.container.RemoveAttributeRequest)
37+
- [RemoveAttributeRequest.Body](#neo.fs.v2.container.RemoveAttributeRequest.Body)
38+
- [RemoveAttributeRequest.Body.Parameters](#neo.fs.v2.container.RemoveAttributeRequest.Body.Parameters)
39+
- [RemoveAttributeResponse](#neo.fs.v2.container.RemoveAttributeResponse)
40+
- [RemoveAttributeResponse.Body](#neo.fs.v2.container.RemoveAttributeResponse.Body)
41+
- [SetAttributeRequest](#neo.fs.v2.container.SetAttributeRequest)
42+
- [SetAttributeRequest.Body](#neo.fs.v2.container.SetAttributeRequest.Body)
43+
- [SetAttributeRequest.Body.Parameters](#neo.fs.v2.container.SetAttributeRequest.Body.Parameters)
44+
- [SetAttributeResponse](#neo.fs.v2.container.SetAttributeResponse)
45+
- [SetAttributeResponse.Body](#neo.fs.v2.container.SetAttributeResponse.Body)
3646
- [SetExtendedACLRequest](#neo.fs.v2.container.SetExtendedACLRequest)
3747
- [SetExtendedACLRequest.Body](#neo.fs.v2.container.SetExtendedACLRequest.Body)
3848
- [SetExtendedACLResponse](#neo.fs.v2.container.SetExtendedACLResponse)
@@ -74,6 +84,8 @@ rpc List(ListRequest) returns (ListResponse);
7484
rpc SetExtendedACL(SetExtendedACLRequest) returns (SetExtendedACLResponse);
7585
rpc GetExtendedACL(GetExtendedACLRequest) returns (GetExtendedACLResponse);
7686
rpc AnnounceUsedSpace(AnnounceUsedSpaceRequest) returns (AnnounceUsedSpaceResponse);
87+
rpc SetAttribute(SetAttributeRequest) returns (SetAttributeResponse);
88+
rpc RemoveAttribute(RemoveAttributeRequest) returns (RemoveAttributeResponse);
7789
7890
```
7991

@@ -191,6 +203,40 @@ contract.
191203
| Name | Input | Output |
192204
| ---- | ----- | ------ |
193205
| AnnounceUsedSpace | [AnnounceUsedSpaceRequest](#neo.fs.v2.container.AnnounceUsedSpaceRequest) | [AnnounceUsedSpaceResponse](#neo.fs.v2.container.AnnounceUsedSpaceResponse) |
206+
#### Method SetAttribute
207+
208+
Sends transaction calling contract method to set container attribute, and
209+
waits for the transaction to be executed. Deadline is determined by the
210+
transport protocol (e.g. `grpc-timeout` header). If the deadline is not
211+
set, server waits 15s after submitting the transaction.
212+
213+
Statuses:
214+
- **OK** (0, SECTION_SUCCESS): \
215+
attribute successfully set;
216+
- Common failures (SECTION_FAILURE_COMMON);
217+
- **CONTAINER_AWAIT_TIMEOUT** (3075, SECTION_CONTAINER): \
218+
transaction was sent but not executed within the deadline.
219+
220+
| Name | Input | Output |
221+
| ---- | ----- | ------ |
222+
| SetAttribute | [SetAttributeRequest](#neo.fs.v2.container.SetAttributeRequest) | [SetAttributeResponse](#neo.fs.v2.container.SetAttributeResponse) |
223+
#### Method RemoveAttribute
224+
225+
Sends transaction calling contract method to remove container attribute,
226+
and waits for the transaction to be executed. Deadline is determined by
227+
the transport protocol (e.g. `grpc-timeout` header). If the deadline is
228+
not set, server waits 15s after submitting the transaction.
229+
230+
Statuses:
231+
- **OK** (0, SECTION_SUCCESS): \
232+
attribute successfully removed;
233+
- Common failures (SECTION_FAILURE_COMMON);
234+
- **CONTAINER_AWAIT_TIMEOUT** (3075, SECTION_CONTAINER): \
235+
transaction was sent but not executed within the deadline.
236+
237+
| Name | Input | Output |
238+
| ---- | ----- | ------ |
239+
| RemoveAttribute | [RemoveAttributeRequest](#neo.fs.v2.container.RemoveAttributeRequest) | [RemoveAttributeResponse](#neo.fs.v2.container.RemoveAttributeResponse) |
194240
<!-- end services -->
195241

196242

@@ -514,6 +560,149 @@ returned here to make sure everything has been done as expected.
514560
| container_id | [neo.fs.v2.refs.ContainerID](#neo.fs.v2.refs.ContainerID) | | Unique identifier of the newly created container |
515561

516562

563+
<a name="neo.fs.v2.container.RemoveAttributeRequest"></a>
564+
565+
### Message RemoveAttributeRequest
566+
Attribute removal request
567+
568+
569+
| Field | Type | Label | Description |
570+
| ----- | ---- | ----- | ----------- |
571+
| body | [RemoveAttributeRequest.Body](#neo.fs.v2.container.RemoveAttributeRequest.Body) | | Request payload. |
572+
| body_signature | [neo.fs.v2.refs.Signature](#neo.fs.v2.refs.Signature) | | Signature of stable-marshalled `body` field. |
573+
574+
575+
<a name="neo.fs.v2.container.RemoveAttributeRequest.Body"></a>
576+
577+
### Message RemoveAttributeRequest.Body
578+
Request payload message.
579+
580+
581+
| Field | Type | Label | Description |
582+
| ----- | ---- | ----- | ----------- |
583+
| parameters | [RemoveAttributeRequest.Body.Parameters](#neo.fs.v2.container.RemoveAttributeRequest.Body.Parameters) | | Op parameters. |
584+
| signature | [neo.fs.v2.refs.SignatureRFC6979](#neo.fs.v2.refs.SignatureRFC6979) | | RFC-6979 signature of stable-marshalled `parameters` field. The signature must authenticate either container owner or one of subjects in the `session_token` field if any. |
585+
| session_token | [neo.fs.v2.session.SessionTokenV2](#neo.fs.v2.session.SessionTokenV2) | | Optional session token. The token must be issued by the container owner. The token must have at least one subject authenticated by `signature` field. The token must have at least one context with this container and `CONTAINER_REMOVEATTRIBUTE` verb. |
586+
| session_token_v1 | [neo.fs.v2.session.SessionToken](#neo.fs.v2.session.SessionToken) | | Optional session token (V1). It must not be set together with `session_token` field that is highly recommended to be used instead. Requirements are the same for both. |
587+
588+
589+
<a name="neo.fs.v2.container.RemoveAttributeRequest.Body.Parameters"></a>
590+
591+
### Message RemoveAttributeRequest.Body.Parameters
592+
Op parameters message.
593+
594+
If container does not have the `attribute`, nothing is done and status
595+
`OK` is returned.
596+
597+
`attribute` must be one of:
598+
- `CORS`;
599+
- `__NEOFS__LOCK_UNTIL`.
600+
601+
Attribute-specific requirements:
602+
- `__NEOFS__LOCK_UNTIL`: current timestamp must have already passed if any
603+
604+
605+
| Field | Type | Label | Description |
606+
| ----- | ---- | ----- | ----------- |
607+
| container_id | [neo.fs.v2.refs.ContainerID](#neo.fs.v2.refs.ContainerID) | | Identifier of the container to remove attribute from. |
608+
| attribute | [string](#string) | | Attribute to be removed. |
609+
610+
611+
<a name="neo.fs.v2.container.RemoveAttributeResponse"></a>
612+
613+
### Message RemoveAttributeResponse
614+
Attribute removal response
615+
616+
617+
| Field | Type | Label | Description |
618+
| ----- | ---- | ----- | ----------- |
619+
| body | [RemoveAttributeResponse.Body](#neo.fs.v2.container.RemoveAttributeResponse.Body) | | Request result. |
620+
| body_signature | [neo.fs.v2.refs.Signature](#neo.fs.v2.refs.Signature) | | Signature of stable-marshalled `body` field. |
621+
622+
623+
<a name="neo.fs.v2.container.RemoveAttributeResponse.Body"></a>
624+
625+
### Message RemoveAttributeResponse.Body
626+
Request result message.
627+
628+
629+
| Field | Type | Label | Description |
630+
| ----- | ---- | ----- | ----------- |
631+
| status | [neo.fs.v2.status.Status](#neo.fs.v2.status.Status) | | Operation execution status. |
632+
633+
634+
<a name="neo.fs.v2.container.SetAttributeRequest"></a>
635+
636+
### Message SetAttributeRequest
637+
Attribute setting request
638+
639+
640+
| Field | Type | Label | Description |
641+
| ----- | ---- | ----- | ----------- |
642+
| body | [SetAttributeRequest.Body](#neo.fs.v2.container.SetAttributeRequest.Body) | | Request payload. |
643+
| body_signature | [neo.fs.v2.refs.Signature](#neo.fs.v2.refs.Signature) | | Signature of stable-marshalled `body` field. |
644+
645+
646+
<a name="neo.fs.v2.container.SetAttributeRequest.Body"></a>
647+
648+
### Message SetAttributeRequest.Body
649+
Request payload message.
650+
651+
652+
| Field | Type | Label | Description |
653+
| ----- | ---- | ----- | ----------- |
654+
| parameters | [SetAttributeRequest.Body.Parameters](#neo.fs.v2.container.SetAttributeRequest.Body.Parameters) | | Op parameters. |
655+
| signature | [neo.fs.v2.refs.SignatureRFC6979](#neo.fs.v2.refs.SignatureRFC6979) | | RFC-6979 signature of stable-marshalled `parameters` field. The signature must authenticate either container owner or one of subjects in the `session_token` field if any. |
656+
| session_token | [neo.fs.v2.session.SessionTokenV2](#neo.fs.v2.session.SessionTokenV2) | | Optional session token. The token must be issued by the container owner. The token must have at least one subject authenticated by `signature` field. The token must have at least one context with this container and `CONTAINER_SETATTRIBUTE` verb. |
657+
658+
659+
<a name="neo.fs.v2.container.SetAttributeRequest.Body.Parameters"></a>
660+
661+
### Message SetAttributeRequest.Body.Parameters
662+
Op parameters message.
663+
664+
If container does not have the `attribute`, it is added. Otherwise, its
665+
value is swapped.
666+
667+
`attribute` must be one of:
668+
- `CORS`;
669+
- `__NEOFS__LOCK_UNTIL`.
670+
671+
In general, requirements for `value` are the same as for container
672+
creation. Attribute-specific requirements:
673+
- `__NEOFS__LOCK_UNTIL`: new timestamp must be after the current one if any
674+
675+
676+
| Field | Type | Label | Description |
677+
| ----- | ---- | ----- | ----------- |
678+
| container_id | [neo.fs.v2.refs.ContainerID](#neo.fs.v2.refs.ContainerID) | | Identifier of the container to set attribute for. |
679+
| attribute | [string](#string) | | Attribute to be set. |
680+
| value | [string](#string) | | New attribute value. |
681+
682+
683+
<a name="neo.fs.v2.container.SetAttributeResponse"></a>
684+
685+
### Message SetAttributeResponse
686+
Attribute setting response
687+
688+
689+
| Field | Type | Label | Description |
690+
| ----- | ---- | ----- | ----------- |
691+
| body | [SetAttributeResponse.Body](#neo.fs.v2.container.SetAttributeResponse.Body) | | Request result. |
692+
| body_signature | [neo.fs.v2.refs.Signature](#neo.fs.v2.refs.Signature) | | Signature of stable-marshalled `body` field. |
693+
694+
695+
<a name="neo.fs.v2.container.SetAttributeResponse.Body"></a>
696+
697+
### Message SetAttributeResponse.Body
698+
Request result message.
699+
700+
701+
| Field | Type | Label | Description |
702+
| ----- | ---- | ----- | ----------- |
703+
| status | [neo.fs.v2.status.Status](#neo.fs.v2.status.Status) | | Operation execution status. |
704+
705+
517706
<a name="neo.fs.v2.container.SetExtendedACLRequest"></a>
518707

519708
### Message SetExtendedACLRequest

0 commit comments

Comments
 (0)