client

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2020 License: MIT Imports: 21 Imported by: 7

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 added in v0.3.0

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 added in v1.0.0

type ApplyOption func(r *userPb.ApplyStorageConfigRequest)

ApplyOption mutates a push request.

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 added in v0.2.0

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
	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 added in v0.4.0

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 added in v0.4.0

func (c *Client) Host() string

Host returns the client host address.

func (*Client) UserID added in v1.1.0

UserID returns the user id.

type Data added in v1.0.0

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

Data provides access to Powergate general data APIs.

func (*Data) CidInfo added in v1.0.0

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

CidInfo returns information about cids stored by the user.

func (*Data) Get added in v1.0.0

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 added in v1.0.0

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 added in v1.0.0

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 added in v1.0.0

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 added in v1.0.0

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 added in v1.0.0

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 added in v1.0.0

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 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 added in v1.0.0

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 added in v1.0.0

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 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 added in v1.0.0

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

StorageConfig provides access to Powergate storage config APIs.

func (*StorageConfig) Apply added in v1.0.0

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

func (*StorageConfig) Default added in v1.0.0

Default returns the default storage config.

func (*StorageConfig) Remove added in v1.0.0

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 added in v1.0.0

SetDefault sets the default storage config.

type StorageJobs added in v1.0.0

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

StorageJobs provides access to Powergate jobs APIs.

func (*StorageJobs) Cancel added in v1.0.0

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

func (*StorageJobs) Executing added in v1.0.0

Executing returns a list of executing storage jobs.

func (*StorageJobs) LatestFinal added in v1.0.0

func (j *StorageJobs) LatestFinal(ctx context.Context, cids ...string) (*userPb.LatestFinalStorageJobsResponse, error)

LatestFinal returns a list of latest final storage jobs.

func (*StorageJobs) LatestSuccessful added in v1.0.0

func (j *StorageJobs) LatestSuccessful(ctx context.Context, cids ...string) (*userPb.LatestSuccessfulStorageJobsResponse, error)

LatestSuccessful returns a list of latest successful storage jobs.

func (*StorageJobs) Queued added in v1.0.0

Queued returns a list of queued storage jobs.

func (*StorageJobs) StorageConfigForJob added in v1.0.0

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

StorageConfigForJob returns the StorageConfig associated with the specified job.

func (*StorageJobs) StorageJob added in v1.0.0

func (j *StorageJobs) StorageJob(ctx context.Context, jobID string) (*userPb.StorageJobResponse, error)

StorageJob returns the current state of the specified job.

func (*StorageJobs) Summary added in v1.0.0

Summary returns a summary of storage jobs.

func (*StorageJobs) Watch added in v1.0.0

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 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 added in v1.0.0

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

Addresses returns a list of addresses managed by the user.

func (*Wallet) Balance added in v0.1.1

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

Balance gets a filecoin wallet's balance.

func (*Wallet) NewAddress added in v0.1.1

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 added in v0.1.1

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 added in v1.0.0

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 added in v1.0.0

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 added in v1.0.0

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 added in v1.0.0

func WithJobIDFilter(jobID string) WatchLogsOption

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

type WatchStorageJobsEvent added in v1.0.0

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