client

package
v1.0.0-rc.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2023 License: Apache-2.0 Imports: 34 Imported by: 43

Documentation

Overview

Package client provides NeoFS API client implementation.

The main component is Client type. It is a virtual connection to the network and provides methods for executing operations on the server.

Example (CustomService)

Consume custom service of the server.

package main

import (
	rpcClient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
	"github.com/nspcc-dev/neofs-api-go/v2/rpc/common"
	"github.com/nspcc-dev/neofs-api-go/v2/rpc/grpc"
	"github.com/nspcc-dev/neofs-sdk-go/client"
)

type CustomRPCRequest struct {
}

type CustomRPCResponse struct {
}

func (a *CustomRPCRequest) ToGRPCMessage() grpc.Message {
	return nil
}

func (a *CustomRPCRequest) FromGRPCMessage(grpc.Message) error {
	return nil
}

func (a *CustomRPCResponse) ToGRPCMessage() grpc.Message {
	return nil
}

func (a *CustomRPCResponse) FromGRPCMessage(grpc.Message) error {
	return nil
}

func main() {
	// syntax = "proto3";
	//
	// service CustomService {
	// 	rpc CustomRPC(CustomRPCRequest) returns (CustomRPCResponse);
	// }

	// import "github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
	// import "github.com/nspcc-dev/neofs-api-go/v2/rpc/common"

	var prmInit client.PrmInit
	// ...

	c, _ := client.New(prmInit)

	req := &CustomRPCRequest{}
	resp := &CustomRPCResponse{}

	err := c.ExecRaw(func(c *rpcClient.Client) error {
		return rpcClient.SendUnary(c, common.CallMethodInfo{
			Service: "CustomService",
			Name:    "CustomRPC",
		}, req, resp)
	})

	_ = err

	// ...

	// Close the connection
	_ = c.Close()

	// Note that it's not allowed to override Client behaviour directly: the parameters
	// for the all operations are write-only and the results of the all operations are
	// read-only. To be able to override client behavior (e.g. for tests), abstract it
	// with an interface:
	//
	// import "github.com/nspcc-dev/neofs-sdk-go/client"
	//
	// type NeoFSClient interface {
	// // Operations according to the application needs
	// CreateContainer(context.Context, container.Container) error
	// // ...
	// }
	//
	// type client struct {
	// 	c *client.Client
	// }
	//
	// func (x *client) CreateContainer(context.Context, container.Container) error {
	// // ...
	// }
}
Output:

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingServer is returned when server endpoint is empty in parameters.
	ErrMissingServer = errors.New("server address is unset or empty")
	// ErrNonPositiveTimeout is returned when any timeout is below zero in parameters.
	ErrNonPositiveTimeout = errors.New("non-positive timeout")

	// ErrMissingAccount is returned when account/owner is not provided.
	ErrMissingAccount = errors.New("missing account")
	// ErrMissingSigner is returned when signer is not provided.
	ErrMissingSigner = errors.New("missing signer")
	// ErrMissingEACLContainer is returned when container info is not provided in eACL table.
	ErrMissingEACLContainer = errors.New("missing container in eACL table")
	// ErrMissingAnnouncements is returned when announcements are not provided.
	ErrMissingAnnouncements = errors.New("missing announcements")
	// ErrZeroRangeLength is returned when range parameter has zero length.
	ErrZeroRangeLength = errors.New("zero range length")
	// ErrMissingRanges is returned when empty ranges list is provided.
	ErrMissingRanges = errors.New("missing ranges")
	// ErrZeroEpoch is returned when zero epoch is provided.
	ErrZeroEpoch = errors.New("zero epoch")
	// ErrMissingTrusts is returned when empty slice of trusts is provided.
	ErrMissingTrusts = errors.New("missing trusts")

	// ErrUnexpectedReadCall is returned when we already got all data but truing to get more.
	ErrUnexpectedReadCall = errors.New("unexpected call to `Read`")

	// ErrSign is returned when unable to sign service message.
	ErrSign SignError

	// ErrMissingResponseField is returned when required field is not exists in NeoFS api response.
	ErrMissingResponseField MissingResponseFieldErr
)
View Source
var (

	// ErrNoSession indicates that session wasn't set in some Prm* structure.
	ErrNoSession = errors.New("session is not set")
)
View Source
var (
	// ErrNoSessionExplicitly is a special error to show auto-session is disabled.
	ErrNoSessionExplicitly = errors.New("session was removed explicitly")
)

Functions

func SyncContainerWithNetwork

func SyncContainerWithNetwork(ctx context.Context, cnr *container.Container, c NetworkInfoExecutor) error

SyncContainerWithNetwork requests network configuration using passed NetworkInfoExecutor and applies/rewrites it to the container.

Returns any network/parsing config errors.

See also client.Client.NetworkInfo, [container.Container.ApplyNetworkConfig].

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents virtual connection to the NeoFS network to communicate with NeoFS server using NeoFS API protocol. It is designed to provide an abstraction interface from the protocol details of data transfer over a network in NeoFS.

Client can be created using New. Before executing the NeoFS operations using the Client, connection to the server MUST BE correctly established (see Dial method and pay attention to the mandatory parameters). Using the Client before connecting have been established can lead to a panic. After the work, the Client SHOULD BE closed (see Close method): it frees internal and system resources which were allocated for the period of work of the Client. Calling Client.Dial/Client.Close method during the communication process step strongly discouraged as it leads to undefined behavior.

Each method which produces a NeoFS API call may return a server response. Status responses are returned in the result structure, and can be cast to built-in error instance (or in the returned error if the client is configured accordingly). Certain statuses can be checked using apistatus and standard errors packages. All possible responses are documented in methods, however, some may be returned from all of them (pay attention to the presence of the pointer sign):

Client MUST NOT be copied by value: use pointer to Client instead.

See client package overview to get some examples.

Example (CreateInstance)
package main

import (
	"time"

	"github.com/nspcc-dev/neofs-sdk-go/client"
)

func main() {
	// Create client instance
	var prm client.PrmInit
	c, err := client.New(prm)
	_ = err

	// Connect to the NeoFS server
	var prmDial client.PrmDial
	prmDial.SetServerURI("grpc://localhost:8080") // endpoint address
	prmDial.SetTimeout(15 * time.Second)
	prmDial.SetStreamTimeout(15 * time.Second)

	_ = c.Dial(prmDial)
}
Output:

func New

func New(prm PrmInit) (*Client, error)

New creates an instance of Client initialized with the given parameters.

See docs of PrmInit methods for details. See also Client.Dial/Client.Close.

func (*Client) AnnounceIntermediateTrust

func (c *Client) AnnounceIntermediateTrust(ctx context.Context, epoch uint64, trust reputation.PeerToPeerTrust, prm PrmAnnounceIntermediateTrust) error

