shell

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2016 License: MIT Imports: 15 Imported by: 1

README

go-ipfs-api

GoDoc Build Status

An unofficial go interface to ipfs's HTTP API

Usage

...

Contribute

Contributions are welcome! Please check out the issues.

License

MIT.

Want to hack on IPFS?

Documentation

Overview

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

Index

Constants

View Source
const (
	TRaw = iota
	TDirectory
	TFile
	TMetadata
	TSymlink
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Command string
	Message string
	Code    int
}

func (*Error) Error

func (e *Error) Error() string

type IdOutput

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

type IpfsObject

type IpfsObject struct {
	Links []ObjectLink
	Data  string
}
type LsLink struct {
	Hash string
	Name string
	Size uint64
	Type int
}

type LsObject

type LsObject struct {
	Links []*LsLink
	LsLink
}
type ObjectLink struct {
	Name, Hash string
	Size       uint64
}

type PeerInfo

type PeerInfo struct {
	Addrs []string
	ID    string
}

type Request

type Request struct {
	ApiBase string
	Command string
	Args    []string
	Opts    map[string]string
	Body    io.Reader
	Headers map[string]string
}

func NewRequest

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

func (*Request) Send

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

type Response

type Response struct {
	Output io.ReadCloser
	Error  *Error
}

func (*Response) Close

func (r *Response) Close() error

type Shell

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

func NewShell

func NewShell(url string) *Shell

func (*Shell) Add

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

Add a file to ipfs from the given reader, returns the hash of the added file

func (*Shell) AddDir

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) BlockGet

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

func (*Shell) BlockPut

func (s *Shell) BlockPut(block []byte) (string, error)

func (*Shell) BlockStat

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

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) FileList

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

FileList entries at the given path using the UnixFS commands

func (*Shell) FindPeer

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

func (*Shell) Get

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

func (*Shell) ID

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

func (s *Shell) IsUp() bool

func (*Shell) List

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

List entries at the given path

func (*Shell) NewObject

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

func (*Shell) ObjectGet

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

func (*Shell) ObjectPut

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

func (*Shell) Patch

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

func (*Shell) PatchData

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

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

Pin the given path

func (*Shell) Publish

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

Publish updates a mutable name to point to a given value

func (*Shell) Refs

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

func (*Shell) Resolve

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

func (*Shell) ResolvePath

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

func (*Shell) SetTimeout

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

func (*Shell) Unpin

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

Unpin the given path

func (*Shell) Version

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

returns ipfs version and commit sha

type UnixLsLink struct {
	Hash string
	Name string
	Size uint64
	Type string
}

type UnixLsObject

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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