client

package
v2.6.2 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2021 License: MIT Imports: 21 Imported by: 11

Documentation

Index

Constants

View Source
const AdminKey = ctxKey("admintoken")

AdminKey is the key that should be used to set the admin auth token in a Context.

View Source
const AuthKey = ctxKey("ffstoken")

AuthKey is the key that should be used to set the auth token in a Context.

Variables

This section is empty.

Functions

func CreateClientConn

func CreateClientConn(target string, optsOverrides ...grpc.DialOption) (*grpc.ClientConn, error)

CreateClientConn creates a gRPC connection with sensible defaults and the provided overrides.

Types

type ApplyOption

type ApplyOption func(r *userPb.ApplyStorageConfigRequest)

ApplyOption mutates a push request.

func WithImportDealIDs

func WithImportDealIDs(dealIDs []uint64) ApplyOption

WithImportDealIDs allows to import active on-chain deals to the Cid deals information.

func WithNoExec

func WithNoExec(noExec bool) ApplyOption

WithNoExec allows to configure if a Job should ensure the new storage configuration.

func WithOverride

func WithOverride(override bool) ApplyOption

WithOverride allows a new push configuration to override an existing one. It's used as an extra security measure to avoid unwanted configuration changes.

func WithStorageConfig

func WithStorageConfig(c *userPb.StorageConfig) ApplyOption

WithStorageConfig overrides the Api default Cid configuration.

type Client

type Client struct {
	StorageConfig *StorageConfig
	Data          *Data
	Wallet        *Wallet
	Deals         *Deals
	StorageInfo   *StorageInfo
	StorageJobs   *StorageJobs
	Admin         *admin.Admin
	// contains filtered or unexported fields
}

Client provides the client api.

func NewClient

func NewClient(host string, optsOverrides ...grpc.DialOption) (*Client, error)

NewClient creates a client.

func (*Client) BuildInfo

func (c *Client) BuildInfo(ctx context.Context) (*userPb.BuildInfoResponse, error)

BuildInfo returns build info about the server.

func (*Client) Close

func (c *Client) Close() error

Close closes the client's grpc connection and cancels any active requests.

func (*Client) Host

func (c *Client) Host() string

Host returns the client host address.

func (*Client) UserID

UserID returns the user id.

type Data

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

Data provides access to Powergate general data APIs.

func (*Data) CidInfo

func (d *Data) CidInfo(ctx context.Context, cid string) (*userPb.CidInfoResponse, error)

CidInfo returns information about a cid stored by the user.

func (*Data) CidSummary

func (d *Data) CidSummary(ctx context.Context, cids ...string) (*userPb.CidSummaryResponse, error)

CidSummary gives a summary of the storage and jobs state of the specified cid.

func (*Data) Get

func (d *Data) Get(ctx context.Context, cid string) (io.Reader, error)

Get returns an io.Reader for reading a stored Cid from hot storage.

func (*Data) GetFolder

func (d *Data) GetFolder(ctx context.Context, ipfsRevProxyAddr, cid, outputDir string) error

GetFolder retrieves to outputDir a Cid which corresponds to a folder.

func (*Data) ReplaceData

func (d *Data) ReplaceData(ctx context.Context, cid1, cid2 string) (*userPb.ReplaceDataResponse, error)

ReplaceData pushes a StorageConfig for c2 equal to that of c1, and removes c1. This operation is more efficient than manually removing and adding in two separate operations.

func (*Data) Stage

func (d *Data) Stage(ctx context.Context, data io.Reader) (*userPb.StageResponse, error)

Stage allows to temporarily stage data in hot storage in preparation for pushing a cid storage config.

func (*Data) StageFolder

func (d *Data) StageFolder(ctx context.Context, ipfsRevProxyAddr string, folderPath string) (string, error)

StageFolder allows to temporarily stage a folder in hot storage in preparation for pushing a cid storage config.

func (*Data) WatchLogs

func (d *Data) WatchLogs(ctx context.Context, ch chan<- WatchLogsEvent, cid string, opts ...WatchLogsOption) error

WatchLogs pushes human-friendly messages about Cid executions. The method is blocking and will continue to send messages until the context is canceled. The provided channel is owned by the method and must not be closed.