AnnounceIntermediateTrust sends global trust values calculated for the specified NeoFS network participants at some stage of client's calculation algorithm.

Any errors (local or remote, including returned status codes) are returned as Go errors, see apistatus package for NeoFS-specific error types.

Context is required and must not be nil. It is used for network communication.

Return errors:

Parameter epoch must not be zero.

func (*Client) AnnounceLocalTrust

func (c *Client) AnnounceLocalTrust(ctx context.Context, epoch uint64, trusts []reputation.Trust, prm PrmAnnounceLocalTrust) error

AnnounceLocalTrust sends client's trust values to the NeoFS network participants.

Any errors (local or remote, including returned status codes) are returned as Go errors, see apistatus package for NeoFS-specific error types.

Context is required and must not be nil. It is used for network communication.

Return errors:

Parameter epoch must not be zero. Parameter trusts must not be empty.

func (*Client) BalanceGet

func (c *Client) BalanceGet(ctx context.Context, prm PrmBalanceGet) (accounting.Decimal, error)

BalanceGet requests current balance of the NeoFS account.

Any errors (local or remote, including returned status codes) are returned as Go errors, see apistatus package for NeoFS-specific error types.

Context is required and must not be nil. It is used for network communication.

Return errors:

func (*Client) Close

func (c *Client) Close() error

Close closes underlying connection to the NeoFS server. Implements io.Closer. MUST NOT be called before successful Dial. Can be called concurrently with server operations processing on running goroutines: in this case they are likely to fail due to a connection error.

One-time method call during application shutdown stage (after Client.Dial) is expected. Calling multiple times leads to undefined behavior.

See also Client.Dial.

func (*Client) ContainerAnnounceUsedSpace

func (c *Client) ContainerAnnounceUsedSpace(ctx context.Context, announcements []container.SizeEstimation, prm PrmAnnounceSpace) error

ContainerAnnounceUsedSpace sends request to announce volume of the space used for the container objects.

Any errors (local or remote, including returned status codes) are returned as Go errors, see apistatus package for NeoFS-specific error types.

Operation is asynchronous and no guaranteed even in the absence of errors. The required time is also not predictable.

At this moment success can not be checked.

Context is required and must not be nil. It is used for network communication.

Announcements parameter MUST NOT be empty slice.

Return errors:

func (*Client) ContainerDelete

func (c *Client) ContainerDelete(ctx context.Context, id cid.ID, signer neofscrypto.Signer, prm PrmContainerDelete) error

ContainerDelete sends request to remove the NeoFS container.

Any errors (local or remote, including returned status codes) are returned as Go errors, see apistatus package for NeoFS-specific error types.

Operation is asynchronous and no guaranteed even in the absence of errors. The required time is also not predictable.

Success can be verified by reading by identifier (see GetContainer).

Context is required and must not be nil. It is used for network communication.

Signer is required and must not be nil. The account corresponding to the specified Signer will be charged for the operation. Signer's scheme MUST be neofscrypto.ECDSA_DETERMINISTIC_SHA256. For example, you can use neofsecdsa.SignerRFC6979.

Reflects all internal errors in second return value (transport problems, response processing, etc.). Return errors:

func (*Client) ContainerEACL

func (c *Client) ContainerEACL(ctx context.Context, id cid.ID, prm PrmContainerEACL) (eacl.Table, error)

ContainerEACL reads eACL table of the NeoFS container.

Any errors (local or remote, including returned status codes) are returned as Go errors, see apistatus package for NeoFS-specific error types.

Context is required and must not be nil. It is used for network communication.

func (*Client) ContainerGet

func (c *Client) ContainerGet(ctx context.Context, id cid.ID, prm PrmContainerGet) (container.Container, error)

ContainerGet reads NeoFS container by ID.

Any errors (local or remote, including returned status codes) are returned as Go errors, see apistatus package for NeoFS-specific error types.

Context is required and must not be nil. It is used for network communication.

func (*Client) ContainerList

func (c *Client) ContainerList(ctx context.Context, ownerID user.ID, prm PrmContainerList) ([]cid.ID, error)

ContainerList requests identifiers of the account-owned containers.

Any errors (local or remote, including returned status codes) are returned as Go errors, see apistatus package for NeoFS-specific error types.

Context is required and must not be nil. It is used for network communication.

func (*Client) ContainerPut

func (c *Client) ContainerPut(ctx context.Context, cont container.Container, signer neofscrypto.Signer, prm PrmContainerPut) (cid.ID, error)

ContainerPut sends request to save container in NeoFS.

Any errors (local or remote, including returned status codes) are returned as Go errors, see apistatus package for NeoFS-specific error types.

Operation is asynchronous and no guaranteed even in the absence of errors. The required time is also not predictable.

Success can be verified by reading Client.ContainerGet using the returned identifier (notice that it needs some time to succeed).

Context is required and must not be nil. It is used for network communication.

Signer is required and must not be nil. The account corresponding to the specified Signer will be charged for the operation. Signer's scheme MUST be neofscrypto.ECDSA_DETERMINISTIC_SHA256. For example, you can use neofsecdsa.SignerRFC6979.

Return errors:

Example

Put a new container into NeoFS.

package main

import (
	"context"
	"fmt"
	"time"

	"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
	netmapv2 "github.com/nspcc-dev/neofs-api-go/v2/netmap"
	"github.com/nspcc-dev/neofs-sdk-go/client"
	"github.com/nspcc-dev/neofs-sdk-go/container"
	"github.com/nspcc-dev/neofs-sdk-go/container/acl"

	cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
	"github.com/nspcc-dev/neofs-sdk-go/netmap"
	"github.com/nspcc-dev/neofs-sdk-go/user"
	"github.com/nspcc-dev/neofs-sdk-go/waiter"
)

