client

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: Apache-2.0 Imports: 33 Imported by: 1

Documentation

Index

Constants

View Source
const TZSize = 64

Variables

This section is empty.

Functions

func DeleteObject added in v1.21.0

func DeleteObject(ctx context.Context, c Client, p *DeleteObjectParams, opts ...CallOption) (*object.Address, error)

DeleteObject is a wrapper over Client.DeleteObject method that provides the ability to receive tombstone address without setting a target in the parameters.

func GetVerifiedContainerStructure added in v1.21.1

func GetVerifiedContainerStructure(ctx context.Context, c Client, id *cid.ID, opts ...CallOption) (*container.Container, error)

GetVerifiedContainerStructure is a wrapper over Client.GetContainer method which checks if the structure of the resulting container matches its identifier.

Returns an error if container does not match the identifier.

Types

type Accounting added in v1.25.0

type Accounting interface {
	// GetBalance returns balance of provided account.
	GetBalance(context.Context, *owner.ID, ...CallOption) (*accounting.Decimal, error)
}

Accounting contains methods related to balance querying.

type AnnounceIntermediateTrustPrm added in v1.26.0

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

AnnounceIntermediateTrustPrm groups parameters of AnnounceIntermediateTrust operation.

func (*AnnounceIntermediateTrustPrm) Epoch added in v1.26.0

func (AnnounceIntermediateTrustPrm) Iteration added in v1.26.0

func (x AnnounceIntermediateTrustPrm) Iteration() uint32

Iteration returns sequence number of the iteration.

func (*AnnounceIntermediateTrustPrm) SetEpoch added in v1.26.0

func (x *AnnounceIntermediateTrustPrm) SetEpoch(epoch uint64)

func (*AnnounceIntermediateTrustPrm) SetIteration added in v1.26.0

func (x *AnnounceIntermediateTrustPrm) SetIteration(iter uint32)

SetIteration sets sequence number of the iteration.

func (*AnnounceIntermediateTrustPrm) SetTrust added in v1.26.0

SetTrust sets current global trust value computed at the specified iteration.

func (AnnounceIntermediateTrustPrm) Trust added in v1.26.0

Trust returns current global trust value computed at the specified iteration.

type AnnounceIntermediateTrustRes added in v1.26.0

type AnnounceIntermediateTrustRes struct{}

AnnounceIntermediateTrustRes groups results of AnnounceIntermediateTrust operation.

type AnnounceLocalTrustPrm added in v1.26.0

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

AnnounceLocalTrustPrm groups parameters of AnnounceLocalTrust operation.

func (AnnounceLocalTrustPrm) Epoch added in v1.26.0

func (x AnnounceLocalTrustPrm) Epoch() uint64

Epoch returns epoch in which the trust was assessed.

func (*AnnounceLocalTrustPrm) SetEpoch added in v1.26.0

func (x *AnnounceLocalTrustPrm) SetEpoch(epoch uint64)

SetEpoch sets epoch in which the trust was assessed.

func (*AnnounceLocalTrustPrm) SetTrusts added in v1.26.0

func (x *AnnounceLocalTrustPrm) SetTrusts(trusts []*reputation.Trust)

SetTrusts sets list of local trust values.

func (AnnounceLocalTrustPrm) Trusts added in v1.26.0

func (x AnnounceLocalTrustPrm) Trusts() []*reputation.Trust

Trusts returns list of local trust values.

type AnnounceLocalTrustRes added in v1.26.0

type AnnounceLocalTrustRes struct{}

AnnounceLocalTrustRes groups results of AnnounceLocalTrust operation.

type CallOption

type CallOption func(*callOptions)

func WithBearer

func WithBearer(token *token.BearerToken) CallOption

func WithEpoch

func WithEpoch(epoch uint64) CallOption

func WithKey added in v1.25.0

func WithKey(key *ecdsa.PrivateKey) CallOption

WithKey sets client's key for the next request.

func WithSession

func WithSession(token *session.Token) CallOption

func WithTTL

func WithTTL(ttl uint32) CallOption

func WithXHeader

func WithXHeader(x *pkg.XHeader) CallOption

type Client

type Client interface {
	Accounting
	Container
	Netmap
	Object
	Session
	Reputation

	// Raw must return underlying raw protobuf client.
	Raw() *client.Client

	// Conn must return underlying connection.
	//
	// Must return a non-nil result after the first RPC call
	// completed without a connection error.
	Conn() io.Closer
}

