coreapi.go 1.51 KB
Newer Older
1 2 3 4 5 6 7
// Package iface defines IPFS Core API which is a set of interfaces used to
// interact with IPFS nodes.
package iface

import (
	"context"

8 9 10
	options "github.com/ipfs/go-ipfs/core/coreapi/interface/options"

	cid "gx/ipfs/QmapdYm1b22Frv3k17fqrBYTFRxwiaVJkB299Mfn33edeB/go-cid"
Steven Allen's avatar
Steven Allen committed
11
	ipld "gx/ipfs/QmZtNq8dArGfnpCZfx2pUNY7UcjGhVp5qqwQ4hH6mpTMRQ/go-ipld-format"
12 13
)

Łukasz Magiera's avatar
Łukasz Magiera committed
14
// CoreAPI defines an unified interface to IPFS for Go programs
15
type CoreAPI interface {
Łukasz Magiera's avatar
Łukasz Magiera committed
16
	// Unixfs returns an implementation of Unixfs API
17 18
	Unixfs() UnixfsAPI

Łukasz Magiera's avatar
Łukasz Magiera committed
19
	// Block returns an implementation of Block API
20 21
	Block() BlockAPI

Łukasz Magiera's avatar
Łukasz Magiera committed
22
	// Dag returns an implementation of Dag API
23 24
	Dag() DagAPI

Łukasz Magiera's avatar
Łukasz Magiera committed
25
	// Name returns an implementation of Name API
26 27
	Name() NameAPI

Łukasz Magiera's avatar
Łukasz Magiera committed
28
	// Key returns an implementation of Key API
29
	Key() KeyAPI
Łukasz Magiera's avatar
Łukasz Magiera committed
30 31

	// Pin returns an implementation of Pin API
32 33 34 35 36 37 38 39 40 41 42
	Pin() PinAPI

	// ObjectAPI returns an implementation of Object API
	Object() ObjectAPI

	// ResolvePath resolves the path using Unixfs resolver
	ResolvePath(context.Context, Path) (Path, error)

	// ResolveNode resolves the path (if not resolved already) using Unixfs
	// resolver, gets and returns the resolved Node
	ResolveNode(context.Context, Path) (ipld.Node, error)
43 44 45 46 47 48 49 50 51 52

	// ParsePath parses string path to a Path
	ParsePath(context.Context, string, ...options.ParsePathOption) (Path, error)

	// WithResolve is an option for ParsePath which when set to true tells
	// ParsePath to also resolve the path
	WithResolve(bool) options.ParsePathOption

	// ParseCid creates new path from the provided CID
	ParseCid(*cid.Cid) Path
53
}