func main() {
	ctx := context.Background()
	var accountID user.ID

	// The account was taken from https://github.com/nspcc-dev/neofs-aio
	key, err := keys.NEP2Decrypt("6PYM8VdX2BSm7BSXKzV4Fz6S3R9cDLLWNrD9nMjxW352jEv3fsC8N3wNLY", "one", keys.NEP2ScryptParams())
	if err != nil {
		panic(err)
	}

	signer := user.NewAutoIDSignerRFC6979(key.PrivateKey)
	// take account from user's signer
	accountID = signer.UserID()

	// prepare client
	var prmInit client.PrmInit

	c, err := client.New(prmInit)
	if err != nil {
		panic(fmt.Errorf("New: %w", err))
	}

	// connect to NeoFS gateway
	var prmDial client.PrmDial
	prmDial.SetServerURI("grpc://localhost:8080") // endpoint address
	prmDial.SetTimeout(15 * time.Second)
	prmDial.SetStreamTimeout(15 * time.Second)

	if err = c.Dial(prmDial); err != nil {
		panic(fmt.Errorf("dial %v", err))
	}

	// describe new container
	cont := container.Container{}
	// set version and nonce
	cont.Init()
	cont.SetOwner(accountID)
	cont.SetBasicACL(acl.PublicRW)

	// set reserved attributes
	cont.SetName("name-1")
	cont.SetCreationTime(time.Now().UTC())

	// init placement policy
	var containerID cid.ID
	var placementPolicyV2 netmapv2.PlacementPolicy
	var replicas []netmapv2.Replica

	replica := netmapv2.Replica{}
	replica.SetCount(1)
	replicas = append(replicas, replica)
	placementPolicyV2.SetReplicas(replicas)

	var placementPolicy netmap.PlacementPolicy
	if err = placementPolicy.ReadFromV2(placementPolicyV2); err != nil {
		panic(fmt.Errorf("ReadFromV2 %w", err))
	}

	placementPolicy.SetContainerBackupFactor(1)
	cont.SetPlacementPolicy(placementPolicy)

	w := waiter.NewContainerPutWaiter(c, waiter.DefaultPollInterval)

	// waiter creates the container and waits until it will be created or context canceled.
	containerID, err = w.ContainerPut(ctx, cont, signer, client.PrmContainerPut{})
	if err != nil {
		panic(fmt.Errorf("ContainerPut %w", err))
	}

	// containerID already exists
	fmt.Println(containerID)
	// example output: 76wa5UNiT8gk8Q5rdCVCV4pKuZSmYsifh6g84BcL6Hqs

	contRes, err := c.ContainerGet(ctx, containerID, client.PrmContainerGet{})
	if err != nil {
		panic(fmt.Errorf("ContainerGet %w", err))
	}

	jsonData, err := contRes.MarshalJSON()
	if err != nil {
		panic(fmt.Errorf("MarshalJSON %w", err))
	}

	fmt.Println(string(jsonData))
	// example output: {"version":{"major":2,"minor":13},"ownerID":{"value":"Ne6eoiwn40vQFI/EEI4I906PUEiy8ZXKcw=="},"nonce":"rPVd/iw2RW6Q6d66FVnIqg==","basicACL":532660223,"attributes":[{"key":"Name","value":"name-1"},{"key":"Timestamp","value":"1681738627"}],"placementPolicy":{"replicas":[{"count":1,"selector":""}],"containerBackupFactor":1,"selectors":[],"filters":[],"subnetId":{"value":0}}}
}
Output:

func (*Client) ContainerSetEACL

func (c *Client) ContainerSetEACL(ctx context.Context, table eacl.Table, signer user.Signer, prm PrmContainerSetEACL) error

ContainerSetEACL sends request to update eACL table of the NeoFS container.

Any errors (local or remote, including returned status codes) are returned as Go errors, see apistatus package for NeoFS-specific error types.

Operation is asynchronous and no guaranteed even in the absence of errors. The required time is also not predictable.

Success can be verified by reading by identifier (see EACL).

Signer is required and must not be nil. The account corresponding to the specified Signer will be charged for the operation. Signer's scheme MUST be neofscrypto.ECDSA_DETERMINISTIC_SHA256. For example, you can use neofsecdsa.SignerRFC6979.

Return errors:

Context is required and must not be nil. It is used for network communication.

func (*Client) Dial

func (c *Client) Dial(prm PrmDial) error

Dial establishes a connection to the server from the NeoFS network. Returns an error describing failure reason. If failed, the Client SHOULD NOT be used.

Uses the context specified by SetContext if it was called with non-nil argument, otherwise context.Background() is used. Dial returns context errors, see context package docs for details.

Panics if required parameters are set incorrectly, look carefully at the method documentation.

One-time method call during application start-up stage is expected. Calling multiple times leads to undefined behavior.

Return client errors:

See also Client.Close.

func (*Client) EndpointInfo

func (c *Client) EndpointInfo(ctx context.Context, prm PrmEndpointInfo) (*ResEndpointInfo, error)

EndpointInfo requests information about the storage node served on the remote endpoint.

Method can be used as a health check to see if node is alive and responds to requests.

Any client's internal or transport errors are returned as `error`, see apistatus package for NeoFS-specific error types.

Context is required and must not be nil. It is used for network communication.

Exactly one return value is non-nil. Server status return is returned in ResEndpointInfo. Reflects all internal errors in second return value (transport problems, response processing, etc.).

func (*Client) ExecRaw

func (c *Client) ExecRaw(f func(client *client.Client) error) error

ExecRaw executes f with underlying github.com/nspcc-dev/neofs-api-go/v2/rpc/client.Client instance. Communicate over the Protocol Buffers protocol in a more flexible way: most often used to transmit data over a fixed version of the NeoFS protocol, as well as to support custom services.

The f must not manipulate the client connection passed into it.

Like all other operations, must be called after connecting to the server and before closing the connection.

See also Dial and Close. See also github.com/nspcc-dev/neofs-api-go/v2/rpc/client package docs.

func (*Client) NetMapSnapshot

func (c *Client) NetMapSnapshot(ctx context.Context, _ PrmNetMapSnapshot) (netmap.NetMap, error)

NetMapSnapshot requests current network view of the remote server.

Any client's internal or transport errors are returned as `error`, see apistatus package for NeoFS-specific error types.

Context is required and MUST NOT be nil. It is used for network communication.

Reflects all internal errors in second return value (transport problems, response processing, etc.).

func (*Client) NetworkInfo

func (c *Client) NetworkInfo(ctx context.Context, prm PrmNetworkInfo) (netmap.NetworkInfo, error)

NetworkInfo requests information about the NeoFS network of which the remote server is a part.

Any client's internal or transport errors are returned as `error`, see apistatus package for NeoFS-specific error types.

Context is required and must not be nil. It is used for network communication.

Reflects all internal errors in second return value (transport problems, response processing, etc.).

func (*Client) ObjectDelete

func (c *Client) ObjectDelete(ctx context.Context, containerID cid.ID, objectID oid.ID, signer user.Signer, prm PrmObjectDelete) (oid.ID, error)

ObjectDelete marks an object for deletion from the container using NeoFS API protocol. As a marker, a special unit called a tombstone is placed in the container. It confirms the user's intent to delete the object, and is itself a container object. Explicit deletion is done asynchronously, and is generally not guaranteed.

Any client's internal or transport errors are returned as `error`, see apistatus package for NeoFS-specific error types.

Context is required and must not be nil. It is used for network communication.

Signer is required and must not be nil. The operation is executed on behalf of the account corresponding to the specified Signer, which is taken into account, in particular, for access control.

Return errors:

func (*Client) ObjectGetInit

func (c *Client) ObjectGetInit(ctx context.Context, containerID cid.ID, objectID oid.ID, signer user.Signer, prm PrmObjectGet) (object.Object, *PayloadReader, error)

ObjectGetInit initiates reading an object through a remote server using NeoFS API protocol. Returns header of the requested object and stream of its payload separately.