type DealRecordsOption

type DealRecordsOption func(*userPb.DealRecordsConfig)

DealRecordsOption updates a ListDealRecordsConfig.

func WithAscending

func WithAscending(ascending bool) DealRecordsOption

WithAscending specifies to sort the results in ascending order. Default is descending order. Records are sorted by timestamp.

func WithDataCids

func WithDataCids(cids ...string) DealRecordsOption

WithDataCids limits the results to deals for the provided data cids. If WithFromAddrs is also provided, this is an AND operation.

func WithFromAddrs

func WithFromAddrs(addrs ...string) DealRecordsOption

WithFromAddrs limits the results deals initiated from the provided wallet addresses. If WithDataCids is also provided, this is an AND operation.

func WithIncludeFailed added in v2.1.0

func WithIncludeFailed(includeFailed bool) DealRecordsOption

WithIncludeFailed specifies if failed records will be included in the output.

func WithIncludeFinal

func WithIncludeFinal(includeFinal bool) DealRecordsOption

WithIncludeFinal specifies whether or not to include final deals in the results. Default is false. Ignored for ListRetrievalDealRecords.

func WithIncludePending

func WithIncludePending(includePending bool) DealRecordsOption

WithIncludePending specifies whether or not to include pending deals in the results. Default is false. Ignored for ListRetrievalDealRecords.

type Deals

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

Deals provides access to Powergate deals APIs.

func (*Deals) RetrievalDealRecords

func (d *Deals) RetrievalDealRecords(ctx context.Context, opts ...DealRecordsOption) (*userPb.RetrievalDealRecordsResponse, error)

RetrievalDealRecords returns a list of retrieval deals for the user according to the provided options.

func (*Deals) StorageDealRecords

func (d *Deals) StorageDealRecords(ctx context.Context, opts ...DealRecordsOption) (*userPb.StorageDealRecordsResponse, error)

StorageDealRecords returns a list of storage deals for the user according to the provided options.

type ListConfig

type ListConfig struct {
	// CidFilter filters StorageJobs list to the specified cid. Defaults to no filter.
	CidFilter string
	// Limit limits the number of StorageJobs returned. Defaults to no limit.
	Limit uint64
	// Ascending returns the StorageJobs ascending by time. Defaults to false, descending.
	Ascending bool
	// Select specifies to return StorageJobs in the specified state.
	Select ListSelect
	// NextPageToken sets the slug from which to start building the next page of results.
	NextPageToken string
}

ListConfig controls the behavior for listing StorageJobs.

type ListSelect

type ListSelect int32

ListSelect specifies which StorageJobs to list.

const (
	// All lists all StorageJobs and is the default.
	All ListSelect = iota
	// Queued lists queued StorageJobs.
	Queued
	// Executing lists executing StorageJobs.
	Executing
	// Final lists final StorageJobs.
	Final
)

type NewAddressOption

type NewAddressOption func(r *userPb.NewAddressRequest)

NewAddressOption is a function that changes a NewAddressConfig.

func WithAddressType

func WithAddressType(addressType string) NewAddressOption

WithAddressType specifies the type of address to create.

func WithMakeDefault

func WithMakeDefault(makeDefault bool) NewAddressOption

WithMakeDefault specifies if the new address should become the default.

type StorageConfig

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

StorageConfig provides access to Powergate storage config APIs.

func (*StorageConfig) Apply

Apply push a new configuration for the Cid in hot and cold storage.

func (*StorageConfig) Default

Default returns the default storage config.

func (*StorageConfig) Remove

func (s *StorageConfig) Remove(ctx context.Context, cid string) (*userPb.RemoveResponse, error)

Remove removes a Cid from being tracked as an active storage. The Cid should have both Hot and Cold storage disabled, if that isn't the case it will return ErrActiveInStorage.

func (*StorageConfig) SetDefault

SetDefault sets the default storage config.

type StorageInfo

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

StorageInfo provides access to Powergate storage indo APIs.

func (*StorageInfo) Get

Get returns the information about a stored Cid. If no information is available, since the Cid was never stored, it returns an error with codes.NotFound.

func (*StorageInfo) List

