client

package
v2.6.1 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2021 License: MIT Imports: 16 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPushPathQueueClosed indicates the push path is or was closed.
	ErrPushPathQueueClosed = errors.New("push path queue is closed")
)

Functions

This section is empty.

Types

type ArchiveOption

type ArchiveOption func(*pb.ArchiveRequest)

func WithArchiveConfig

func WithArchiveConfig(config *pb.ArchiveConfig) ArchiveOption

WithArchiveConfig allows you to provide a custom ArchiveConfig for a single call to Archive.

type Client

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

Client provides the client api.

func NewClient

func NewClient(target string, opts ...grpc.DialOption) (*Client, error)

NewClient starts the client.

func (*Client) Archive

func (c *Client) Archive(ctx context.Context, key string, opts ...ArchiveOption) error

Archive creates a Filecoin bucket archive via Powergate.

func (*Client) ArchiveWatch

func (c *Client) ArchiveWatch(ctx context.Context, key string, ch chan<- string) error

ArchiveWatch watches status events from a Filecoin bucket archive.

func (*Client) Archives added in v2.2.0

func (c *Client) Archives(ctx context.Context, key string) (*pb.ArchivesResponse, error)

Archives returns information about current and historical archives.

func (*Client) Close

func (c *Client) Close() error

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

func (*Client) Create

func (c *Client) Create(ctx context.Context, opts ...CreateOption) (*pb.CreateResponse, error)

Create initializes a new bucket. The bucket name is only meant to help identify a bucket in a UI and is not unique.

func (*Client) DefaultArchiveConfig

func (c *Client) DefaultArchiveConfig(ctx context.Context, key string) (*pb.ArchiveConfig, error)

DefaultArchiveConfig gets the default archive config for the specified Bucket.

func (c *Client) Links(ctx context.Context, key, pth string) (*pb.LinksResponse, error)

Links returns a list of bucket path URL links.

func (*Client) List

func (c *Client) List(ctx context.Context) (*pb.ListResponse, error)

List returns a list of all bucket roots.

func (*Client) ListIpfsPath

func (c *Client) ListIpfsPath(ctx context.Context, pth path.Path) (*pb.ListIpfsPathResponse, error)

ListIpfsPath returns items at a particular path in a UnixFS path living in the IPFS network.

func (*Client) ListPath

func (c *Client) ListPath(ctx context.Context, key, pth string) (*pb.ListPathResponse, error)

ListPath returns information about a bucket path.

func (*Client) PullIpfsPath

func (c *Client) PullIpfsPath(ctx context.Context, pth path.Path, writer io.Writer, opts ...Option) error

PullIpfsPath pulls the path from a remote UnixFS dag, writing it to writer if it's a file.

func (*Client) PullPath

func (c *Client) PullPath(ctx context.Context, key, pth string, writer io.Writer, opts ...Option) error

PullPath pulls the bucket path, writing it to writer if it's a file.

func (*Client) PullPathAccessRoles

func (c *Client) PullPathAccessRoles(ctx context.Context, key, pth string) (map[string]buckets.Role, error)

PullPathAccessRoles returns access roles for a path.

func (*Client) PushPath

func (c *Client) PushPath(
	ctx context.Context,
	key, pth string,
	reader io.Reader,
	opts ...Option,
) (result path.Resolved, root path.Resolved, err error)

PushPath pushes a file to a bucket path. This will return the resolved path and the bucket's new root path.

func (*Client) PushPathAccessRoles

func (c *Client) PushPathAccessRoles(ctx context.Context, key, pth string, roles map[string]buckets.Role) error

PushPathAccessRoles updates path access roles by merging the pushed roles with existing roles. roles is a map of string marshaled public keys to path roles. A non-nil error is returned if the map keys are not unmarshalable to public keys. To delete a role for a public key, set its value to buckets.None.

func (*Client) PushPaths added in v2.6.0

func (c *Client) PushPaths(ctx context.Context, key string, opts ...Option) (*PushPathsQueue, error)

PushPaths returns a queue that can be used to push multiple files and readers to bucket paths. See PushPathQueue.AddFile and PushPathsQueue.AddReader for more.