Exactly one return value is non-nil. Resulting PayloadReader must be finally closed.

Context is required and must not be nil. It is used for network communication.

Signer is required and must not be nil. The operation is executed on behalf of the account corresponding to the specified Signer, which is taken into account, in particular, for access control.

Return errors:

func (*Client) ObjectHash

func (c *Client) ObjectHash(ctx context.Context, containerID cid.ID, objectID oid.ID, signer user.Signer, prm PrmObjectHash) ([][]byte, error)

ObjectHash requests checksum of the range list of the object payload using NeoFS API protocol.

Returns a list of checksums in raw form: the format of hashes and their number is left for the caller to check. Client preserves the order of the server's response.

Exactly one return value is non-nil. By default, server status is returned in res structure. Any client's internal or transport errors are returned as `error`, see apistatus package for NeoFS-specific error types.

Context is required and must not be nil. It is used for network communication.

Signer is required and must not be nil. The operation is executed on behalf of the account corresponding to the specified Signer, which is taken into account, in particular, for access control.

Return errors:

func (*Client) ObjectHead

func (c *Client) ObjectHead(ctx context.Context, containerID cid.ID, objectID oid.ID, signer user.Signer, prm PrmObjectHead) (*object.Object, error)

ObjectHead reads object header through a remote server using NeoFS API protocol.

Exactly one return value is non-nil. By default, server status is returned in res structure. Any client's internal or transport errors are returned as `error`, see apistatus package for NeoFS-specific error types.

Context is required and must not be nil. It is used for network communication.

Signer is required and must not be nil. The operation is executed on behalf of the account corresponding to the specified Signer, which is taken into account, in particular, for access control.

Return errors:

func (*Client) ObjectPutInit

func (c *Client) ObjectPutInit(ctx context.Context, hdr object.Object, signer user.Signer, prm PrmObjectPutInit) (ObjectWriter, error)

ObjectPutInit initiates writing an object through a remote server using NeoFS API protocol.

The call only opens the transmission channel, explicit recording is done using the ObjectWriter. Exactly one return value is non-nil. Resulting writer must be finally closed.

Context is required and must not be nil. It will be used for network communication for the whole object transmission, including put init (this method) and subsequent object payload writes via ObjectWriter.

Signer is required and must not be nil. The operation is executed on behalf of the account corresponding to the specified Signer, which is taken into account, in particular, for access control.

Returns errors:

func (*Client) ObjectRangeInit

func (c *Client) ObjectRangeInit(ctx context.Context, containerID cid.ID, objectID oid.ID, offset, length uint64, signer user.Signer, prm PrmObjectRange) (*ObjectRangeReader, error)

ObjectRangeInit initiates reading an object's payload range through a remote server using NeoFS API protocol.

The call only opens the transmission channel, explicit fetching is done using the ObjectRangeReader. Exactly one return value is non-nil. Resulting reader must be finally closed.

Context is required and must not be nil. It is used for network communication.

Signer is required and must not be nil. The operation is executed on behalf of the account corresponding to the specified Signer, which is taken into account, in particular, for access control.

Return errors:

func (*Client) ObjectSearchInit

func (c *Client) ObjectSearchInit(ctx context.Context, containerID cid.ID, signer user.Signer, prm PrmObjectSearch) (*ObjectListReader, error)

ObjectSearchInit initiates object selection through a remote server using NeoFS API protocol.

The call only opens the transmission channel, explicit fetching of matched objects is done using the ObjectListReader. Exactly one return value is non-nil. Resulting reader must be finally closed.

Context is required and must not be nil. It is used for network communication.

Signer is required and must not be nil. The operation is executed on behalf of the account corresponding to the specified Signer, which is taken into account, in particular, for access control.

Return errors:

func (*Client) SessionCreate

func (c *Client) SessionCreate(ctx context.Context, signer user.Signer, prm PrmSessionCreate) (*ResSessionCreate, error)

SessionCreate opens a session with the node server on the remote endpoint. The session lifetime coincides with the server lifetime. Results can be written to session token which can be later attached to the requests.

Any errors (local or remote, including returned status codes) are returned as Go errors, see apistatus package for NeoFS-specific error types.

Context is required and must not be nil. It is used for network communication.

Signer is required and must not be nil. The account will be used as owner of new session.

Return errors:

Example

Session created for the one node, and it will work only for this node. Other nodes don't have info about this session. That is why session can't be created with Pool API.

package main

import (
	"context"
	"crypto/ecdsa"
	"crypto/elliptic"
	"crypto/rand"

	"github.com/google/uuid"
	"github.com/nspcc-dev/neofs-sdk-go/client"

	cid "github.com/nspcc-dev/neofs-sdk-go/container/id"

	neofsecdsa "github.com/nspcc-dev/neofs-sdk-go/crypto/ecdsa"
	"github.com/nspcc-dev/neofs-sdk-go/session"
	"github.com/nspcc-dev/neofs-sdk-go/user"
)

func main() {
	// import "github.com/google/uuid"

	var prmInit client.PrmInit
	// ...
	c, _ := client.New(prmInit)

	// Epoch when session will expire.
	// Note that expiration starts since exp+1 epoch.
	// For instance, now you have 8 epoch. You set exp=10. The session will be still valid during 10th epoch.
	// Expiration starts since 11 epoch.
	var exp uint64
	var prm client.PrmSessionCreate
	prm.SetExp(exp)

	// The key is generated to simplify the example, in reality it's likely to come from configuration/wallet.
	pk, _ := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
	signer := user.NewAutoIDSignerRFC6979(*pk)

	res, _ := c.SessionCreate(context.Background(), signer, prm)

	var id uuid.UUID
	_ = id.UnmarshalBinary(res.ID())

	// Public key for separate private key, which was created inside node for this session.
	var key neofsecdsa.PublicKey
	_ = key.Decode(res.PublicKey())

	// Fill session parameters
	var sessionObject session.Object
	sessionObject.SetID(id)
	sessionObject.SetAuthKey(&key)
	sessionObject.SetExp(exp)

	// Attach verb and container. Session allows to do just one action by time. In this example it is a VerbObjectPut.
	// If you need Get, Delete, etc you should create another session.
	sessionObject.ForVerb(session.VerbObjectPut)
	// Session works only with one container.
	sessionObject.BindContainer(cid.ID{})

	// Finally, token must be signed by container owner or someone who allowed to do the Verb action. In our example
	// it is VerbObjectPut.
	_ = sessionObject.Sign(signer)

	// ...

	// This token will be used in object put operation
	var prmPut client.PrmObjectPutInit
	prmPut.WithinSession(sessionObject)
	// ...
}
Output:

type DefaultObjectWriter

type DefaultObjectWriter struct {
	// contains filtered or unexported fields
}

DefaultObjectWriter implements ObjectWriter.

Must be initialized using Client.ObjectPutInit, any other usage is unsafe.

