internal

package
v0.43.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: GPL-3.0 Imports: 32 Imported by: 0

Documentation

Overview

Package internal provides functionality for FrostFS CLI application communication with FrostFS network.

The base client for accessing remote nodes via FrostFS API is a FrostFS SDK Go API client. However, although it encapsulates a useful piece of business logic (e.g. the signature mechanism), the FrostFS CLI application does not fully use the client's flexible interface.

In this regard, this package provides functions over base API client necessary for the application. This allows you to concentrate the entire spectrum of the client's use in one place (this will be convenient both when updating the base client and for evaluating the UX of SDK library). So it is expected that all application packages will be limited to this package for the development of functionality requiring FrostFS API communication.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCurrentEpoch

func GetCurrentEpoch(ctx context.Context, cmd *cobra.Command, endpoint string) (uint64, error)

GetCurrentEpoch returns current epoch.

func GetSDKClient

func GetSDKClient(ctx context.Context, cmd *cobra.Command, key *ecdsa.PrivateKey, addr network.Address) (*client.Client, error)

GetSDKClient returns default frostfs-sdk-go client.

func GetSDKClientByFlag

func GetSDKClientByFlag(cmd *cobra.Command, key *ecdsa.PrivateKey, endpointFlag string) *client.Client

GetSDKClientByFlag returns default frostfs-sdk-go client using the specified flag for the address. On error, outputs to stderr of cmd and exits with non-zero code.

func IsACLExtendable

func IsACLExtendable(ctx context.Context, c *client.Client, cnr cid.ID) (bool, error)

IsACLExtendable checks if ACL of the container referenced by the given identifier can be extended. Client connection MUST BE correctly established in advance.

Types

type BalanceOfPrm

type BalanceOfPrm struct {
	client.PrmBalanceGet
	// contains filtered or unexported fields
}

BalanceOfPrm groups parameters of BalanceOf operation.

func (*BalanceOfPrm) SetClient

func (x *BalanceOfPrm) SetClient(cli *client.Client)

SetClient sets the base client for FrostFS API communication.

type BalanceOfRes

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

BalanceOfRes groups the resulting values of BalanceOf operation.

func BalanceOf

func BalanceOf(ctx context.Context, prm BalanceOfPrm) (res BalanceOfRes, err error)

BalanceOf requests the current balance of a FrostFS user.

Returns any error which prevented the operation from completing correctly in error return.

func (BalanceOfRes) Balance

func (x BalanceOfRes) Balance() accounting.Decimal

Balance returns the current balance.

type CreateSessionPrm

type CreateSessionPrm struct {
	client.PrmSessionCreate
	// contains filtered or unexported fields
}

CreateSessionPrm groups parameters of CreateSession operation.

func (*CreateSessionPrm) SetClient

func (x *CreateSessionPrm) SetClient(cli *client.Client)

SetClient sets the base client for FrostFS API communication.

type CreateSessionRes

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

CreateSessionRes groups the resulting values of CreateSession operation.

func CreateSession

func CreateSession(ctx context.Context, prm CreateSessionPrm) (res CreateSessionRes, err error)

CreateSession opens a new unlimited session with the remote node.

Returns any error which prevented the operation from completing correctly in error return.

func (CreateSessionRes) ID

func (x CreateSessionRes) ID() []byte

ID returns session identifier.

func (CreateSessionRes) SessionKey

func (x CreateSessionRes) SessionKey() []byte

SessionKey returns public session key in a binary format.

type DeleteContainerPrm

type DeleteContainerPrm struct {
	Client       *client.Client
	ClientParams client.PrmContainerDelete
}

DeleteContainerPrm groups parameters of DeleteContainerPrm operation.

type DeleteContainerRes

type DeleteContainerRes struct{}

DeleteContainerRes groups the resulting values of DeleteContainer operation.

func DeleteContainer

func DeleteContainer(ctx context.Context, prm DeleteContainerPrm) (res DeleteContainerRes, err error)

DeleteContainer sends a request to remove a container from FrostFS by ID.

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

Success can be verified by reading by identifier.

Returns any error which prevented the operation from completing correctly in error return.

type DeleteObjectPrm

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

DeleteObjectPrm groups parameters of DeleteObject operation.

func (*DeleteObjectPrm) SetAddress

func (x *DeleteObjectPrm) SetAddress(addr oid.Address)

func (*DeleteObjectPrm) SetSessionToken

func (x *DeleteObjectPrm) SetSessionToken(tok *session.Object)

SetSessionToken sets the token of the session within which the request should be sent.

func (*DeleteObjectPrm) SetTTL