func (*Client) Remove

func (c *Client) Remove(ctx context.Context, key string) error

Remove removes an entire bucket. Files and directories will be unpinned.

func (*Client) RemovePath

func (c *Client) RemovePath(ctx context.Context, key, pth string, opts ...Option) (path.Resolved, error)

RemovePath removes the file or directory at path. Files and directories will be unpinned.

func (*Client) Root

func (c *Client) Root(ctx context.Context, key string) (*pb.RootResponse, error)

Root returns the bucket root.

func (*Client) SetDefaultArchiveConfig

func (c *Client) SetDefaultArchiveConfig(ctx context.Context, key string, config *pb.ArchiveConfig) error

SetDefaultArchiveConfig sets the default archive config for the specified Bucket.

func (*Client) SetPath

func (c *Client) SetPath(ctx context.Context, key, pth string, remoteCid cid.Cid) (*pb.SetPathResponse, error)

SetPath set a particular path to an existing IPFS UnixFS DAG.

type CreateOption

type CreateOption func(*createOptions)

func WithCid

func WithCid(c cid.Cid) CreateOption

WithCid indicates that an inited bucket should be boostraped with a particular UnixFS DAG.

func WithName

func WithName(name string) CreateOption

WithName sets a name for the bucket.

func WithPrivate

func WithPrivate(private bool) CreateOption

WithPrivate specifies that an encryption key will be used for the bucket.

func WithUnfreeze added in v2.6.0

func WithUnfreeze(enabled bool) CreateOption

WithUnfreeze indicates that an inited bucket should be boostraped from an imported archive.

type Option

type Option func(*options)

func WithFastForwardOnly

func WithFastForwardOnly(root path.Resolved) Option

WithFastForwardOnly instructs the remote to reject non-fast-forward updates by comparing root with the remote.

func WithProgress

func WithProgress(ch chan<- int64) Option

WithProgress writes progress updates to the given channel.

type PushPathsQueue added in v2.6.0

type PushPathsQueue struct {
	// Current contains the current push result.
	Current PushPathsResult
	// contains filtered or unexported fields
}

PushPathsQueue handles PushPath input and output.

func (*PushPathsQueue) AddFile added in v2.6.0

func (c *PushPathsQueue) AddFile(pth, name string) error

AddFile adds a file to the queue. pth is the location relative to the bucket root at which to insert the file, e.g., "/path/to/mybone.jpg". name is the location of the file on the local filesystem, e.g., "/Users/clyde/Downloads/mybone.jpg".

func (*PushPathsQueue) AddReader added in v2.6.0

func (c *PushPathsQueue) AddReader(pth string, r io.Reader, size int64) error

AddReader adds a reader to the queue. pth is the location relative to the bucket root at which to insert the file, e.g., "/path/to/mybone.jpg". r is the reader to read from. size is the size of the reader. Use of the WithProgress option is not recommended if the reader size is unknown.

func (*PushPathsQueue) Close added in v2.6.0

func (c *PushPathsQueue) Close() error

Close the queue. Failure to close may lead to unpredictable bucket state.

func (*PushPathsQueue) Complete added in v2.6.0

func (c *PushPathsQueue) Complete() int64

Complete returns the portion of the queue size that has been pushed.

func (*PushPathsQueue) Err added in v2.6.0

func (c *PushPathsQueue) Err() error

Err returns the current queue error. Call this method before checking the value of Current.

func (*PushPathsQueue) Next added in v2.6.0

func (c *PushPathsQueue) Next() (ok bool)

Next blocks while the queue is open, returning true when a result is ready. Use Current to access the result.

func (*PushPathsQueue) Size added in v2.6.0

func (c *PushPathsQueue) Size() int64

Size returns the queue size in bytes.

type PushPathsResult added in v2.6.0

type PushPathsResult struct {
	Path   string
	Cid    cid.Cid
	Size   int64
	Pinned int64
	Root   path.Resolved
	// contains filtered or unexported fields
}

PushPathsResult contains the result of a Push.

Jump to

Keyboard shortcuts

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