func (*DefaultObjectWriter) Close

func (x *DefaultObjectWriter) Close() error

Close ends writing the object and returns the result of the operation along with the final results. Must be called after using the DefaultObjectWriter.

Exactly one return value is non-nil. By default, server status is returned in res structure. Any client's internal or transport errors are returned as Go built-in error. If Client is tuned to resolve NeoFS API statuses, then NeoFS failures codes are returned as error.

Return errors:

func (*DefaultObjectWriter) GetResult

func (x *DefaultObjectWriter) GetResult() ResObjectPut

GetResult returns the put operation result.

func (*DefaultObjectWriter) Write

func (x *DefaultObjectWriter) Write(chunk []byte) (n int, err error)

WritePayloadChunk writes chunk of the object payload. Result means success. Failure reason can be received via DefaultObjectWriter.Close.

type MissingResponseFieldErr

type MissingResponseFieldErr struct {
	// contains filtered or unexported fields
}

MissingResponseFieldErr contains field name which should be in NeoFS API response.

func (MissingResponseFieldErr) Error

func (e MissingResponseFieldErr) Error() string

Error implements the error interface.

func (MissingResponseFieldErr) Is

func (e MissingResponseFieldErr) Is(target error) bool

Is implements interface for correct checking current error type with errors.Is.

type NetworkInfoExecutor

type NetworkInfoExecutor interface {
	NetworkInfo(ctx context.Context, prm PrmNetworkInfo) (netmap.NetworkInfo, error)
}

NetworkInfoExecutor describes methods to get network information.

type ObjectListReader

type ObjectListReader struct {
	// contains filtered or unexported fields
}

ObjectListReader is designed to read list of object identifiers from NeoFS system.

Must be initialized using Client.ObjectSearch, any other usage is unsafe.

func (*ObjectListReader) Close

func (x *ObjectListReader) Close() error

Close ends reading list of the matched objects and returns the result of the operation along with the final results. Must be called after using the ObjectListReader.

Any client's internal or transport errors are returned as Go built-in error. If Client is tuned to resolve NeoFS API statuses, then NeoFS failures codes are returned as error.

Return errors:

func (*ObjectListReader) Iterate

func (x *ObjectListReader) Iterate(f func(oid.ID) bool) error

Iterate iterates over the list of found object identifiers. f can return true to stop iteration earlier.

Returns an error if object can't be read.

func (*ObjectListReader) Read

func (x *ObjectListReader) Read(buf []oid.ID) (int, error)

Read reads another list of the object identifiers. Works similar to io.Reader.Read but copies oid.ID.

Failure reason can be received via Close.

Panics if buf has zero length.

type ObjectRangeReader

type ObjectRangeReader struct {
	// contains filtered or unexported fields
}

ObjectRangeReader is designed to read payload range of one object from NeoFS system. Implements io.ReadCloser.

Must be initialized using Client.ObjectRangeInit, any other usage is unsafe.

func (*ObjectRangeReader) Close

func (x *ObjectRangeReader) Close() error

Close ends reading the payload range and returns the result of the operation along with the final results. Must be called after using the ObjectRangeReader.

Any client's internal or transport errors are returned as Go built-in error. If Client is tuned to resolve NeoFS API statuses, then NeoFS failures codes are returned as error.

Return errors:

func (*ObjectRangeReader) Read

func (x *ObjectRangeReader) Read(p []byte) (int, error)

Read implements io.Reader of the object payload.

type ObjectWriter

type ObjectWriter interface {
	io.WriteCloser
	GetResult() ResObjectPut
}

ObjectWriter is designed to write one object to NeoFS system.

type PayloadReader

type PayloadReader struct {
	// contains filtered or unexported fields
}

PayloadReader is a data stream of the particular NeoFS object. Implements io.ReadCloser.

Must be initialized using Client.ObjectGetInit, any other usage is unsafe.

func (*PayloadReader) Close

func (x *PayloadReader) Close() error

Close ends reading the object payload. Must be called after using the PayloadReader.

func (*PayloadReader) Read

func (x *PayloadReader) Read(p []byte) (int, error)

Read implements io.Reader of the object payload.

type PrmAnnounceIntermediateTrust

type PrmAnnounceIntermediateTrust struct {
	// contains filtered or unexported fields
}

PrmAnnounceIntermediateTrust groups optional parameters of AnnounceIntermediateTrust operation.

func (*PrmAnnounceIntermediateTrust) SetIteration

func (x *PrmAnnounceIntermediateTrust) SetIteration(iter uint32)

SetIteration sets current sequence number of the client's calculation algorithm. By default, corresponds to initial (zero) iteration.

func (*PrmAnnounceIntermediateTrust) WithXHeaders

func (x *PrmAnnounceIntermediateTrust) WithXHeaders(hs ...string)

WithXHeaders specifies list of extended headers (string key-value pairs) to be attached to the request. Must have an even length.

Slice must not be mutated until the operation completes.

type PrmAnnounceLocalTrust

type PrmAnnounceLocalTrust struct {
	// contains filtered or unexported fields
}

PrmAnnounceLocalTrust groups optional parameters of AnnounceLocalTrust operation.

func (*PrmAnnounceLocalTrust) WithXHeaders

func (x *PrmAnnounceLocalTrust) WithXHeaders(hs ...string)

WithXHeaders specifies list of extended headers (string key-value pairs) to be attached to the request. Must have an even length.

Slice must not be mutated until the operation completes.

type PrmAnnounceSpace

type PrmAnnounceSpace struct {
	// contains filtered or unexported fields
}

PrmAnnounceSpace groups optional parameters of ContainerAnnounceUsedSpace operation.

func (*PrmAnnounceSpace) WithXHeaders

func (x *PrmAnnounceSpace) WithXHeaders(hs ...string)

WithXHeaders specifies list of extended headers (string key-value pairs) to be attached to the request. Must have an even length.

Slice must not be mutated until the operation completes.

type PrmBalanceGet

type PrmBalanceGet struct {
	// contains filtered or unexported fields
}

PrmBalanceGet groups parameters of BalanceGet operation.

func (*PrmBalanceGet) SetAccount

func (x *PrmBalanceGet) SetAccount(id user.ID)

SetAccount sets identifier of the NeoFS account for which the balance is requested. Required parameter.

func (*PrmBalanceGet) WithXHeaders

func (x *PrmBalanceGet) WithXHeaders(hs ...string)

WithXHeaders specifies list of extended headers (string key-value pairs) to be attached to the request. Must have an even length.

Slice must not be mutated until the operation completes.

type PrmContainerDelete

type PrmContainerDelete struct {
	// contains filtered or unexported fields
}

PrmContainerDelete groups optional parameters of ContainerDelete operation.

func (*PrmContainerDelete) WithXHeaders

func (x *PrmContainerDelete) WithXHeaders(hs ...string)