Client represents NeoFS client.

func New

func New(opts ...Option) (Client, error)

type Container added in v1.25.0

type Container interface {
	// PutContainer creates new container in the NeoFS network.
	PutContainer(context.Context, *container.Container, ...CallOption) (*cid.ID, error)

	// GetContainer returns container by ID.
	GetContainer(context.Context, *cid.ID, ...CallOption) (*container.Container, error)

	// ListContainers return container list with the provided owner.
	ListContainers(context.Context, *owner.ID, ...CallOption) ([]*cid.ID, error)

	// DeleteContainer removes container from NeoFS network.
	DeleteContainer(context.Context, *cid.ID, ...CallOption) error

	// GetEACL returns extended ACL for a given container.
	GetEACL(context.Context, *cid.ID, ...CallOption) (*EACLWithSignature, error)

	// SetEACL sets extended ACL.
	SetEACL(context.Context, *eacl.Table, ...CallOption) error

	// AnnounceContainerUsedSpace announces amount of space which is taken by stored objects.
	AnnounceContainerUsedSpace(context.Context, []container.UsedSpaceAnnouncement, ...CallOption) error
}

Container contains methods related to container and ACL.

type DeleteObjectParams

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

func (*DeleteObjectParams) Address added in v1.21.0

func (p *DeleteObjectParams) Address() *object.Address

func (*DeleteObjectParams) TombstoneAddressTarget added in v1.21.0

func (p *DeleteObjectParams) TombstoneAddressTarget() ObjectAddressWriter

TombstoneAddressTarget returns target component to write tombstone address.

func (*DeleteObjectParams) WithAddress

func (*DeleteObjectParams) WithTombstoneAddressTarget added in v1.21.0

func (p *DeleteObjectParams) WithTombstoneAddressTarget(v ObjectAddressWriter) *DeleteObjectParams

WithTombstoneAddressTarget sets target component to write tombstone address.

type EACLWithSignature added in v1.20.3

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

EACLWithSignature represents eACL table/signature pair.

func (EACLWithSignature) EACL added in v1.20.3

func (e EACLWithSignature) EACL() *eacl.Table

EACL returns eACL table.

func (EACLWithSignature) Signature deprecated added in v1.20.3

func (e EACLWithSignature) Signature() *pkg.Signature

Signature returns table signature.

Deprecated: use EACL().Signature() instead.

type EndpointInfo added in v1.25.0

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

EACLWithSignature represents eACL table/signature pair.

func (*EndpointInfo) LatestVersion added in v1.25.0

func (e *EndpointInfo) LatestVersion() *pkg.Version

LatestVersion returns latest NeoFS API version in use.

func (*EndpointInfo) NodeInfo added in v1.25.0

func (e *EndpointInfo) NodeInfo() *netmap.NodeInfo

NodeInfo returns returns information about the NeoFS node.

type GetObjectParams

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

func (*GetObjectParams) Address added in v1.21.0

func (p *GetObjectParams) Address() *object.Address

func (*GetObjectParams) PayloadWriter added in v1.21.0

func (p *GetObjectParams) PayloadWriter() io.Writer

func (*GetObjectParams) RawFlag added in v1.21.0

func (p *GetObjectParams) RawFlag() bool

func (*GetObjectParams) WithAddress

func (p *GetObjectParams) WithAddress(v *object.Address) *GetObjectParams

func (*GetObjectParams) WithPayloadReaderHandler added in v1.28.0

func (p *GetObjectParams) WithPayloadReaderHandler(f ReaderHandler) *GetObjectParams

WithPayloadReaderHandler sets handler of the payload reader.

If provided, payload reader is composed after receiving the header. In this case payload writer set via WithPayloadWriter is ignored.

Handler should not be nil.

func (*GetObjectParams) WithPayloadWriter

func (p *GetObjectParams) WithPayloadWriter(w io.Writer) *GetObjectParams

func (*GetObjectParams) WithRawFlag added in v1.21.0

func (p *GetObjectParams) WithRawFlag(v bool) *GetObjectParams

type Netmap added in v1.25.0

type Netmap interface {
	// EndpointInfo returns attributes, address and public key of the node, specified
	// in client constructor via address or open connection. This can be used as a
	// health check to see if node is alive and responses to requests.
	EndpointInfo(context.Context, ...CallOption) (*EndpointInfo, error)

	// NetworkInfo returns information about the NeoFS network of which the remote server is a part.
	NetworkInfo(context.Context, ...CallOption) (*netmap.NetworkInfo, error)
}

