Commit graph

255 commits

Author SHA1 Message Date
Leonard Lyubich
5844096017 [#288] pkg/eacl: Convert nil eACL target to nil API v2 message
Make `Target.ToV2` method to return `nil` when called on `nil`. Write
corresponding unit test.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-05-28 09:37:21 +03:00
Leonard Lyubich
8f27d857fa [#288] pkg/eacl: Document default values set in NewFilter
Document field values of instance constructed via `NewFilter`. Assert the
values in corresponding unit test.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-05-28 09:37:21 +03:00
Leonard Lyubich
89cb2f6e71 [#288] pkg/eacl: Convert nil eACL filter to nil message
Make `Filter.ToV2` method to return `nil` when called on `nil`. Write
corresponding unit test.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-05-28 09:37:21 +03:00
Leonard Lyubich
25de451a2f [#283] client/container: Write new fields to eACL table in GetEACL
Call `SetSessionToken` and `SetSignature` methods on resulting eACL table
with items from response body. From now eACL signature can be accessed from
the table itself, so `EACLWithSignature.Signature` is marked deprecated.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-05-26 12:24:58 +03:00
Leonard Lyubich
ad6b5aa8a9 [#283] client/container: Attach container session token to request
Write session token of `container.Container` to container SetExtendedACL
request body inside `client.SetEACL` call.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-05-26 12:24:58 +03:00
Leonard Lyubich
396210409d [#283] client/container: Write new fields to container in GetContainer
Call `SetSessionToken` and `SetSignature` methods on resulting container
with items from response body.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-05-26 12:24:58 +03:00
Leonard Lyubich
ddccfe0072 [#283] client/container: Attach container session token to request
Write session token of `container.Container` to container PUT request body
during `client.PutContainer` call.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-05-26 12:24:58 +03:00
Leonard Lyubich
0719fcef59 [#283] pkg/container: Add session token and signature to Table
Extended ACL table can be set within a session, and should be signed.

Add `SessionToken` / `SetSessionToken` (`Signature` / `SetSignature`)
methods to carry session token (signature) in `Table` structure.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-05-26 12:24:58 +03:00
Leonard Lyubich
37b415347d [#283] pkg/token: Replace SessionToken into a session package
There is a need to add session token to `eacl.Table` structure. To do this,
we need to replace `token.SessionToken` type to another package since `eacl`
package imports `token` one (potential cross-import).

Create `pkg/session` package and replace session token implementation to it.
Related API in `container` package is deprecated from now.

Additionally implement test generator of random session tokens.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-05-26 12:24:58 +03:00
Leonard Lyubich
fcbe0bbd2e [#283] pkg/container: Add session token and signature to Container
Container can be created within a session, and should be signed.

Add `SessionToken` / `SetSessionToken` (`Signature` / `SetSignature`)
methods to carry session token (signature) in `Container` structure.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-05-26 12:24:58 +03:00
Leonard Lyubich
f60f7e0cdb [#283] pkg/eacl: Remove usage of deprecated container ID from src files
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-05-26 12:24:58 +03:00
Leonard Lyubich
7314038069 [#283] pkg/container: Define ID in a separate package
In order to prevent potential cross imports, container ID should be defined
in a separate package as a base type. A similar approach was used in the
NeoFS API design.

Create `pkg/container/id` package and replace container ID implementation to
it. Related API in `container` package is deprecated from now.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-05-26 12:24:58 +03:00
Pavel Karpy
2ebb91cb4c [#286] client: Delete useless raw client init
Since raw client initialization is
postponed until the first `Raw()` function
call, there is no need to init empty(
without options) raw client in constructor.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2021-05-24 16:56:59 +03:00
Pavel Karpy
89aede1fb3 [#286] client: Add TLS options
Add `WithTLSConfig` option to client.
If it is not nil then client will
try to open secured connection.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2021-05-24 16:56:59 +03:00
Evgenii Stratonikov
9ddfcdfbba [#277] go.mod: remove pkg/errors
Use stdlib `errors` instead.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2021-05-19 11:14:56 +03:00
Alex Vanin
2e9db28f1c Bump version in pkg
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2021-05-07 15:11:18 +03:00
Alex Vanin
099347d3bc Synchronize namings with NeoFS API v2.6.0
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2021-05-07 15:11:18 +03:00
Leonard Lyubich
fcb2cce8a0 [#278] pkg/client: Fix payload slice allocation in Object Range method
Allocate capacity instead of length of the slice to write the object payload
range since each chunk is written through `append`.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-04-30 11:15:35 +03:00
Pavel Karpy
0f7a14a69f [#274] pkg/client: Add epoch field to SendIntermediateTrustPrm
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2021-04-22 13:37:07 +03:00
Alex Vanin
5a507e0d1b [#273] Add go1.16 tests and fix linter error
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2021-04-16 16:32:14 +03:00
Leonard Lyubich
8128d598d0 [#265] pkg/client: Change trust type in SendIntermediateTrustPrm
Change accepted/returned value type of `SetTrust` / `Trust` methods of
`SendIntermediateTrustPrm` structure to `reputation.PeerToPeerTrust`.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-04-09 11:57:42 +03:00
Leonard Lyubich
a61c15b990 [#265] pkg/reputation: Implement PeerToPeerTrust structure
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-04-09 11:57:42 +03:00
Leonard Lyubich
771f395d9d [#265] pkg/reputation: Implement GlobalTrust type
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-04-02 15:57:59 +03:00
Leonard Lyubich
05a351d344 [#265] pkg/reputation: Change PeerID implementation
Make `PeerID` type to be the wrapper over v2 `PeerID` message structure.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-04-02 15:57:59 +03:00
Leonard Lyubich
c5000a3334 [#265] pkg/client: Extend Client with SendIntermediateTrust method
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-04-02 15:57:59 +03:00
Leonard Lyubich
b792e4e464 [#265] pkg/client: Implement SendLocalTrust method
Define `Reputation` section interface. Embed `Reputation` interface to
`Client` one.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-03-25 11:20:34 +03:00
Leonard Lyubich
009f704377 [#265] pkg/reputation: Implement PeerID and Trust types
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-03-25 11:20:34 +03:00
Leonard Lyubich
2fcb6d9613 [#267] pkg: Fix IsSupportedVersion implementation
Current API library supports versions up to 2.4.x.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-03-17 14:30:02 +03:00
Leonard Lyubich
7cb9b8f283 [#267] pkg/client: Extend Client interface with Raw method
Add `Client.Raw` method which returns underlying raw protobuf client.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-03-17 14:30:02 +03:00
Leonard Lyubich
a43175e2ea [#263] pkg/client: Split interface method's declarations with linebreaks
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-03-17 14:03:49 +03:00
Leonard Lyubich
c819909906 [#263] pkg/client: Refactor the client to use raw protobuf client
Make `Client` to be the wrapper over raw protobuf client. Provide public
method to get the underlying raw client. Change implementations of all
methods with the new approach of the RPC execution.

Additional changes:
 * key replaced from `New` argument to `WithDefaultPrivateKey` option;
 * `GetSelfBalance` is removed as non-viable;
 * `GetEACLWithSignature` is removed, `GetEACL` returns `EACLWithSignature`;
 * `AttachSessionToken` / `AttachBearerToken` are removed as non-viable;
 * redundant options are removed.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-03-17 14:03:49 +03:00
Leonard Lyubich
5a9dd7ab3f [#263] pkg/netmap: Do not allocate nil repeated fields during conversion
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-03-17 14:03:49 +03:00
Evgenii Stratonikov
ae2fb263f1 [#266] pkg/client: Export Client interface instead of structure
Make it easier to test API clients and mock specific methods.
Also add comments on exported methods.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2021-03-17 13:43:22 +03:00
Alex Vanin
e39a1fd949 pkg/object: Add content type constant
Specification defined one more well-known object
attribute `Content-Type`.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2021-03-15 13:27:28 +03:00
Evgenii Stratonikov
64505180b4 [#261] pkg/client: Provide signing key in call options
Allow to reuse underlying connection for requests
with different key. If no key is specified the one
provided on client creation is used.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2021-03-12 10:40:10 +03:00
Evgenii Stratonikov
74769323be [#261] pkg/client: Use self address as default in ListContainers/GetBalance
This will allow us to overwrite key for every request.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2021-03-12 10:40:10 +03:00
Leonard Lyubich
8529aa2a93 [#259] pkg/client: Add NetworkInfo method
Implement NetworkInfo method that performs NeoFS API NetmapService
NetworkInfo RPC.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-02-19 16:25:53 +03:00
Leonard Lyubich
f6268339d0 [#259] pkg/netmap: Implement v2-compatible NetworkInfo type
Define NetworkInfo structure. Implement constructors, fields getters and
setters, binary and JSON encoding methods.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-02-19 16:25:53 +03:00
Leonard Lyubich
521df90def [#255] pkg/netmap: Define constant keys to all well-known attributes
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-02-11 15:04:13 +03:00
Leonard Lyubich
8254da2890 [#255] pkg/netmap: Move common substring of well-known attributes to prefix
Rename `PriceAttr` constant to `AttrPrice`. Rename `CapacityAttr` constant
to `AttrCapacity`. Add documentation to both of them.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-02-11 15:04:13 +03:00
Leonard Lyubich
e782531f25 [#255] pkg/object: Implement json.Marshaler/Unmarshaler on SearchFilters
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-02-11 15:04:13 +03:00
Leonard Lyubich
ebff07aaf2 [#254] object: Support new values of search match type
Support STRING_NOT_EQUAL and NOT_PRESENT match types
of object search filters.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-02-11 15:04:13 +03:00
Leonard Lyubich
e9ae408c3a [#254] pkg/object: Rewrite unit test of MatchType enum
Avoid direct usage of naming constants where it is not necessary.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-02-11 15:04:13 +03:00
Leonard Lyubich
93e1580684 [#253] container: Implement marshalers on UsedSpaceAnnouncement structure
Implement Unmarshal method on UsedSpaceAnnouncement v2 message. Implement
Marshal/Unmarshal methods on cross-version UsedSpaceAnnouncement type.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-02-11 15:04:13 +03:00
Alex Vanin
9e01f29dda [#250] pkg/container: Add epoch field to size announce body
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2021-02-11 15:04:13 +03:00
Alex Vanin
5566081d2d [#245] pkg/client: Add AnnounceContainerUsedSpace method
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2021-02-11 15:04:13 +03:00
Evgenii Stratonikov
5d9ef5feec [#248] netmap: fulfill backup factor for default attribute
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2021-02-03 15:31:18 +03:00
Alex Vanin
c35e15a758 [#249] pkg/netmap: Add CBF field in placement context
If CBF value is not set, then netmap package uses default CBF
value. However it modifies placement policy structure in
`GetContainerNodes()` because policy passed as a pointer.

Instead package can store CBF value in internal context and use
it without policy modification.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2021-01-27 15:47:06 +03:00
Alex Vanin
9401724b9c [#246] pkg/client: Use io.Reader wrapper at object put
Object payload transferred in chunks. Size of the
chunks may be limited by transport protocols. To
split it we use `io.CopyBuffer` with pre-allocated
buffer size of one chunk. However this function may
ignore buffer if reader or writer implements
`WriteTo` or `ReadFrom` methods. Unfortunately
`bytes.Reader` implements `WriteTo` function.

To fix this we wrap reader so wrapper implements
only `io.Reader` interface.

Related to github.com/nspcc-dev/neofs-node/issues/338

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2021-01-25 13:25:52 +03:00
Alex Vanin
8a82400451 [#243] Fix golint linter errors
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2021-01-12 18:22:07 +03:00