WithXHeaders specifies list of extended headers (string key-value pairs) to be attached to the request. Must have an even length.

Slice must not be mutated until the operation completes.

func (*PrmContainerDelete) WithinSession

func (x *PrmContainerDelete) WithinSession(tok session.Container)

WithinSession specifies session within which container should be removed.

Creator of the session acquires the authorship of the request. This may affect the execution of an operation (e.g. access control).

Must be signed.

type PrmContainerEACL

type PrmContainerEACL struct {
	// contains filtered or unexported fields
}

PrmContainerEACL groups optional parameters of ContainerEACL operation.

func (*PrmContainerEACL) WithXHeaders

func (x *PrmContainerEACL) WithXHeaders(hs ...string)

WithXHeaders specifies list of extended headers (string key-value pairs) to be attached to the request. Must have an even length.

Slice must not be mutated until the operation completes.

type PrmContainerGet

type PrmContainerGet struct {
	// contains filtered or unexported fields
}

PrmContainerGet groups optional parameters of ContainerGet operation.

func (*PrmContainerGet) WithXHeaders

func (x *PrmContainerGet) WithXHeaders(hs ...string)

WithXHeaders specifies list of extended headers (string key-value pairs) to be attached to the request. Must have an even length.

Slice must not be mutated until the operation completes.

type PrmContainerList

type PrmContainerList struct {
	// contains filtered or unexported fields
}

PrmContainerList groups optional parameters of ContainerList operation.

func (*PrmContainerList) WithXHeaders

func (x *PrmContainerList) WithXHeaders(hs ...string)

WithXHeaders specifies list of extended headers (string key-value pairs) to be attached to the request. Must have an even length.

Slice must not be mutated until the operation completes.

type PrmContainerPut

type PrmContainerPut struct {
	// contains filtered or unexported fields
}

PrmContainerPut groups optional parameters of ContainerPut operation.

func (*PrmContainerPut) WithXHeaders

func (x *PrmContainerPut) WithXHeaders(hs ...string)

WithXHeaders specifies list of extended headers (string key-value pairs) to be attached to the request. Must have an even length.

Slice must not be mutated until the operation completes.

func (*PrmContainerPut) WithinSession

func (x *PrmContainerPut) WithinSession(s session.Container)

WithinSession specifies session within which container should be saved.

Creator of the session acquires the authorship of the request. This affects the execution of an operation (e.g. access control).

Session is optional, if set the following requirements apply:

  • session operation MUST be session.VerbContainerPut (ForVerb)
  • token MUST be signed using private signer of the owner of the container to be saved

type PrmContainerSetEACL

type PrmContainerSetEACL struct {
	// contains filtered or unexported fields
}

PrmContainerSetEACL groups optional parameters of ContainerSetEACL operation.

func (*PrmContainerSetEACL) WithXHeaders

func (x *PrmContainerSetEACL) WithXHeaders(hs ...string)

WithXHeaders specifies list of extended headers (string key-value pairs) to be attached to the request. Must have an even length.

Slice must not be mutated until the operation completes.

func (*PrmContainerSetEACL) WithinSession

func (x *PrmContainerSetEACL) WithinSession(s session.Container)

WithinSession specifies session within which extended ACL of the container should be saved.

Creator of the session acquires the authorship of the request. This affects the execution of an operation (e.g. access control).

Session is optional, if set the following requirements apply:

  • if particular container is specified (ApplyOnlyTo), it MUST equal the container for which extended ACL is going to be set
  • session operation MUST be session.VerbContainerSetEACL (ForVerb)
  • token MUST be signed using private signer of the owner of the container to be saved

type PrmDial

type PrmDial struct {
	// contains filtered or unexported fields
}

PrmDial groups connection parameters for the Client.

See also Dial.

func (*PrmDial) SetContext

func (x *PrmDial) SetContext(ctx context.Context)

SetContext allows to specify optional base context within which connection should be established.

Context SHOULD NOT be nil.

func (*PrmDial) SetServerURI

func (x *PrmDial) SetServerURI(endpoint string)

SetServerURI sets server URI in the NeoFS network. Required parameter.

Format of the URI:

