powergate: github.com/textileio/powergate/api/client Index | Files | Directories

package client

import "github.com/textileio/powergate/api/client"


Package Files

client.go data.go deals.go storageconfig.go storagejobs.go wallet.go


const AdminKey = ctxKey("admintoken")

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

const AuthKey = ctxKey("ffstoken")

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

func CreateClientConn Uses

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

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

type ApplyOption Uses

type ApplyOption func(r *userPb.ApplyStorageConfigRequest)

ApplyOption mutates a push request.

func WithOverride Uses

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 Uses

func WithStorageConfig(c *userPb.StorageConfig) ApplyOption

WithStorageConfig overrides the Api default Cid configuration.

type Client Uses

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 Uses

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

NewClient creates a client.

func (*Client) BuildInfo Uses

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

BuildInfo returns build info about the server.

func (*Client) Close Uses

func (c *Client) Close() error

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

func (*Client) Host Uses

func (c *Client) Host() string

Host returns the client host address.

func (*Client) UserID Uses

func (c *Client) UserID(ctx context.Context) (*userPb.UserIdentifierResponse, error)

UserID returns the user id.

type Data Uses

type Data struct {
    // contains filtered or unexported fields

Data provides access to Powergate general data APIs.

func (*Data) CidInfo Uses

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

CidInfo returns information about cids stored by the user.

func (*Data) Get Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

type DealRecordsOption func(*userPb.DealRecordsConfig)

DealRecordsOption updates a ListDealRecordsConfig.

func WithAscending Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

type Deals struct {
    // contains filtered or unexported fields

Deals provides access to Powergate deals APIs.

func (*Deals) RetrievalDealRecords Uses

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 Uses

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 Uses

type NewAddressOption func(r *userPb.NewAddressRequest)

NewAddressOption is a function that changes a NewAddressConfig.

func WithAddressType Uses

func WithAddressType(addressType string) NewAddressOption

WithAddressType specifies the type of address to create.

func WithMakeDefault Uses

func WithMakeDefault(makeDefault bool) NewAddressOption

WithMakeDefault specifies if the new address should become the default.

type StorageConfig Uses

type StorageConfig struct {
    // contains filtered or unexported fields

StorageConfig provides access to Powergate storage config APIs.

func (*StorageConfig) Apply Uses

func (s *StorageConfig) Apply(ctx context.Context, cid string, opts ...ApplyOption) (*userPb.ApplyStorageConfigResponse, error)

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

func (*StorageConfig) Default Uses

func (s *StorageConfig) Default(ctx context.Context) (*userPb.DefaultStorageConfigResponse, error)

Default returns the default storage config.

func (*StorageConfig) Remove Uses

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 Uses

func (s *StorageConfig) SetDefault(ctx context.Context, config *userPb.StorageConfig) (*userPb.SetDefaultStorageConfigResponse, error)

SetDefault sets the default storage config.

type StorageJobs Uses

type StorageJobs struct {
    // contains filtered or unexported fields

StorageJobs provides access to Powergate jobs APIs.

func (*StorageJobs) Cancel Uses

func (j *StorageJobs) Cancel(ctx context.Context, jobID string) (*userPb.CancelStorageJobResponse, error)

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

func (*StorageJobs) Executing Uses

func (j *StorageJobs) Executing(ctx context.Context, cids ...string) (*userPb.ExecutingStorageJobsResponse, error)

Executing returns a list of executing storage jobs.

func (*StorageJobs) LatestFinal Uses

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

LatestFinal returns a list of latest final storage jobs.

func (*StorageJobs) LatestSuccessful Uses

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

LatestSuccessful returns a list of latest successful storage jobs.

func (*StorageJobs) Queued Uses

func (j *StorageJobs) Queued(ctx context.Context, cids ...string) (*userPb.QueuedStorageJobsResponse, error)

Queued returns a list of queued storage jobs.

func (*StorageJobs) StorageConfigForJob Uses

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

StorageConfigForJob returns the StorageConfig associated with the specified job.

func (*StorageJobs) StorageJob Uses

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

StorageJob returns the current state of the specified job.

func (*StorageJobs) Summary Uses

func (j *StorageJobs) Summary(ctx context.Context, cids ...string) (*userPb.StorageJobsSummaryResponse, error)

Summary returns a summary of storage jobs.

func (*StorageJobs) Watch Uses

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 Uses

type TokenAuth struct {
    Secure bool

TokenAuth provides token based auth.

func (TokenAuth) GetRequestMetadata Uses

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

GetRequestMetadata returns request metadata that includes the auth token.

func (TokenAuth) RequireTransportSecurity Uses

func (t TokenAuth) RequireTransportSecurity() bool

RequireTransportSecurity specifies if the connection should be secure.

type Wallet Uses

type Wallet struct {
    // contains filtered or unexported fields

Wallet provides an API for managing filecoin wallets.

func (*Wallet) Addresses Uses

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

Addresses returns a list of addresses managed by the user.

func (*Wallet) Balance Uses

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

Balance gets a filecoin wallet's balance.

func (*Wallet) NewAddress Uses

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 Uses

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 Uses

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 Uses

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 Uses

type WatchLogsEvent struct {
    Res *userPb.WatchLogsResponse
    Err error

WatchLogsEvent represents an event for watching cid logs.

type WatchLogsOption Uses

type WatchLogsOption func(r *userPb.WatchLogsRequest)

WatchLogsOption is a function that changes GetLogsConfig.

func WithHistory Uses

func WithHistory(enabled bool) WatchLogsOption

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

func WithJobIDFilter Uses

func WithJobIDFilter(jobID string) WatchLogsOption

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

type WatchStorageJobsEvent Uses

type WatchStorageJobsEvent struct {
    Res *userPb.WatchStorageJobsResponse
    Err error

WatchStorageJobsEvent represents an event for Watching a job.



Package client imports 21 packages (graph) and is imported by 6 packages. Updated 2020-11-17. Refresh now. Tools for package owners.