Documentation ¶
Overview ¶
package shell implements a remote API interface for a running btfs daemon
Index ¶
- Constants
- Variables
- func NewSessionSignature(hash string, peerIdStr string, uts string, verifyBefore bool) (string, error)
- func VerifySessionSignature(offSignRenterPid peer.ID, data string, sessionSigStr string) error
- type AddOpts
- type ContractItem
- type Contracts
- type Error
- type FilesOpt
- type FilesStatObject
- type IdOutput
- type IpfsObject
- type Key
- type KeyOpt
- type KeyRenameObject
- type Logger
- type LsLink
- type LsObject
- type Message
- type MfsLsEntry
- type ObjectLink
- type ObjectStats
- type PeerInfo
- type PeersList
- type PinInfo
- type PinStreamInfo
- type PubSubSubscription
- type PublishResponse
- type Request
- type RequestBuilder
- func (r *RequestBuilder) Arguments(args ...string) *RequestBuilder
- func (r *RequestBuilder) Body(body io.Reader) *RequestBuilder
- func (r *RequestBuilder) BodyBytes(body []byte) *RequestBuilder
- func (r *RequestBuilder) BodyString(body string) *RequestBuilder
- func (r *RequestBuilder) Exec(ctx context.Context, res interface{}) error
- func (r *RequestBuilder) Header(name, value string) *RequestBuilder
- func (r *RequestBuilder) Option(key string, value interface{}) *RequestBuilder
- func (r *RequestBuilder) Send(ctx context.Context) (*Response, error)
- type Response
- type Shard
- type Shell
- func (s *Shell) Add(r io.Reader, options ...AddOpts) (string, error)
- func (s *Shell) AddDir(dir string) (string, error)
- func (s *Shell) AddLink(target string) (string, error)
- func (s *Shell) AddMultiPartFileDir(dir files.Directory, reedSolomon bool) (string, error)
- func (s *Shell) AddNoPin(r io.Reader) (string, error)
- func (s *Shell) AddSerialFileDir(dir string, reedSolomon bool) (string, error)
- func (s *Shell) AddSlicedDirectory(dir files.Directory, reedSolomon bool) (string, error)
- func (s *Shell) AddWithOpts(r io.Reader, pin bool, rawLeaves bool) (string, error)
- func (s *Shell) BlockGet(path string) ([]byte, error)
- func (s *Shell) BlockPut(block []byte, format, mhtype string, mhlen int) (string, error)
- func (s *Shell) BlockStat(path string) (string, int, error)
- func (s *Shell) BootstrapAdd(peers []string) ([]string, error)
- func (s *Shell) BootstrapAddDefault() ([]string, error)
- func (s *Shell) BootstrapRmAll() ([]string, error)
- func (s *Shell) Cat(path string) (io.ReadCloser, error)
- func (s *Shell) DagGet(ref string, out interface{}) error
- func (s *Shell) DagPut(data interface{}, ienc, kind string) (string, error)
- func (s *Shell) DagPutWithOpts(data interface{}, opts ...options.DagPutOption) (string, error)
- func (s *Shell) FileList(path string) (*UnixLsObject, error)
- func (s *Shell) FilesChcid(ctx context.Context, path string, options ...FilesOpt) error
- func (s *Shell) FilesCp(ctx context.Context, src string, dest string) error
- func (s *Shell) FilesFlush(ctx context.Context, path string) (string, error)
- func (s *Shell) FilesLs(ctx context.Context, path string, options ...FilesOpt) ([]*MfsLsEntry, error)
- func (s *Shell) FilesMkdir(ctx context.Context, path string, options ...FilesOpt) error
- func (s *Shell) FilesMv(ctx context.Context, src string, dest string) error
- func (s *Shell) FilesRead(ctx context.Context, path string, options ...FilesOpt) (io.ReadCloser, error)
- func (s *Shell) FilesRm(ctx context.Context, path string, force bool) error
- func (s *Shell) FilesStat(ctx context.Context, path string, options ...FilesOpt) (*FilesStatObject, error)
- func (s *Shell) FilesWrite(ctx context.Context, path string, data io.Reader, options ...FilesOpt) error
- func (s *Shell) FindPeer(peer string) (*PeerInfo, error)
- func (s *Shell) Get(hash, outdir string) error
- func (s *Shell) GetLogs(ctx context.Context) (Logger, error)
- func (s *Shell) GetUts() string
- func (s *Shell) ID(peer ...string) (*IdOutput, error)
- func (s *Shell) IsUp() bool
- func (s *Shell) KeyGen(ctx context.Context, name string, options ...KeyOpt) (*Key, error)
- func (s *Shell) KeyList(ctx context.Context) ([]*Key, error)
- func (s *Shell) KeyRename(ctx context.Context, old string, new string, force bool) (*KeyRenameObject, error)
- func (s *Shell) KeyRm(ctx context.Context, name string) ([]*Key, error)
- func (s *Shell) List(path string) ([]*LsLink, error)
- func (s *Shell) NewObject(template string) (string, error)
- func (s *Shell) ObjectGet(path string) (*IpfsObject, error)
- func (s *Shell) ObjectPut(obj *IpfsObject) (string, error)
- func (s *Shell) ObjectStat(key string) (*ObjectStats, error)
- func (s *Shell) Patch(root, action string, args ...string) (string, error)
- func (s *Shell) PatchData(root string, set bool, data interface{}) (string, error)
- func (s *Shell) PatchLink(root, path, childhash string, create bool) (string, error)
- func (s *Shell) Pin(path string) error
- func (s *Shell) Pins() (map[string]PinInfo, error)
- func (s *Shell) PinsStream(ctx context.Context) (<-chan PinStreamInfo, error)
- func (s *Shell) PubSubPublish(topic, data string) (err error)
- func (s *Shell) PubSubSubscribe(topic string) (*PubSubSubscription, error)
- func (s *Shell) Publish(node string, value string) error
- func (s *Shell) PublishWithDetails(contentHash, key string, lifetime, ttl time.Duration, resolve bool) (*PublishResponse, error)
- func (s *Shell) Refs(hash string, recursive bool) (<-chan string, error)
- func (s *Shell) Remove(hash string) bool
- func (s *Shell) Request(command string, args ...string) *RequestBuilder
- func (s *Shell) Resolve(id string) (string, error)
- func (s *Shell) ResolvePath(path string) (string, error)
- func (s *Shell) SetTimeout(d time.Duration)
- func (s *Shell) StatsBW(ctx context.Context) (*p2pmetrics.Stats, error)
- func (s *Shell) StorageUpload(hash string, options ...StorageUploadOpts) (string, error)
- func (s *Shell) StorageUploadGetContractBatch(sid string, uts string, t string) (*Contracts, error)
- func (s *Shell) StorageUploadGetUnsignedData(sid string, uts string, sessionStatus string) (*UnsignedData, error)
- func (s *Shell) StorageUploadOffSign(hash string, uts string, options ...StorageUploadOpts) (string, error)
- func (s *Shell) StorageUploadSign(id string, hash string, unsignedData *UnsignedData, uts string, ...) ([]byte, error)
- func (s *Shell) StorageUploadSignBalance(id string, unsignedData *UnsignedData, uts string, sessionStatus string) error
- func (s *Shell) StorageUploadSignBatch(sid string, unsignedBatchContracts *Contracts, uts string, t string) error
- func (s *Shell) StorageUploadSignGuardFileMeta(id string, unsignedData *UnsignedData, uts string, sessionStatus string) error
- func (s *Shell) StorageUploadSignGuardQuestions(id string, unsignedData *UnsignedData, uts string, sessionStatus string) error
- func (s *Shell) StorageUploadSignPayChannel(id string, unsignedData *UnsignedData, uts string, sessionStatus string, ...) error
- func (s *Shell) StorageUploadSignPayRequest(id string, unsignedData *UnsignedData, uts string, sessionStatus string) error
- func (s *Shell) StorageUploadSignWaitupload(id string, unsignedData *UnsignedData, uts string, sessionStatus string) error
- func (s *Shell) StorageUploadStatus(id string) (*Storage, error)
- func (s *Shell) SwarmConnect(ctx context.Context, addr ...string) error
- func (s *Shell) SwarmPeers(ctx context.Context) (*SwarmConnInfos, error)
- func (s *Shell) Unpin(path string) error
- func (s *Shell) Version() (string, string, error)
- type Storage
- type StorageOpts
- type StorageUploadOpts
- type SwarmConnInfo
- type SwarmConnInfos
- type SwarmStreamInfo
- type UnixLsLink
- type UnixLsObject
- type UnsignedData
Constants ¶
const ( DefaultPathName = ".btfs" DefaultPathRoot = "~/" + DefaultPathName DefaultApiFile = "api" EnvDir = "BTFS_PATH" )
const ( TRaw = iota TDirectory TFile TMetadata TSymlink )
const ( DirectPin = "direct" RecursivePin = "recursive" IndirectPin = "indirect" )
const (
API_VERSION = "v1"
)
Variables ¶
var ( FilesLs filesLs FilesChcid filesChcid FilesMkdir filesMkdir FilesRead filesRead FilesWrite filesWrite FilesStat filesStat )
var KeyGen keyGen
Functions ¶
func NewSessionSignature ¶ added in v0.2.1
Types ¶
type AddOpts ¶
type AddOpts = func(*RequestBuilder) error
func CidVersion ¶ added in v0.1.1
CidVersion allows for selecting the CID version that btfs should use.
type ContractItem ¶ added in v0.1.7
type Contracts ¶ added in v0.1.7
type Contracts struct {
Contracts []ContractItem `json:contracts`
}
type FilesOpt ¶ added in v0.4.0
type FilesOpt func(*RequestBuilder) error
type FilesStatObject ¶ added in v0.4.0
type IpfsObject ¶
type IpfsObject struct { Links []ObjectLink Data string }
type KeyOpt ¶ added in v0.4.0
type KeyOpt func(*RequestBuilder) error
type KeyRenameObject ¶ added in v0.4.0
type Logger ¶ added in v0.1.1
type Logger struct {
// contains filtered or unexported fields
}
Logger is used to handle incoming logs from the btfs node
type MfsLsEntry ¶ added in v0.4.0
type ObjectLink ¶
type ObjectStats ¶
type PinStreamInfo ¶ added in v0.3.0
PinStreamInfo is the output type for PinsStream
type PubSubSubscription ¶
type PubSubSubscription struct {
// contains filtered or unexported fields
}
PubSubSubscription allow you to receive pubsub records that where published on the network.
func (*PubSubSubscription) Cancel ¶
func (s *PubSubSubscription) Cancel() error
Cancel cancels the given subscription.
func (*PubSubSubscription) Next ¶
func (s *PubSubSubscription) Next() (*Message, error)
Next waits for the next record and returns that.
type PublishResponse ¶
type Request ¶
type Request struct { Ctx context.Context ApiBase string Command string Args []string Opts map[string]string Body io.Reader Headers map[string]string }
func NewRequest ¶
type RequestBuilder ¶
type RequestBuilder struct {
// contains filtered or unexported fields
}
RequestBuilder is an IPFS commands request builder.
func (*RequestBuilder) Arguments ¶
func (r *RequestBuilder) Arguments(args ...string) *RequestBuilder
Arguments adds the arguments to the args.
func (*RequestBuilder) Body ¶
func (r *RequestBuilder) Body(body io.Reader) *RequestBuilder
Body sets the request body to the given reader.
func (*RequestBuilder) BodyBytes ¶
func (r *RequestBuilder) BodyBytes(body []byte) *RequestBuilder
BodyBytes sets the request body to the given buffer.
func (*RequestBuilder) BodyString ¶
func (r *RequestBuilder) BodyString(body string) *RequestBuilder
BodyString sets the request body to the given string.
func (*RequestBuilder) Exec ¶
func (r *RequestBuilder) Exec(ctx context.Context, res interface{}) error
Exec sends the request a request and decodes the response.
func (*RequestBuilder) Header ¶
func (r *RequestBuilder) Header(name, value string) *RequestBuilder
Header sets the given header.
func (*RequestBuilder) Option ¶
func (r *RequestBuilder) Option(key string, value interface{}) *RequestBuilder
Option sets the given option.
type Response ¶
type Response struct { Output io.ReadCloser Error *Error }
type Shell ¶
type Shell struct {
// contains filtered or unexported fields
}
func NewLocalShell ¶
func NewLocalShell() *Shell
func (*Shell) AddMultiPartFileDir ¶ added in v0.2.0
func (*Shell) AddNoPin ¶
AddNoPin adds a file to btfs without pinning it Deprecated: Use Add() with option functions instead
func (*Shell) AddSerialFileDir ¶ added in v0.2.0
AddDir adds a directory recursively with all of the files under it
func (*Shell) AddSlicedDirectory ¶ added in v0.2.0
func (*Shell) AddWithOpts ¶
AddWithOpts adds a file to btfs with some additional options Deprecated: Use Add() with option functions instead
func (*Shell) BootstrapAddDefault ¶
func (*Shell) BootstrapRmAll ¶
func (*Shell) Cat ¶
func (s *Shell) Cat(path string) (io.ReadCloser, error)
Cat the content at the given path. Callers need to drain and close the returned reader after usage.
func (*Shell) DagPutWithOpts ¶
func (s *Shell) DagPutWithOpts(data interface{}, opts ...options.DagPutOption) (string, error)
func (*Shell) FileList ¶
func (s *Shell) FileList(path string) (*UnixLsObject, error)
FileList entries at the given path using the UnixFS commands
func (*Shell) FilesChcid ¶ added in v0.4.0
FilesChcid change the cid version or hash function of the root node of a given path
func (*Shell) FilesCp ¶ added in v0.4.0
FilesCp copy any IPFS files and directories into MFS (or copy within MFS)
func (*Shell) FilesFlush ¶ added in v0.4.0
FilesFlush flush a given path's data to disk
func (*Shell) FilesLs ¶ added in v0.4.0
func (s *Shell) FilesLs(ctx context.Context, path string, options ...FilesOpt) ([]*MfsLsEntry, error)
FilesLs list directories in the local mutable namespace
func (*Shell) FilesMkdir ¶ added in v0.4.0
FilesMkdir make directories
func (*Shell) FilesRead ¶ added in v0.4.0
func (s *Shell) FilesRead(ctx context.Context, path string, options ...FilesOpt) (io.ReadCloser, error)
FilesRead read a file in a given MFS
func (*Shell) FilesStat ¶ added in v0.4.0
func (s *Shell) FilesStat(ctx context.Context, path string, options ...FilesOpt) (*FilesStatObject, error)
FilesStat display file status
func (*Shell) FilesWrite ¶ added in v0.4.0
func (s *Shell) FilesWrite(ctx context.Context, path string, data io.Reader, options ...FilesOpt) error
FilesWrite write to a mutable file in a given filesystem
func (*Shell) ID ¶
ID gets information about a given peer. Arguments:
peer: peer.ID of the node to look up. If no peer is specified,
return information about the local peer.
func (*Shell) KeyRename ¶ added in v0.4.0
func (s *Shell) KeyRename(ctx context.Context, old string, new string, force bool) (*KeyRenameObject, error)
KeyRename Rename a keypair
func (*Shell) ObjectStat ¶
func (s *Shell) ObjectStat(key string) (*ObjectStats, error)
ObjectStat gets stats for the DAG object named by key. It returns the stats of the requested Object or an error.
func (*Shell) Pins ¶
Pins returns a map of the pin hashes to their info (currently just the pin type, one of DirectPin, RecursivePin, or IndirectPin). A map is returned instead of a slice because it is easier to do existence lookup by map key than unordered array searching. The map is likely to be more useful to a client than a flat list.
func (*Shell) PinsStream ¶ added in v0.3.0
func (s *Shell) PinsStream(ctx context.Context) (<-chan PinStreamInfo, error)
PinsStream is a streamed version of Pins. It returns a channel of the pins with their type, one of DirectPin, RecursivePin, or IndirectPin.
func (*Shell) PubSubPublish ¶
func (*Shell) PubSubSubscribe ¶
func (s *Shell) PubSubSubscribe(topic string) (*PubSubSubscription, error)
func (*Shell) PublishWithDetails ¶
func (s *Shell) PublishWithDetails(contentHash, key string, lifetime, ttl time.Duration, resolve bool) (*PublishResponse, error)
PublishWithDetails is used for fine grained control over record publishing
func (*Shell) Resolve ¶
Resolve gets resolves the string provided to an /ipns/[name]. If asked to resolve an empty string, resolve instead resolves the node's own /ipns value.
func (*Shell) SetTimeout ¶
func (*Shell) StatsBW ¶
ObjectStat gets stats for the DAG object named by key. It returns the stats of the requested Object or an error.
func (*Shell) StorageUpload ¶ added in v0.1.4
func (s *Shell) StorageUpload(hash string, options ...StorageUploadOpts) (string, error)
Storage upload api.
func (*Shell) StorageUploadGetContractBatch ¶ added in v0.1.7
Storage upload get offline contract batch api.
func (*Shell) StorageUploadGetUnsignedData ¶ added in v0.1.7
func (s *Shell) StorageUploadGetUnsignedData(sid string, uts string, sessionStatus string) (*UnsignedData, error)
Storage upload get offline unsigned data api.
func (*Shell) StorageUploadOffSign ¶ added in v0.1.7
func (s *Shell) StorageUploadOffSign(hash string, uts string, options ...StorageUploadOpts) (string, error)
Storage upload api.
func (*Shell) StorageUploadSign ¶ added in v0.1.7
func (s *Shell) StorageUploadSign(id string, hash string, unsignedData *UnsignedData, uts string, sessionStatus string) ([]byte, error)
Storage upload sign offline data api.
func (*Shell) StorageUploadSignBalance ¶ added in v0.1.7
func (*Shell) StorageUploadSignBatch ¶ added in v0.1.7
func (s *Shell) StorageUploadSignBatch(sid string, unsignedBatchContracts *Contracts, uts string, t string) error
Storage upload sign offline contract batch api.
func (*Shell) StorageUploadSignGuardFileMeta ¶ added in v0.1.7
func (*Shell) StorageUploadSignGuardQuestions ¶ added in v0.2.2
func (*Shell) StorageUploadSignPayChannel ¶ added in v0.1.7
func (*Shell) StorageUploadSignPayRequest ¶ added in v0.1.7
func (*Shell) StorageUploadSignWaitupload ¶ added in v0.2.2
func (*Shell) StorageUploadStatus ¶ added in v0.1.4
Storage upload status api.
func (*Shell) SwarmConnect ¶
SwarmConnect opens a swarm connection to a specific address.
func (*Shell) SwarmPeers ¶
func (s *Shell) SwarmPeers(ctx context.Context) (*SwarmConnInfos, error)
SwarmPeers gets all the swarm peers
type StorageOpts ¶ added in v0.1.7
type StorageOpts = func(*RequestBuilder) error
func Hosts ¶ added in v0.1.7
func Hosts(hosts string) StorageOpts
func UploadMode ¶ added in v0.1.7
func UploadMode(mode string) StorageOpts
type StorageUploadOpts ¶ added in v0.1.5
type StorageUploadOpts = func(*RequestBuilder) error
func StorageLength ¶ added in v0.1.5
func StorageLength(length int) StorageUploadOpts
Set storage upload time.
type SwarmConnInfo ¶
type SwarmConnInfo struct { Addr string Peer string Latency string Muxer string Streams []SwarmStreamInfo }
type SwarmConnInfos ¶
type SwarmConnInfos struct {
Peers []SwarmConnInfo
}
type SwarmStreamInfo ¶
type SwarmStreamInfo struct {
Protocol string
}
type UnixLsObject ¶
type UnixLsObject struct { Hash string Size uint64 Type string Links []*UnixLsLink }
type UnsignedData ¶ added in v0.1.7
func (UnsignedData) SignBalanceData ¶ added in v0.1.7
func (d UnsignedData) SignBalanceData(privateKey string) (*ledgerpb.SignedPublicKey, error)