Netmap contains methods related to netmap.

type Object added in v1.25.0

type Object interface {
	// PutObject puts new object to NeoFS.
	PutObject(context.Context, *PutObjectParams, ...CallOption) (*object.ID, error)

	// DeleteObject deletes object to NeoFS.
	DeleteObject(context.Context, *DeleteObjectParams, ...CallOption) error

	// GetObject returns object stored in NeoFS.
	GetObject(context.Context, *GetObjectParams, ...CallOption) (*object.Object, error)

	// GetObjectHeader returns object header.
	GetObjectHeader(context.Context, *ObjectHeaderParams, ...CallOption) (*object.Object, error)

	// ObjectPayloadRangeData returns range of object payload.
	ObjectPayloadRangeData(context.Context, *RangeDataParams, ...CallOption) ([]byte, error)

	// ObjectPayloadRangeSHA256 returns sha-256 hashes of object sub-ranges from NeoFS.
	ObjectPayloadRangeSHA256(context.Context, *RangeChecksumParams, ...CallOption) ([][sha256.Size]byte, error)

	// ObjectPayloadRangeTZ returns homomorphic hashes of object sub-ranges from NeoFS.
	ObjectPayloadRangeTZ(context.Context, *RangeChecksumParams, ...CallOption) ([][TZSize]byte, error)

	// SearchObject searches for objects in NeoFS using provided parameters.
	SearchObject(context.Context, *SearchObjectParams, ...CallOption) ([]*object.ID, error)
}

Object contains methods for working with objects.

type ObjectAddressWriter added in v1.21.0

type ObjectAddressWriter interface {
	SetAddress(*object.Address)
}

ObjectAddressWriter is an interface of the component that writes the object address.

type ObjectHeaderParams

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

func (*ObjectHeaderParams) Address added in v1.21.0

func (p *ObjectHeaderParams) Address() *object.Address

func (*ObjectHeaderParams) AllFields added in v1.21.0

func (p *ObjectHeaderParams) AllFields() bool

AllFields return true if parameter set to return all header fields, returns false if parameter set to return only main fields of header.

func (*ObjectHeaderParams) RawFlag added in v1.21.0

func (p *ObjectHeaderParams) RawFlag() bool

func (*ObjectHeaderParams) WithAddress

func (*ObjectHeaderParams) WithAllFields

func (p *ObjectHeaderParams) WithAllFields() *ObjectHeaderParams

func (*ObjectHeaderParams) WithMainFields

func (p *ObjectHeaderParams) WithMainFields() *ObjectHeaderParams

func (*ObjectHeaderParams) WithRawFlag added in v1.21.0

func (p *ObjectHeaderParams) WithRawFlag(v bool) *ObjectHeaderParams

type Option

type Option func(*clientOptions)

func WithAddress

func WithAddress(addr string) Option

WithAddress returns option to specify network address of the remote server.

Ignored if WithGRPCConnection is provided.

func WithDefaultPrivateKey added in v1.25.0

func WithDefaultPrivateKey(key *ecdsa.PrivateKey) Option

WithDefaultPrivateKey returns option to set default private key used for the work.

func WithDialTimeout added in v1.20.3

func WithDialTimeout(dur time.Duration) Option

WithDialTimeout returns option to set connection timeout to the remote node.

Ignored if WithGRPCConn is provided.

func WithGRPCConnection

func WithGRPCConnection(grpcConn *grpc.ClientConn) Option

WithGRPCConnection returns option to set GRPC connection to the remote node.

func WithResponseInfoHandler added in v1.30.0

func WithResponseInfoHandler(f func(ResponseMetaInfo) error) Option

WithResponseInfoHandler allows to specify handler of response meta information for the all Client operations. The handler is called right after the response is received. Client returns handler's error immediately.

func WithTLSConfig added in v1.27.0

func WithTLSConfig(cfg *tls.Config) Option

WithTLSConfig returns option to set connection's TLS config to the remote node.

Ignored if WithGRPCConnection is provided.

func WithURIAddress added in v1.27.0

func WithURIAddress(addr string, tlsCfg *tls.Config) Option

WithURIAddress returns option to specify network address of a remote server and connection scheme for it.

Format of the URI:

