Skip to content

Commit 141f160

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

5 files changed

Lines changed: 348 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
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)
1011

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

container/service.proto

Lines changed: 151 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,127 @@ 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+
569+
// Request payload.
570+
Body body = 1;
571+
572+
// Signature of stable-marshalled `body` field.
573+
neo.fs.v2.refs.Signature body_signature = 2;
574+
}
575+
576+
// Attribute removal response
577+
message RemoveAttributeResponse {
578+
// Request result message.
579+
message Body {
580+
// Operation execution status.
581+
neo.fs.v2.status.Status status = 1;
582+
}
583+
584+
// Request result.
585+
Body body = 1;
586+
587+
// Signature of stable-marshalled `body` field.
588+
neo.fs.v2.refs.Signature body_signature = 2;
589+
}

proto-docs/container.md

Lines changed: 188 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,148 @@ 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+
587+
588+
<a name="neo.fs.v2.container.RemoveAttributeRequest.Body.Parameters"></a>
589+
590+
### Message RemoveAttributeRequest.Body.Parameters
591+
Op parameters message.
592+
593+
If container does not have the `attribute`, nothing is done and status
594+
`OK` is returned.
595+
596+
`attribute` must be one of:
597+
- `CORS`;
598+
- `__NEOFS__LOCK_UNTIL`.
599+
600+
Attribute-specific requirements:
601+
- `__NEOFS__LOCK_UNTIL`: current timestamp must have already passed if any
602+
603+
604+
| Field | Type | Label | Description |
605+
| ----- | ---- | ----- | ----------- |
606+
| container_id | [neo.fs.v2.refs.ContainerID](#neo.fs.v2.refs.ContainerID) | | Identifier of the container to remove attribute from. |
607+
| attribute | [string](#string) | | Attribute to be removed. |
608+
609+
610+
<a name="neo.fs.v2.container.RemoveAttributeResponse"></a>
611+
612+
### Message RemoveAttributeResponse
613+
Attribute removal response
614+
615+
616+
| Field | Type | Label | Description |
617+
| ----- | ---- | ----- | ----------- |
618+
| body | [RemoveAttributeResponse.Body](#neo.fs.v2.container.RemoveAttributeResponse.Body) | | Request result. |
619+
| body_signature | [neo.fs.v2.refs.Signature](#neo.fs.v2.refs.Signature) | | Signature of stable-marshalled `body` field. |
620+
621+
622+
<a name="neo.fs.v2.container.RemoveAttributeResponse.Body"></a>
623+
624+
### Message RemoveAttributeResponse.Body
625+
Request result message.
626+
627+
628+
| Field | Type | Label | Description |
629+
| ----- | ---- | ----- | ----------- |
630+
| status | [neo.fs.v2.status.Status](#neo.fs.v2.status.Status) | | Operation execution status. |
631+
632+
633+
<a name="neo.fs.v2.container.SetAttributeRequest"></a>
634+
635+
### Message SetAttributeRequest
636+
Attribute setting request
637+
638+
639+
| Field | Type | Label | Description |
640+
| ----- | ---- | ----- | ----------- |
641+
| body | [SetAttributeRequest.Body](#neo.fs.v2.container.SetAttributeRequest.Body) | | Request payload. |
642+
| body_signature | [neo.fs.v2.refs.Signature](#neo.fs.v2.refs.Signature) | | Signature of stable-marshalled `body` field. |
643+
644+
645+
<a name="neo.fs.v2.container.SetAttributeRequest.Body"></a>
646+
647+
### Message SetAttributeRequest.Body
648+
Request payload message.
649+
650+
651+
| Field | Type | Label | Description |
652+
| ----- | ---- | ----- | ----------- |
653+
| parameters | [SetAttributeRequest.Body.Parameters](#neo.fs.v2.container.SetAttributeRequest.Body.Parameters) | | Op parameters. |
654+
| 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. |
655+
| 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. |
656+
657+
658+
<a name="neo.fs.v2.container.SetAttributeRequest.Body.Parameters"></a>
659+
660+
### Message SetAttributeRequest.Body.Parameters
661+
Op parameters message.
662+
663+
If container does not have the `attribute`, it is added. Otherwise, its
664+
value is swapped.
665+
666+
`attribute` must be one of:
667+
- `CORS`;
668+
- `__NEOFS__LOCK_UNTIL`.
669+
670+
In general, requirements for `value` are the same as for container
671+
creation. Attribute-specific requirements:
672+
- `__NEOFS__LOCK_UNTIL`: new timestamp must be after the current one if any
673+
674+
675+
| Field | Type | Label | Description |
676+
| ----- | ---- | ----- | ----------- |
677+
| container_id | [neo.fs.v2.refs.ContainerID](#neo.fs.v2.refs.ContainerID) | | Identifier of the container to set attribute for. |
678+
| attribute | [string](#string) | | Attribute to be set. |
679+
| value | [string](#string) | | New attribute value. |
680+
681+
682+
<a name="neo.fs.v2.container.SetAttributeResponse"></a>
683+
684+
### Message SetAttributeResponse
685+
Attribute setting response
686+
687+
688+
| Field | Type | Label | Description |
689+
| ----- | ---- | ----- | ----------- |
690+
| body | [SetAttributeResponse.Body](#neo.fs.v2.container.SetAttributeResponse.Body) | | Request result. |
691+
| body_signature | [neo.fs.v2.refs.Signature](#neo.fs.v2.refs.Signature) | | Signature of stable-marshalled `body` field. |
692+
693+
694+
<a name="neo.fs.v2.container.SetAttributeResponse.Body"></a>
695+
696+
### Message SetAttributeResponse.Body
697+
Request result message.
698+
699+
700+
| Field | Type | Label | Description |
701+
| ----- | ---- | ----- | ----------- |
702+
| status | [neo.fs.v2.status.Status](#neo.fs.v2.status.Status) | | Operation execution status. |
703+
704+
517705
<a name="neo.fs.v2.container.SetExtendedACLRequest"></a>
518706

519707
### Message SetExtendedACLRequest

0 commit comments

Comments
 (0)