func (x *DeleteObjectPrm) SetTTL(ttl uint32)

SetTTL sets request TTL value.

func (*DeleteObjectPrm) SetXHeaders

func (x *DeleteObjectPrm) SetXHeaders(hs []string)

SetXHeaders sets request X-Headers.

type DeleteObjectRes

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

DeleteObjectRes groups the resulting values of DeleteObject operation.

func DeleteObject

func DeleteObject(ctx context.Context, prm DeleteObjectPrm) (*DeleteObjectRes, error)

DeleteObject marks an object to be removed from FrostFS through tombstone placement.

Returns any error which prevented the operation from completing correctly in error return.

func (DeleteObjectRes) Tombstone

func (x DeleteObjectRes) Tombstone() oid.ID

Tombstone returns the ID of the created object with tombstone.

type GetContainerPrm

type GetContainerPrm struct {
	Client       *client.Client
	ClientParams client.PrmContainerGet
}

GetContainerPrm groups parameters of GetContainer operation.

func (*GetContainerPrm) SetContainer deprecated

func (x *GetContainerPrm) SetContainer(id cid.ID)

SetContainer sets identifier of the container to be read.

Deprecated: Use GetContainerPrm.ClientParams.ContainerID instead.

type GetContainerRes

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

GetContainerRes groups the resulting values of GetContainer operation.

func GetContainer

func GetContainer(ctx context.Context, prm GetContainerPrm) (res GetContainerRes, err error)

GetContainer reads a container from FrostFS by ID.

Returns any error which prevented the operation from completing correctly in error return.

func (GetContainerRes) Container

func (x GetContainerRes) Container() containerSDK.Container

Container returns structured of the requested container.

type GetObjectPrm

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

GetObjectPrm groups parameters of GetObject operation.

func (*GetObjectPrm) SetAddress

func (x *GetObjectPrm) SetAddress(addr oid.Address)

func (*GetObjectPrm) SetHeaderCallback

func (p *GetObjectPrm) SetHeaderCallback(f func(*objectSDK.Object))

SetHeaderCallback sets callback which is called on the object after the header is received but before the payload is written.

func (*GetObjectPrm) SetPayloadWriter

func (x *GetObjectPrm) SetPayloadWriter(wrt io.Writer)

SetPayloadWriter sets the writer of the object payload.

func (*GetObjectPrm) SetRawFlag

func (x *GetObjectPrm) SetRawFlag(raw bool)

SetRawFlag sets flag of raw request.

func (*GetObjectPrm) SetSessionToken

func (x *GetObjectPrm) SetSessionToken(tok *session.Object)

SetSessionToken sets the token of the session within which the request should be sent.

func (*GetObjectPrm) SetTTL

func (x *GetObjectPrm) SetTTL(ttl uint32)

SetTTL sets request TTL value.

func (*GetObjectPrm) SetXHeaders

func (x *GetObjectPrm) SetXHeaders(hs []string)

SetXHeaders sets request X-Headers.

type GetObjectRes

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

GetObjectRes groups the resulting values of GetObject operation.

func GetObject

func GetObject(ctx context.Context, prm GetObjectPrm) (*GetObjectRes, error)

GetObject reads an object by address.

Interrupts on any writer error. If successful, payload is written to the writer.

Returns any error which prevented the operation from completing correctly in error return. For raw reading, returns *object.SplitInfoError error if object is virtual.

func (GetObjectRes) Header

func (x GetObjectRes) Header() *objectSDK.Object

Header returns the header of the request object.

type HashPayloadRangesPrm

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

HashPayloadRangesPrm groups parameters of HashPayloadRanges operation.

func (*HashPayloadRangesPrm) SetAddress

func (x *HashPayloadRangesPrm) SetAddress(addr oid.Address)

func (*HashPayloadRangesPrm) SetRanges

func (x *HashPayloadRangesPrm) SetRanges(rngs []objectSDK.Range)

SetRanges sets a list of payload ranges to hash.

func (*HashPayloadRangesPrm) SetSalt

func (x *HashPayloadRangesPrm) SetSalt(salt []byte)

SetSalt sets data for each range to be XOR'ed with.

func (*HashPayloadRangesPrm) SetSessionToken

func (x *HashPayloadRangesPrm) SetSessionToken(tok *session.Object)

SetSessionToken sets the token of the session within which the request should be sent.

func (*HashPayloadRangesPrm) SetTTL

func (x *HashPayloadRangesPrm) SetTTL(ttl uint32)

SetTTL sets request TTL value.

func (*HashPayloadRangesPrm) SetXHeaders

func (x *HashPayloadRangesPrm) SetXHeaders(hs []string)

SetXHeaders sets request X-Headers.

func (*HashPayloadRangesPrm) TZ

func (x *HashPayloadRangesPrm) TZ()

TZ sets flag to request Tillich-Zemor hashes.

type HashPayloadRangesRes

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

HashPayloadRangesRes groups the resulting values of HashPayloadRanges operation.

func HashPayloadRanges

func HashPayloadRanges(ctx context.Context, prm HashPayloadRangesPrm) (*HashPayloadRangesRes, error)

HashPayloadRanges requests hashes (by default SHA256) of the object payload ranges.

Returns any error which prevented the operation from completing correctly in error return. Returns an error if number of received hashes differs with the number of requested ranges.

func (HashPayloadRangesRes) HashList

func (x HashPayloadRangesRes) HashList() [][]byte

HashList returns a list of hashes of the payload ranges keeping order.

type HeadObjectPrm

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

HeadObjectPrm groups parameters of HeadObject operation.

func (*HeadObjectPrm) SetAddress

func (x *HeadObjectPrm) SetAddress(addr oid.Address)

func (*HeadObjectPrm) SetRawFlag

func (x *HeadObjectPrm) SetRawFlag(raw bool)

SetRawFlag sets flag of raw request.

func (*HeadObjectPrm) SetSessionToken

func (x *HeadObjectPrm) SetSessionToken(tok *session.Object)

SetSessionToken sets the token of the session within which the request should be sent.

func (*HeadObjectPrm) SetTTL

func (x *HeadObjectPrm) SetTTL(ttl uint32)

SetTTL sets request TTL value.

func (*HeadObjectPrm) SetXHeaders

func (x *HeadObjectPrm) SetXHeaders(hs []string)

SetXHeaders sets request X-Headers.

type HeadObjectRes

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

HeadObjectRes groups the resulting values of HeadObject operation.

func HeadObject

func HeadObject(ctx context.Context, prm HeadObjectPrm) (*HeadObjectRes, error)

HeadObject reads an object header by address.

Returns any error which prevented the operation from completing correctly in error return. For raw reading, returns *object.SplitInfoError error if object is virtual.

func (HeadObjectRes) Header

func (x HeadObjectRes) Header() *objectSDK.Object

Header returns the requested object header.

type ListContainersPrm

type ListContainersPrm struct {
	client.PrmContainerList
	// contains filtered or unexported fields
}

ListContainersPrm groups parameters of ListContainers operation.

func (*ListContainersPrm) SetClient

func (x *ListContainersPrm) SetClient(cli *client.Client)

SetClient sets the base client for FrostFS API communication.

type ListContainersRes

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

ListContainersRes groups the resulting values of ListContainers operation.

func ListContainers

func ListContainers(ctx context.Context, prm ListContainersPrm) (res ListContainersRes, err error)

ListContainers requests a list of FrostFS user's containers.

Returns any error which prevented the operation from completing correctly in error return.

func (ListContainersRes) IDList

func (x ListContainersRes) IDList() []cid.ID

IDList returns list of identifiers of user's containers.

func (ListContainersRes) SortedIDList added in v0.38.0

func (x ListContainersRes) SortedIDList() []cid.ID

SortedIDList returns sorted list of identifiers of user's containers.

type NetMapSnapshotPrm

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

NetMapSnapshotPrm groups parameters of NetMapSnapshot operation.

func (*NetMapSnapshotPrm) SetClient

func (x *NetMapSnapshotPrm) SetClient(cli *client.Client)

SetClient sets the base client for FrostFS API communication.

type NetMapSnapshotRes

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

NetMapSnapshotRes groups the resulting values of NetMapSnapshot operation.

func NetMapSnapshot

func NetMapSnapshot(ctx context.Context, prm NetMapSnapshotPrm) (res NetMapSnapshotRes, err error)

NetMapSnapshot requests current network view of the remote server.

Returns any error which prevented the operation from completing correctly in error return.

func (NetMapSnapshotRes) NetMap

func (x NetMapSnapshotRes) NetMap() netmap.NetMap

NetMap returns current local snapshot of the FrostFS network map.

type NetworkInfoPrm

type NetworkInfoPrm struct {
	Client       *client.Client
	ClientParams client.PrmNetworkInfo
}

NetworkInfoPrm groups parameters of NetworkInfo operation.

type NetworkInfoRes

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

NetworkInfoRes groups the resulting values of NetworkInfo operation.

func NetworkInfo

func NetworkInfo(ctx context.Context, prm NetworkInfoPrm) (res NetworkInfoRes, err error)

NetworkInfo reads information about the FrostFS network.

Returns any error which prevented the operation from completing correctly in error return.

func (NetworkInfoRes) NetworkInfo

func (x NetworkInfoRes) NetworkInfo() netmap.NetworkInfo

NetworkInfo returns structured information about the FrostFS network.

type NodeInfoPrm

type NodeInfoPrm struct {
	Client       *client.Client
	ClientParams client.PrmEndpointInfo
}

NodeInfoPrm groups parameters of NodeInfo operation.

type NodeInfoRes

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

NodeInfoRes groups the resulting values of NodeInfo operation.

func NodeInfo

func NodeInfo(ctx context.Context, prm NodeInfoPrm) (res NodeInfoRes, err error)

NodeInfo requests information about the remote server from FrostFS netmap.

Returns any error which prevented the operation from completing correctly in error return.

func (NodeInfoRes) LatestVersion

func (x NodeInfoRes) LatestVersion() version.Version

LatestVersion returns the latest FrostFS API version in use.

func (NodeInfoRes) NodeInfo

func (x NodeInfoRes) NodeInfo() netmap.NodeInfo

NodeInfo returns information about the node from netmap.

type PatchObjectPrm added in v0.43.0

type PatchObjectPrm struct {
	NewAttributes []objectSDK.Attribute

	ReplaceAttribute bool

	PayloadPatches []PayloadPatch
	// contains filtered or unexported fields
}

PatchObjectPrm groups parameters of PatchObject operation.

func (*PatchObjectPrm) SetAddress added in v0.43.0

func (x *PatchObjectPrm) SetAddress(addr oid.Address)

func (*PatchObjectPrm) SetSessionToken added in v0.43.0

func (x *PatchObjectPrm) SetSessionToken(tok *session.Object)

SetSessionToken sets the token of the session within which the request should be sent.

func (*PatchObjectPrm) SetTTL added in v0.43.0

func (x *PatchObjectPrm) SetTTL(ttl uint32)

SetTTL sets request TTL value.

func (*PatchObjectPrm) SetXHeaders added in v0.43.0

func (x *PatchObjectPrm) SetXHeaders(hs []string)

SetXHeaders sets request X-Headers.

type PatchRes added in v0.43.0

type PatchRes struct {
	OID oid.ID
}

func Patch added in v0.43.0

func Patch(ctx context.Context, prm PatchObjectPrm) (*PatchRes, error)

type PayloadPatch added in v0.43.0

type PayloadPatch struct {
	Range objectSDK.Range

	PayloadPath string
}

type PayloadRangePrm

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

PayloadRangePrm groups parameters of PayloadRange operation.

func (*PayloadRangePrm) SetAddress

func (x *PayloadRangePrm) SetAddress(addr oid.Address)

func (*PayloadRangePrm) SetPayloadWriter

func (x *PayloadRangePrm) SetPayloadWriter(wrt io.Writer)

SetPayloadWriter sets the writer of the object payload.

func (*PayloadRangePrm) SetRange

func (x *PayloadRangePrm) SetRange(rng *objectSDK.Range)

SetRange sets payload range to read.

func (*PayloadRangePrm) SetRawFlag

func (x *PayloadRangePrm) SetRawFlag(raw bool)

SetRawFlag sets flag of raw request.

func (*PayloadRangePrm) SetSessionToken

func (x *PayloadRangePrm) SetSessionToken(tok *session.Object)

SetSessionToken sets the token of the session within which the request should be sent.

func (*PayloadRangePrm) SetTTL

func (x *PayloadRangePrm) SetTTL(ttl uint32)

SetTTL sets request TTL value.

func (*PayloadRangePrm) SetXHeaders

func (x *PayloadRangePrm) SetXHeaders(hs []string)

SetXHeaders sets request X-Headers.

type PayloadRangeRes

type PayloadRangeRes struct{}

PayloadRangeRes groups the resulting values of PayloadRange operation.

func PayloadRange

func PayloadRange(ctx context.Context, prm PayloadRangePrm) (*PayloadRangeRes, error)

PayloadRange reads object payload range from FrostFS and writes it to the specified writer.

Interrupts on any writer error.

Returns any error which prevented the operation from completing correctly in error return. For raw reading, returns *object.SplitInfoError error if object is virtual.

type PutContainerPrm

type PutContainerPrm struct {
	Client       *client.Client
	ClientParams client.PrmContainerPut
}

PutContainerPrm groups parameters of PutContainer operation.

type PutContainerRes

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

PutContainerRes groups the resulting values of PutContainer operation.

func PutContainer

func PutContainer(ctx context.Context, prm PutContainerPrm) (res PutContainerRes, err error)