[scheme://]host:port

Supported schemes:

  • grpc;
  • grpcs.

tls.Cfg second argument is optional and is taken into account only in case of `grpcs` scheme.

Falls back to WithNetworkAddress if address is not a valid URI.

Do not use along with WithAddress and WithTLSConfig.

Ignored if WithGRPCConnection is provided.

type PutObjectParams

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

func (*PutObjectParams) Object added in v1.21.0

func (p *PutObjectParams) Object() *object.Object

func (*PutObjectParams) PayloadReader added in v1.21.0

func (p *PutObjectParams) PayloadReader() io.Reader

func (*PutObjectParams) WithObject

func (p *PutObjectParams) WithObject(v *object.Object) *PutObjectParams

func (*PutObjectParams) WithPayloadReader

func (p *PutObjectParams) WithPayloadReader(v io.Reader) *PutObjectParams

type RangeChecksumParams

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

func (*RangeChecksumParams) Address added in v1.21.0

func (p *RangeChecksumParams) Address() *object.Address

func (*RangeChecksumParams) RangeList added in v1.21.0

func (p *RangeChecksumParams) RangeList() []*object.Range

func (*RangeChecksumParams) Salt added in v1.21.0

func (p *RangeChecksumParams) Salt() []byte

func (*RangeChecksumParams) WithAddress

func (*RangeChecksumParams) WithRangeList

func (p *RangeChecksumParams) WithRangeList(rs ...*object.Range) *RangeChecksumParams

func (*RangeChecksumParams) WithSalt

func (p *RangeChecksumParams) WithSalt(v []byte) *RangeChecksumParams

type RangeDataParams

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

func (*RangeDataParams) Address added in v1.21.0

func (p *RangeDataParams) Address() *object.Address

func (*RangeDataParams) DataWriter added in v1.21.0

func (p *RangeDataParams) DataWriter() io.Writer

func (*RangeDataParams) Range added in v1.21.0

func (p *RangeDataParams) Range() *object.Range

func (*RangeDataParams) Raw added in v1.21.0

func (p *RangeDataParams) Raw() bool

func (*RangeDataParams) WithAddress

func (p *RangeDataParams) WithAddress(v *object.Address) *RangeDataParams

func (*RangeDataParams) WithDataWriter

func (p *RangeDataParams) WithDataWriter(v io.Writer) *RangeDataParams

func (*RangeDataParams) WithRange

func (p *RangeDataParams) WithRange(v *object.Range) *RangeDataParams

func (*RangeDataParams) WithRaw added in v1.21.0

func (p *RangeDataParams) WithRaw(v bool) *RangeDataParams

type ReaderHandler added in v1.28.0

type ReaderHandler func(io.Reader)

ReaderHandler is a function over io.Reader.

type Reputation added in v1.26.0

type Reputation interface {
	// AnnounceLocalTrust announces local trust values of local peer.
	AnnounceLocalTrust(context.Context, AnnounceLocalTrustPrm, ...CallOption) (*AnnounceLocalTrustRes, error)

	// AnnounceIntermediateTrust announces the intermediate result of the iterative algorithm for calculating
	// the global reputation of the node.
	AnnounceIntermediateTrust(context.Context, AnnounceIntermediateTrustPrm, ...CallOption) (*AnnounceIntermediateTrustRes, error)
}

Reputation contains methods for working with Reputation system values.

type ResponseMetaInfo added in v1.30.0

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

ResponseMetaInfo groups meta information about any NeoFS API response.

func (ResponseMetaInfo) ResponderKey added in v1.30.0

func (x ResponseMetaInfo) ResponderKey() []byte

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

Result must not be mutated.

type SearchObjectParams

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

func (*SearchObjectParams) ContainerID added in v1.21.0

func (p *SearchObjectParams) ContainerID() *cid.ID

func (*SearchObjectParams) SearchFilters added in v1.21.0

func (p *SearchObjectParams) SearchFilters() object.SearchFilters

func (*SearchObjectParams) WithContainerID

func (p *SearchObjectParams) WithContainerID(v *cid.ID) *SearchObjectParams

func (*SearchObjectParams) WithSearchFilters

func (p *SearchObjectParams) WithSearchFilters(v object.SearchFilters) *SearchObjectParams

type Session added in v1.25.0

type Session interface {
	// CreateSession creates session using provided expiration time.
	CreateSession(context.Context, uint64, ...CallOption) (*session.Token, error)
}

Session contains session-related methods.

Jump to

Keyboard shortcuts

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