List returns a list of information about all stored cids, filtered by cids if provided.

type StorageJobs

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

StorageJobs provides access to Powergate jobs APIs.

func (*StorageJobs) Cancel

Cancel signals that the executing Job with JobID jid should be canceled.

func (*StorageJobs) Get

Get returns the current state of the specified job.

func (*StorageJobs) List

List lists StorageJobs according to the provided ListConfig.

func (*StorageJobs) StorageConfig

func (j *StorageJobs) StorageConfig(ctx context.Context, jobID string) (*userPb.StorageConfigForJobResponse, error)

StorageConfig returns the StorageConfig associated with the specified job.

func (*StorageJobs) Summary

Summary returns a summary of storage jobs.

func (*StorageJobs) Watch

func (j *StorageJobs) Watch(ctx context.Context, ch chan<- WatchStorageJobsEvent, jobIDs ...string) error

Watch pushes JobEvents to the provided channel. The provided channel will be owned by the client after the call, so it shouldn't be closed by the client. To stop receiving events, the provided ctx should be canceled. If an error occurs, it will be returned in the Err field of JobEvent and the channel will be closed.

type SummaryOption

type SummaryOption = func(*summaryConfig)

SummaryOption configures a storageJobsConfig.

func WithCid

func WithCid(cid string) SummaryOption

WithCid filters the results to the specified data cid.

type TokenAuth

type TokenAuth struct {
	Secure bool
}

TokenAuth provides token based auth.

func (TokenAuth) GetRequestMetadata

func (t TokenAuth) GetRequestMetadata(ctx context.Context, _ ...string) (map[string]string, error)

GetRequestMetadata returns request metadata that includes the auth token.

func (TokenAuth) RequireTransportSecurity

func (t TokenAuth) RequireTransportSecurity() bool

RequireTransportSecurity specifies if the connection should be secure.

type Wallet

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

Wallet provides an API for managing filecoin wallets.

func (*Wallet) Addresses

func (w *Wallet) Addresses(ctx context.Context) (*userPb.AddressesResponse, error)

Addresses returns a list of addresses managed by the user. Each addresses *could* have verified-client information. If VerifiedClientInfo is nil, then the address isn't verified.

func (*Wallet) Balance

func (w *Wallet) Balance(ctx context.Context, address string) (*userPb.BalanceResponse, error)

Balance gets a filecoin wallet's balance.

func (*Wallet) NewAddress

func (w *Wallet) NewAddress(ctx context.Context, name string, options ...NewAddressOption) (*userPb.NewAddressResponse, error)

NewAddress creates a new wallet address managed by the user.

func (*Wallet) SendFil

func (w *Wallet) SendFil(ctx context.Context, from string, to string, amount *big.Int) (*userPb.SendFilResponse, error)

SendFil sends fil from a managed address to any another address, returns immediately but funds are sent asynchronously.

func (*Wallet) SignMessage

func (w *Wallet) SignMessage(ctx context.Context, address string, message []byte) (*userPb.SignMessageResponse, error)

SignMessage signs a message with a user wallet address.

func (*Wallet) VerifyMessage

func (w *Wallet) VerifyMessage(ctx context.Context, address string, message, signature []byte) (*userPb.VerifyMessageResponse, error)

VerifyMessage verifies a message signature from a wallet address.

type WatchLogsEvent

type WatchLogsEvent struct {
	Res *userPb.WatchLogsResponse
	Err error
}

WatchLogsEvent represents an event for watching cid logs.

type WatchLogsOption

type WatchLogsOption func(r *userPb.WatchLogsRequest)

WatchLogsOption is a function that changes GetLogsConfig.

func WithHistory

func WithHistory(enabled bool) WatchLogsOption

WithHistory indicates that prior history logs should be sent in the channel before getting real time logs.

func WithJobIDFilter

func WithJobIDFilter(jobID string) WatchLogsOption

WithJobIDFilter filters only log messages of a Cid related to the Job with id jid.

type WatchStorageJobsEvent

type WatchStorageJobsEvent struct {
	Res *userPb.WatchStorageJobsResponse
	Err error
}

WatchStorageJobsEvent represents an event for Watching a job.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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