go-ipfs-api: github.com/ipfs/go-ipfs-api Index | Files | Directories

package shell

import "github.com/ipfs/go-ipfs-api"

package shell implements a remote API interface for a running ipfs daemon


Package Files

add.go bootstrap.go dag.go ipns.go key.go logger.go mfs.go pubsub.go request.go requestbuilder.go shell.go unixfs.go


const (
    DefaultPathName = ".ipfs"
    DefaultPathRoot = "~/" + DefaultPathName
    DefaultApiFile  = "api"
    EnvDir          = "IPFS_PATH"
const (
    TRaw = iota
const (
    DirectPin    = "direct"
    RecursivePin = "recursive"
    IndirectPin  = "indirect"


var (
    FilesLs    filesLs
    FilesChcid filesChcid
    FilesMkdir filesMkdir
    FilesRead  filesRead
    FilesWrite filesWrite
    FilesStat  filesStat
var KeyGen keyGen

type AddOpts Uses

type AddOpts = func(*RequestBuilder) error

func CidVersion Uses

func CidVersion(version int) AddOpts

CidVersion allows for selecting the CID version that ipfs should use.

func Hash Uses

func Hash(hash string) AddOpts

Hash allows for selecting the multihash type

func OnlyHash Uses

func OnlyHash(enabled bool) AddOpts

func Pin Uses

func Pin(enabled bool) AddOpts

func Progress Uses

func Progress(enabled bool) AddOpts

func RawLeaves Uses

func RawLeaves(enabled bool) AddOpts

type Error Uses

type Error struct {
    Command string
    Message string
    Code    int

func (*Error) Error Uses

func (e *Error) Error() string

type FilesOpt Uses

type FilesOpt func(*RequestBuilder) error

type FilesStatObject Uses

type FilesStatObject struct {
    Blocks         int
    CumulativeSize uint64
    Hash           string
    Local          bool
    Size           uint64
    SizeLocal      uint64
    Type           string
    WithLocality   bool

type IdOutput Uses

type IdOutput struct {
    ID              string
    PublicKey       string
    Addresses       []string
    AgentVersion    string
    ProtocolVersion string

type IpfsObject Uses

type IpfsObject struct {
    Links []ObjectLink
    Data  string

type Key Uses

type Key struct {
    Id   string
    Name string

type KeyOpt Uses

type KeyOpt func(*RequestBuilder) error

type KeyRenameObject Uses

type KeyRenameObject struct {
    Id        string
    Now       string
    Overwrite bool
    Was       string

type Logger Uses

type Logger struct {
    // contains filtered or unexported fields

Logger is used to handle incoming logs from the ipfs node

func (Logger) Close Uses

func (l Logger) Close() error

Close is used to close our reader

func (Logger) Next Uses

func (l Logger) Next() (map[string]interface{}, error)

Next is used to retrieve the next event from the logging system

type LsLink struct {
    Hash string
    Name string
    Size uint64
    Type int

type LsObject Uses

type LsObject struct {
    Links []*LsLink

type Message Uses

type Message struct {
    From     peer.ID
    Data     []byte
    Seqno    []byte
    TopicIDs []string

Message is a pubsub message.

type MfsLsEntry Uses

type MfsLsEntry struct {
    Name string
    Type uint8
    Size uint64
    Hash string
type ObjectLink struct {
    Name, Hash string
    Size       uint64

type ObjectStats Uses

type ObjectStats struct {
    Hash           string
    BlockSize      int
    CumulativeSize int
    DataSize       int
    LinksSize      int
    NumLinks       int

type PeerInfo Uses

type PeerInfo struct {
    Addrs []string
    ID    string

type PeersList Uses

type PeersList struct {
    Peers []string

type PinInfo Uses

type PinInfo struct {
    Type string

type PinStreamInfo Uses

type PinStreamInfo struct {
    Cid  string
    Type string

PinStreamInfo is the output type for PinsStream

type PubSubSubscription Uses

type PubSubSubscription struct {
    // contains filtered or unexported fields

PubSubSubscription allow you to receive pubsub records that where published on the network.

func (*PubSubSubscription) Cancel Uses

func (s *PubSubSubscription) Cancel() error

Cancel cancels the given subscription.

func (*PubSubSubscription) Next Uses

func (s *PubSubSubscription) Next() (*Message, error)

Next waits for the next record and returns that.

type PublishResponse Uses

type PublishResponse struct {
    Name  string `json:"name"`
    Value string `json:"value"`

type Request Uses

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 Uses

func NewRequest(ctx context.Context, url, command string, args ...string) *Request

func (*Request) Send Uses

func (r *Request) Send(c *http.Client) (*Response, error)

type RequestBuilder Uses

type RequestBuilder struct {
    // contains filtered or unexported fields

RequestBuilder is an IPFS commands request builder.

func (*RequestBuilder) Arguments Uses

func (r *RequestBuilder) Arguments(args ...string) *RequestBuilder

Arguments adds the arguments to the args.

func (*RequestBuilder) Body Uses

func (r *RequestBuilder) Body(body io.Reader) *RequestBuilder

Body sets the request body to the given reader.

func (*RequestBuilder) BodyBytes Uses

func (r *RequestBuilder) BodyBytes(body []byte) *RequestBuilder

BodyBytes sets the request body to the given buffer.

func (*RequestBuilder) BodyString Uses

func (r *RequestBuilder) BodyString(body string) *RequestBuilder

BodyString sets the request body to the given string.

func (*RequestBuilder) Exec Uses

func (r *RequestBuilder) Exec(ctx context.Context, res interface{}) error

Exec sends the request a request and decodes the response.

func (*RequestBuilder) Header Uses

func (r *RequestBuilder) Header(name, value string) *RequestBuilder

Header sets the given header.

func (*RequestBuilder) Option Uses

func (r *RequestBuilder) Option(key string, value interface{}) *RequestBuilder

Option sets the given option.

func (*RequestBuilder) Send Uses

func (r *RequestBuilder) Send(ctx context.Context) (*Response, error)

Send sends the request and return the response.

type Response Uses

type Response struct {
    Output io.ReadCloser
    Error  *Error

func (*Response) Close Uses

func (r *Response) Close() error

func (*Response) Decode Uses

func (r *Response) Decode(dec interface{}) error

type Shell Uses

type Shell struct {
    // contains filtered or unexported fields

func NewLocalShell Uses

func NewLocalShell() *Shell

func NewShell Uses

func NewShell(url string) *Shell

func NewShellWithClient Uses

func NewShellWithClient(url string, client *gohttp.Client) *Shell

func (*Shell) Add Uses

func (s *Shell) Add(r io.Reader, options ...AddOpts) (string, error)

func (*Shell) AddDir Uses

func (s *Shell) AddDir(dir string) (string, error)

AddDir adds a directory recursively with all of the files under it

func (s *Shell) AddLink(target string) (string, error)

func (*Shell) AddNoPin Uses

func (s *Shell) AddNoPin(r io.Reader) (string, error)

AddNoPin adds a file to ipfs without pinning it Deprecated: Use Add() with option functions instead

func (*Shell) AddWithOpts Uses

func (s *Shell) AddWithOpts(r io.Reader, pin bool, rawLeaves bool) (string, error)

AddWithOpts adds a file to ipfs with some additional options Deprecated: Use Add() with option functions instead

func (*Shell) BlockGet Uses

func (s *Shell) BlockGet(path string) ([]byte, error)

func (*Shell) BlockPut Uses

func (s *Shell) BlockPut(block []byte, format, mhtype string, mhlen int) (string, error)

func (*Shell) BlockStat Uses

func (s *Shell) BlockStat(path string) (string, int, error)

func (*Shell) BootstrapAdd Uses

func (s *Shell) BootstrapAdd(peers []string) ([]string, error)

func (*Shell) BootstrapAddDefault Uses

func (s *Shell) BootstrapAddDefault() ([]string, error)

func (*Shell) BootstrapRmAll Uses

func (s *Shell) BootstrapRmAll() ([]string, error)

func (*Shell) Cat Uses

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) DagGet Uses

func (s *Shell) DagGet(ref string, out interface{}) error

func (*Shell) DagPut Uses

func (s *Shell) DagPut(data interface{}, ienc, kind string) (string, error)

func (*Shell) DagPutWithOpts Uses

func (s *Shell) DagPutWithOpts(data interface{}, opts ...options.DagPutOption) (string, error)

func (*Shell) FileList Uses

func (s *Shell) FileList(path string) (*UnixLsObject, error)

FileList entries at the given path using the UnixFS commands

func (*Shell) FilesChcid Uses

func (s *Shell) FilesChcid(ctx context.Context, path string, options ...FilesOpt) error

FilesChcid change the cid version or hash function of the root node of a given path

func (*Shell) FilesCp Uses

func (s *Shell) FilesCp(ctx context.Context, src string, dest string) error

FilesCp copy any IPFS files and directories into MFS (or copy within MFS)

func (*Shell) FilesFlush Uses

func (s *Shell) FilesFlush(ctx context.Context, path string) (string, error)

FilesFlush flush a given path's data to disk

func (*Shell) FilesLs Uses

func (s *Shell) FilesLs(ctx context.Context, path string, options ...FilesOpt) ([]*MfsLsEntry, error)

FilesLs list directories in the local mutable namespace

func (*Shell) FilesMkdir Uses

func (s *Shell) FilesMkdir(ctx context.Context, path string, options ...FilesOpt) error

FilesMkdir make directories

func (*Shell) FilesMv Uses

func (s *Shell) FilesMv(ctx context.Context, src string, dest string) error

FilesMv move files

func (*Shell) FilesRead Uses

func (s *Shell) FilesRead(ctx context.Context, path string, options ...FilesOpt) (io.ReadCloser, error)

FilesRead read a file in a given MFS

func (*Shell) FilesRm Uses

func (s *Shell) FilesRm(ctx context.Context, path string, force bool) error

FilesRm remove a file

func (*Shell) FilesStat Uses

func (s *Shell) FilesStat(ctx context.Context, path string, options ...FilesOpt) (*FilesStatObject, error)

FilesStat display file status

func (*Shell) FilesWrite Uses

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) FindPeer Uses

func (s *Shell) FindPeer(peer string) (*PeerInfo, error)

func (*Shell) Get Uses

func (s *Shell) Get(hash, outdir string) error

func (*Shell) GetLogs Uses

func (s *Shell) GetLogs(ctx context.Context) (Logger, error)

GetLogs is used to retrieve a parsable logger object

func (*Shell) ID Uses

func (s *Shell) ID(peer ...string) (*IdOutput, error)

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) IsUp Uses

func (s *Shell) IsUp() bool

func (*Shell) KeyGen Uses

func (s *Shell) KeyGen(ctx context.Context, name string, options ...KeyOpt) (*Key, error)

KeyGen Create a new keypair

func (*Shell) KeyList Uses

func (s *Shell) KeyList(ctx context.Context) ([]*Key, error)

KeyList List all local keypairs

func (*Shell) KeyRename Uses

func (s *Shell) KeyRename(ctx context.Context, old string, new string, force bool) (*KeyRenameObject, error)

KeyRename Rename a keypair

func (*Shell) KeyRm Uses

func (s *Shell) KeyRm(ctx context.Context, name string) ([]*Key, error)

KeyRm remove a keypair

func (*Shell) List Uses

func (s *Shell) List(path string) ([]*LsLink, error)

List entries at the given path

func (*Shell) NewObject Uses

func (s *Shell) NewObject(template string) (string, error)

func (*Shell) ObjectGet Uses

func (s *Shell) ObjectGet(path string) (*IpfsObject, error)

func (*Shell) ObjectPut Uses

func (s *Shell) ObjectPut(obj *IpfsObject) (string, error)

func (*Shell) ObjectStat Uses

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) Patch Uses

func (s *Shell) Patch(root, action string, args ...string) (string, error)

func (*Shell) PatchData Uses

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 (*Shell) Pin Uses

func (s *Shell) Pin(path string) error

Pin the given path

func (*Shell) Pins Uses

func (s *Shell) Pins() (map[string]PinInfo, error)

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 Uses

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 Uses

func (s *Shell) PubSubPublish(topic, data string) (err error)

func (*Shell) PubSubSubscribe Uses

func (s *Shell) PubSubSubscribe(topic string) (*PubSubSubscription, error)

func (*Shell) Publish Uses

func (s *Shell) Publish(node string, value string) error

Publish updates a mutable name to point to a given value

func (*Shell) PublishWithDetails Uses

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) Refs Uses

func (s *Shell) Refs(hash string, recursive bool) (<-chan string, error)

func (*Shell) Request Uses

func (s *Shell) Request(command string, args ...string) *RequestBuilder

func (*Shell) Resolve Uses

func (s *Shell) Resolve(id string) (string, error)

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) ResolvePath Uses

func (s *Shell) ResolvePath(path string) (string, error)

func (*Shell) SetTimeout Uses

func (s *Shell) SetTimeout(d time.Duration)

func (*Shell) StatsBW Uses

func (s *Shell) StatsBW(ctx context.Context) (*p2pmetrics.Stats, error)

ObjectStat gets stats for the DAG object named by key. It returns the stats of the requested Object or an error.

func (*Shell) SwarmConnect Uses

func (s *Shell) SwarmConnect(ctx context.Context, addr ...string) error

SwarmConnect opens a swarm connection to a specific address.

func (*Shell) SwarmPeers Uses

func (s *Shell) SwarmPeers(ctx context.Context) (*SwarmConnInfos, error)

SwarmPeers gets all the swarm peers

func (*Shell) Unpin Uses

func (s *Shell) Unpin(path string) error

Unpin the given path

func (*Shell) Version Uses

func (s *Shell) Version() (string, string, error)

returns ipfs version and commit sha

type SwarmConnInfo Uses

type SwarmConnInfo struct {
    Addr    string
    Peer    string
    Latency string
    Muxer   string
    Streams []SwarmStreamInfo

type SwarmConnInfos Uses

type SwarmConnInfos struct {
    Peers []SwarmConnInfo

type SwarmStreamInfo Uses

type SwarmStreamInfo struct {
    Protocol string
type UnixLsLink struct {
    Hash string
    Name string
    Size uint64
    Type string

type UnixLsObject Uses

type UnixLsObject struct {
    Hash  string
    Size  uint64
    Type  string
    Links []*UnixLsLink



Package shell imports 24 packages (graph) and is imported by 76 packages. Updated 2020-07-12. Refresh now. Tools for package owners.