[scheme://]host:port

Supported schemes:

grpc
grpcs

See also SetTLSConfig.

func (*PrmDial) SetStreamTimeout

func (x *PrmDial) SetStreamTimeout(timeout time.Duration)

SetStreamTimeout sets the timeout for individual operations in streaming RPC. MUST BE positive. If not called, 10s timeout will be used by default.

func (*PrmDial) SetTLSConfig

func (x *PrmDial) SetTLSConfig(tlsConfig *tls.Config)

SetTLSConfig sets tls.Config to open TLS client connection to the NeoFS server. Nil (default) means insecure connection.

See also SetServerURI.

func (*PrmDial) SetTimeout

func (x *PrmDial) SetTimeout(timeout time.Duration)

SetTimeout sets the timeout for connection to be established. MUST BE positive. If not called, 5s timeout will be used by default.

type PrmEndpointInfo

type PrmEndpointInfo struct {
	// contains filtered or unexported fields
}

PrmEndpointInfo groups parameters of EndpointInfo operation.

func (*PrmEndpointInfo) WithXHeaders

func (x *PrmEndpointInfo) WithXHeaders(hs ...string)

WithXHeaders specifies list of extended headers (string key-value pairs) to be attached to the request. Must have an even length.

Slice must not be mutated until the operation completes.

type PrmInit

type PrmInit struct {
	// contains filtered or unexported fields
}

PrmInit groups initialization parameters of Client instances.

See also New.

func (*PrmInit) SetResponseInfoCallback

func (x *PrmInit) SetResponseInfoCallback(f func(ResponseMetaInfo) error)

SetResponseInfoCallback makes the Client to pass ResponseMetaInfo from each NeoFS server response to f. Nil (default) means ignore response meta info.

func (*PrmInit) SetStatisticCallback

func (x *PrmInit) SetStatisticCallback(statisticCallback stat.OperationCallback)

SetStatisticCallback makes the Client to pass stat.OperationCallback for the external statistic.

type PrmNetMapSnapshot

type PrmNetMapSnapshot struct {
}

PrmNetMapSnapshot groups parameters of NetMapSnapshot operation.

type PrmNetworkInfo

type PrmNetworkInfo struct {
	// contains filtered or unexported fields
}

PrmNetworkInfo groups parameters of NetworkInfo operation.

func (*PrmNetworkInfo) WithXHeaders

func (x *PrmNetworkInfo) WithXHeaders(hs ...string)

WithXHeaders specifies list of extended headers (string key-value pairs) to be attached to the request. Must have an even length.

Slice must not be mutated until the operation completes.

type PrmObjectDelete

type PrmObjectDelete struct {
	// contains filtered or unexported fields
}

PrmObjectDelete groups optional parameters of ObjectDelete operation.

func (*PrmObjectDelete) GetSession

func (x *PrmObjectDelete) GetSession() (*session.Object, error)

GetSession returns session object.

Returns:

func (*PrmObjectDelete) IgnoreSession

func (x *PrmObjectDelete) IgnoreSession()

IgnoreSession disables auto-session creation.

See also WithinSession.

func (*PrmObjectDelete) WithBearerToken

func (x *PrmObjectDelete) WithBearerToken(t bearer.Token)

WithBearerToken attaches bearer token to be used for the operation.

If set, underlying eACL rules will be used in access control.

Must be signed.

func (*PrmObjectDelete) WithXHeaders

func (x *PrmObjectDelete) WithXHeaders(hs ...string)

WithXHeaders specifies list of extended headers (string key-value pairs) to be attached to the request. Must have an even length.

Slice must not be mutated until the operation completes.

func (*PrmObjectDelete) WithinSession

func (x *PrmObjectDelete) WithinSession(t session.Object)

WithinSession specifies session within which the query must be executed.

Creator of the session acquires the authorship of the request. This may affect the execution of an operation (e.g. access control).

See also IgnoreSession.

Must be signed.

type PrmObjectGet

type PrmObjectGet struct {
	// contains filtered or unexported fields
}

PrmObjectGet groups optional parameters of ObjectGetInit operation.

func (*PrmObjectGet) MarkLocal

func (x *PrmObjectGet) MarkLocal()

MarkLocal tells the server to execute the operation locally.

func (*PrmObjectGet) MarkRaw

func (x *PrmObjectGet) MarkRaw()

MarkRaw marks an intent to read physically stored object.

func (*PrmObjectGet) WithBearerToken

func (x *PrmObjectGet) WithBearerToken(t bearer.Token)

WithBearerToken attaches bearer token to be used for the operation.

If set, underlying eACL rules will be used in access control.

Must be signed.

func (*PrmObjectGet) WithXHeaders

func (x *PrmObjectGet) WithXHeaders(hs ...string)

WithXHeaders specifies list of extended headers (string key-value pairs) to be attached to the request. Must have an even length.

Slice must not be mutated until the operation completes.

type PrmObjectHash

type PrmObjectHash struct {
	// contains filtered or unexported fields
}

PrmObjectHash groups parameters of ObjectHash operation.

func (*PrmObjectHash) GetSession

func (x *PrmObjectHash) GetSession() (*session.Object, error)

GetSession returns session object.

Returns:

func (*PrmObjectHash) IgnoreSession

func (x *PrmObjectHash) IgnoreSession()

IgnoreSession disables auto-session creation.

See also WithinSession.

func (*PrmObjectHash) MarkLocal

func (x *PrmObjectHash) MarkLocal()

MarkLocal tells the server to execute the operation locally.

func (*PrmObjectHash) SetRangeList

func (x *PrmObjectHash) SetRangeList(r ...uint64)

SetRangeList sets list of ranges in (offset, length) pair format. Required parameter.

If passed as slice, then it must not be mutated before the operation completes.

func (*PrmObjectHash) TillichZemorAlgo

func (x *PrmObjectHash) TillichZemorAlgo()

TillichZemorAlgo changes the hash function to Tillich-Zemor (https://link.springer.com/content/pdf/10.1007/3-540-48658-5_5.pdf).

By default, SHA256 hash function is used.

func (*PrmObjectHash) UseSalt

func (x *PrmObjectHash) UseSalt(salt []byte)

UseSalt sets the salt to XOR the data range before hashing.

Must not be mutated before the operation completes.

func (*PrmObjectHash) WithBearerToken

func (x *PrmObjectHash) WithBearerToken(t bearer.Token)

WithBearerToken attaches bearer token to be used for the operation.

If set, underlying eACL rules will be used in access control.

Must be signed.

func (*PrmObjectHash) WithXHeaders

func (x *PrmObjectHash) WithXHeaders(hs ...string)

WithXHeaders specifies list of extended headers (string key-value pairs) to be attached to the request. Must have an even length.

Slice must not be mutated until the operation completes.

func (*PrmObjectHash) WithinSession

func (x *PrmObjectHash) WithinSession(t session.Object)

WithinSession specifies session within which the query must be executed.

Creator of the session acquires the authorship of the request. This may affect the execution of an operation (e.g. access control).

See also IgnoreSession.

Must be signed.

type PrmObjectHead

type PrmObjectHead struct {
	// contains filtered or unexported fields
}

PrmObjectHead groups optional parameters of ObjectHead operation.

func (*PrmObjectHead) MarkLocal

func (x *PrmObjectHead) MarkLocal()

MarkLocal tells the server to execute the operation locally.

func (*PrmObjectHead) MarkRaw

func (x *PrmObjectHead) MarkRaw()

MarkRaw marks an intent to read physically stored object.

func (*PrmObjectHead) WithBearerToken

func (x *PrmObjectHead) WithBearerToken(t bearer.Token)

WithBearerToken attaches bearer token to be used for the operation.

If set, underlying eACL rules will be used in access control.

Must be signed.

func (*PrmObjectHead) WithXHeaders

func (x *PrmObjectHead) WithXHeaders(hs ...string)

WithXHeaders specifies list of extended headers (string key-value pairs) to be attached to the request. Must have an even length.

Slice must not be mutated until the operation completes.

type PrmObjectPutInit

type PrmObjectPutInit struct {
	// contains filtered or unexported fields
}

PrmObjectPutInit groups parameters of ObjectPutInit operation.

func (*PrmObjectPutInit) GetSession

func (x *PrmObjectPutInit) GetSession() (*session.Object, error)

GetSession returns session object.

Returns:

func (*PrmObjectPutInit) IgnoreSession

func (x *PrmObjectPutInit) IgnoreSession()

IgnoreSession disables auto-session creation.

See also WithinSession.

func (*PrmObjectPutInit) MarkLocal

func (x *PrmObjectPutInit) MarkLocal()

MarkLocal tells the server to execute the operation locally.

func (*PrmObjectPutInit) SetCopiesNumber

func (x *PrmObjectPutInit) SetCopiesNumber(copiesNumber uint32)

SetCopiesNumber sets the minimal number of copies (out of the number specified by container placement policy) for the object PUT operation to succeed. This means that object operation will return with successful status even before container placement policy is completely satisfied.

func (*PrmObjectPutInit) WithBearerToken

func (x *PrmObjectPutInit) WithBearerToken(t bearer.Token)

WithBearerToken attaches bearer token to be used for the operation. Should be called once before any writing steps.

func (*PrmObjectPutInit) WithXHeaders

func (x *PrmObjectPutInit) WithXHeaders(hs ...string)

WithXHeaders specifies list of extended headers (string key-value pairs) to be attached to the request. Must have an even length.

Slice must not be mutated until the operation completes.

func (*PrmObjectPutInit) WithinSession

func (x *PrmObjectPutInit) WithinSession(t session.Object)

WithinSession specifies session within which the query must be executed.

Creator of the session acquires the authorship of the request. This may affect the execution of an operation (e.g. access control).

See also IgnoreSession.

Must be signed.

type PrmObjectRange

type PrmObjectRange struct {
	// contains filtered or unexported fields
}

PrmObjectRange groups optional parameters of ObjectRange operation.

func (*PrmObjectRange) MarkLocal

func (x *PrmObjectRange) MarkLocal()

MarkLocal tells the server to execute the operation locally.

func (*PrmObjectRange) MarkRaw

func (x *PrmObjectRange) MarkRaw()

MarkRaw marks an intent to read physically stored object.

func (*PrmObjectRange) WithBearerToken

func (x *PrmObjectRange) WithBearerToken(t bearer.Token)

WithBearerToken attaches bearer token to be used for the operation.

If set, underlying eACL rules will be used in access control.

Must be signed.

func (*PrmObjectRange) WithXHeaders

func (x *PrmObjectRange) WithXHeaders(hs ...string)

WithXHeaders specifies list of extended headers (string key-value pairs) to be attached to the request. Must have an even length.

Slice must not be mutated until the operation completes.

type PrmObjectSearch

type PrmObjectSearch struct {
	// contains filtered or unexported fields
}

PrmObjectSearch groups optional parameters of ObjectSearch operation.

func (*PrmObjectSearch) GetSession

func (x *PrmObjectSearch) GetSession() (*session.Object, error)

GetSession returns session object.

Returns:

func (*PrmObjectSearch) IgnoreSession

func (x *PrmObjectSearch) IgnoreSession()

IgnoreSession disables auto-session creation.

See also WithinSession.

func (*PrmObjectSearch) MarkLocal

func (x *PrmObjectSearch) MarkLocal()

MarkLocal tells the server to execute the operation locally.

func (*PrmObjectSearch) SetFilters

func (x *PrmObjectSearch) SetFilters(filters object.SearchFilters)

SetFilters sets filters by which to select objects. All container objects match unset/empty filters.

func (*PrmObjectSearch) WithBearerToken

func (x *PrmObjectSearch) WithBearerToken(t bearer.Token)

WithBearerToken attaches bearer token to be used for the operation.

If set, underlying eACL rules will be used in access control.

Must be signed.

func (*PrmObjectSearch) WithXHeaders

func (x *PrmObjectSearch) WithXHeaders(hs ...string)

WithXHeaders specifies list of extended headers (string key-value pairs) to be attached to the request. Must have an even length.

Slice must not be mutated until the operation completes.

func (*PrmObjectSearch) WithinSession

func (x *PrmObjectSearch) WithinSession(t session.Object)

WithinSession specifies session within which the query must be executed.

Creator of the session acquires the authorship of the request. This may affect the execution of an operation (e.g. access control).

See also IgnoreSession.

Must be signed.

type PrmSessionCreate

type PrmSessionCreate struct {
	// contains filtered or unexported fields
}

PrmSessionCreate groups parameters of SessionCreate operation.

func (*PrmSessionCreate) SetExp

func (x *PrmSessionCreate) SetExp(exp uint64)

SetExp sets number of the last NepFS epoch in the lifetime of the session after which it will be expired.

func (*PrmSessionCreate) WithXHeaders

func (x *PrmSessionCreate) WithXHeaders(hs ...string)

WithXHeaders specifies list of extended headers (string key-value pairs) to be attached to the request. Must have an even length.

Slice must not be mutated until the operation completes.

type ResEndpointInfo

type ResEndpointInfo struct {
	// contains filtered or unexported fields
}

ResEndpointInfo group resulting values of EndpointInfo operation.

func NewResEndpointInfo

func NewResEndpointInfo(version version.Version, ni netmap.NodeInfo) ResEndpointInfo

NewResEndpointInfo is a constructor for ResEndpointInfo.

func (ResEndpointInfo) LatestVersion

func (x ResEndpointInfo) LatestVersion() version.Version

LatestVersion returns latest NeoFS API protocol's version in use.

func (ResEndpointInfo) NodeInfo

func (x ResEndpointInfo) NodeInfo() netmap.NodeInfo

NodeInfo returns information about the NeoFS node served on the remote endpoint.

type ResObjectPut

type ResObjectPut struct {
	// contains filtered or unexported fields
}

ResObjectPut groups the final result values of ObjectPutInit operation.

func (ResObjectPut) StoredObjectID

func (x ResObjectPut) StoredObjectID() oid.ID

StoredObjectID returns identifier of the saved object.

type ResSessionCreate

type ResSessionCreate struct {
	// contains filtered or unexported fields
}

ResSessionCreate groups resulting values of SessionCreate operation.

func NewResSessionCreate

func NewResSessionCreate(id []byte, sessionKey []byte) ResSessionCreate

NewResSessionCreate is a constructor for NewResSessionCreate.

func (ResSessionCreate) ID

func (x ResSessionCreate) ID() []byte

ID returns identifier of the opened session in a binary NeoFS API protocol format.

Client doesn't retain value so modification is safe.

func (ResSessionCreate) PublicKey

func (x ResSessionCreate) PublicKey() []byte

PublicKey returns public key of the opened session in a binary NeoFS API protocol format.

The resulting slice of bytes is a serialized compressed public key. See [elliptic.MarshalCompressed]. Use neofsecdsa.PublicKey.Decode to decode it into a type-specific structure.

The value returned shares memory with the structure itself, so changing it can lead to data corruption. Make a copy if you need to change it.

type ResponseMetaInfo

type ResponseMetaInfo struct {
	// contains filtered or unexported fields
}

ResponseMetaInfo groups meta information about any NeoFS API response.

func (ResponseMetaInfo) Epoch

func (x ResponseMetaInfo) Epoch() uint64

Epoch returns local NeoFS epoch of the server.

func (ResponseMetaInfo) ResponderKey

func (x ResponseMetaInfo) ResponderKey() []byte

ResponderKey returns responder's public key in a binary format.

The resulting slice of bytes is a serialized compressed public key. See [elliptic.MarshalCompressed]. Use neofsecdsa.PublicKey.Decode to decode it into a type-specific structure.

The value returned shares memory with the structure itself, so changing it can lead to data corruption. Make a copy if you need to change it.

type SignError

type SignError struct {
	// contains filtered or unexported fields
}

SignError wraps another error with reason why sign process was failed.

func NewSignError

func NewSignError(err error) SignError

NewSignError is a constructor for SignError.

func (SignError) Error

func (e SignError) Error() string

Error implements the error interface.

func (SignError) Is

func (e SignError) Is(target error) bool

Is implements interface for correct checking current error type with errors.Is.

func (SignError) Unwrap

func (e SignError) Unwrap() error

Unwrap implements the error interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL