internal

package
v0.0.0-...-79ba347 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: GPL-3.0 Imports: 25 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(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(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(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(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.PrmContainerDelete
	// contains filtered or unexported fields
}

DeleteContainerPrm groups parameters of DeleteContainerPrm operation.

func (*DeleteContainerPrm) SetClient

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

SetClient sets the base client for FrostFS API communication.

type DeleteContainerRes

type DeleteContainerRes struct{}

DeleteContainerRes groups the resulting values of DeleteContainer operation.

func DeleteContainer

func DeleteContainer(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(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 EACLPrm

type EACLPrm struct {
	client.PrmContainerEACL
	// contains filtered or unexported fields
}

EACLPrm groups parameters of EACL operation.

func (*EACLPrm) SetClient

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

SetClient sets the base client for FrostFS API communication.

type EACLRes

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

EACLRes groups the resulting values of EACL operation.

func EACL

func EACL(prm EACLPrm) (res EACLRes, err error)

EACL reads eACL table from FrostFS by container ID.

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

func (EACLRes) EACL

func (x EACLRes) EACL() eacl.Table

EACL returns requested eACL table.

type GetContainerPrm

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

GetContainerPrm groups parameters of GetContainer operation.

func (*GetContainerPrm) SetClient

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

SetClient sets the base client for FrostFS API communication.

func (*GetContainerPrm) SetContainer

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

SetContainer sets identifier of the container to be read.

type GetContainerRes

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

GetContainerRes groups the resulting values of GetContainer operation.

func GetContainer

func GetContainer(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(*object.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(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() *object.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 []*object.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(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) SetMainOnlyFlag

func (x *HeadObjectPrm) SetMainOnlyFlag(v bool)

SetMainOnlyFlag sets flag to get only main fields of an object header in terms of FrostFS API.

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(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() *object.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(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.

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(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.PrmNetworkInfo
	// contains filtered or unexported fields
}

NetworkInfoPrm groups parameters of NetworkInfo operation.

func (*NetworkInfoPrm) SetClient

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

SetClient sets the base client for FrostFS API communication.

type NetworkInfoRes

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

NetworkInfoRes groups the resulting values of NetworkInfo operation.

func NetworkInfo

func NetworkInfo(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.PrmEndpointInfo
	// contains filtered or unexported fields
}

NodeInfoPrm groups parameters of NodeInfo operation.

func (*NodeInfoPrm) SetClient

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

SetClient sets the base client for FrostFS API communication.

type NodeInfoRes

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

NodeInfoRes groups the resulting values of NodeInfo operation.

func NodeInfo

func NodeInfo(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 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 *object.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(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.PrmContainerPut
	// contains filtered or unexported fields
}

PutContainerPrm groups parameters of PutContainer operation.

func (*PutContainerPrm) SetClient

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

SetClient sets the base client for FrostFS API communication.

type PutContainerRes

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

PutContainerRes groups the resulting values of PutContainer operation.

func PutContainer

func PutContainer(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) SetHeader

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

SetHeader sets object header.

func (*PutObjectPrm) SetHeaderCallback

func (x *PutObjectPrm) SetHeaderCallback(f func(*object.Object))

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(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 object.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(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 SetEACLPrm

type SetEACLPrm struct {
	client.PrmContainerSetEACL
	// contains filtered or unexported fields
}

SetEACLPrm groups parameters of SetEACL operation.

func (*SetEACLPrm) SetClient

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

SetClient sets the base client for FrostFS API communication.

type SetEACLRes

type SetEACLRes struct{}

SetEACLRes groups the resulting values of SetEACL operation.

func SetEACL

func SetEACL(prm SetEACLPrm) (res SetEACLRes, err error)

SetEACL requests to save an eACL table in FrostFS.

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 container identifier.

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

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(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