PutContainer sends a request to save the container in FrostFS.

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

Success can be verified by reading by identifier.

Returns any error which prevented the operation from completing correctly in error return.

func (PutContainerRes) ID

func (x PutContainerRes) ID() cid.ID

ID returns identifier of the created container.

type PutObjectPrm

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

PutObjectPrm groups parameters of PutObject operation.

func (*PutObjectPrm) PrepareLocally added in v0.37.0

func (x *PutObjectPrm) PrepareLocally()

PrepareLocally generate object header on the client side. For big object - split locally too.

func (*PutObjectPrm) SetCopiesNumberByVectors added in v0.37.0

func (x *PutObjectPrm) SetCopiesNumberByVectors(copiesNumbers []uint32)

SetCopiesNumberByVectors sets ordered list of minimal required object copies numbers per placement vector.

func (*PutObjectPrm) SetHeader

func (x *PutObjectPrm) SetHeader(hdr *objectSDK.Object)

SetHeader sets object header.

func (*PutObjectPrm) SetHeaderCallback

func (x *PutObjectPrm) SetHeaderCallback(f func())

SetHeaderCallback sets callback which is called on the object after the header is received but before the payload is written.

func (*PutObjectPrm) SetPayloadReader

func (x *PutObjectPrm) SetPayloadReader(rdr io.Reader)

SetPayloadReader sets reader of the object payload.

func (*PutObjectPrm) SetSessionToken

func (x *PutObjectPrm) SetSessionToken(tok *session.Object)

SetSessionToken sets the token of the session within which the request should be sent.

func (*PutObjectPrm) SetTTL

func (x *PutObjectPrm) SetTTL(ttl uint32)

SetTTL sets request TTL value.

func (*PutObjectPrm) SetXHeaders

func (x *PutObjectPrm) SetXHeaders(hs []string)

SetXHeaders sets request X-Headers.

type PutObjectRes

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

PutObjectRes groups the resulting values of PutObject operation.

func PutObject

func PutObject(ctx context.Context, prm PutObjectPrm) (*PutObjectRes, error)

PutObject saves the object in FrostFS network.

Returns any error which prevented the operation from completing correctly in error return.

func (PutObjectRes) ID

func (x PutObjectRes) ID() oid.ID

ID returns identifier of the created object.

type SearchObjectsPrm

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

SearchObjectsPrm groups parameters of SearchObjects operation.

func (*SearchObjectsPrm) SetContainerID

func (x *SearchObjectsPrm) SetContainerID(id cid.ID)

SetContainerID sets the container identifier.

func (*SearchObjectsPrm) SetFilters

func (x *SearchObjectsPrm) SetFilters(filters objectSDK.SearchFilters)

SetFilters sets search filters.

func (*SearchObjectsPrm) SetSessionToken

func (x *SearchObjectsPrm) SetSessionToken(tok *session.Object)

SetSessionToken sets the token of the session within which the request should be sent.

func (*SearchObjectsPrm) SetTTL

func (x *SearchObjectsPrm) SetTTL(ttl uint32)

SetTTL sets request TTL value.

func (*SearchObjectsPrm) SetXHeaders

func (x *SearchObjectsPrm) SetXHeaders(hs []string)

SetXHeaders sets request X-Headers.

type SearchObjectsRes

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

SearchObjectsRes groups the resulting values of SearchObjects operation.

func SearchObjects

func SearchObjects(ctx context.Context, prm SearchObjectsPrm) (*SearchObjectsRes, error)

SearchObjects selects objects from the container which match the filters.

Returns any error which prevented the operation from completing correctly in error return.

func (SearchObjectsRes) IDList

func (x SearchObjectsRes) IDList() []oid.ID

IDList returns identifiers of the matched objects.

type SyncContainerPrm

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

SyncContainerPrm groups parameters of SyncContainerSettings operation.

func (*SyncContainerPrm) SetClient

func (x *SyncContainerPrm) SetClient(cli *client.Client)

SetClient sets the base client for FrostFS API communication.

func (*SyncContainerPrm) SetContainer

func (s *SyncContainerPrm) SetContainer(c *containerSDK.Container)

SetContainer sets a container that is required to be synced.

type SyncContainerRes

type SyncContainerRes struct{}

SyncContainerRes groups resulting values of SyncContainerSettings operation.

func SyncContainerSettings

func SyncContainerSettings(ctx context.Context, prm SyncContainerPrm) (*SyncContainerRes, error)

SyncContainerSettings reads global network config from FrostFS and syncs container settings with it.

Interrupts on any writer error.

Panics if a container passed as a parameter is nil.

Jump to

Keyboard shortcuts

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