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

import (
	"context"
Łukasz Magiera's avatar
Łukasz Magiera committed
7
	path "github.com/ipfs/interface-go-ipfs-core/path"
8

Łukasz Magiera's avatar
Łukasz Magiera committed
9
	"github.com/ipfs/interface-go-ipfs-core/options"
Łukasz Magiera's avatar
Łukasz Magiera committed
10

Łukasz Magiera's avatar
Łukasz Magiera committed
11
	ipld "github.com/ipfs/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
	Dag() APIDagService
24

Ł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
	Pin() PinAPI

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

Łukasz Magiera's avatar
Łukasz Magiera committed
37 38 39
	// Dht returns an implementation of Dht API
	Dht() DhtAPI

Łukasz Magiera's avatar
Łukasz Magiera committed
40 41 42
	// Swarm returns an implementation of Swarm API
	Swarm() SwarmAPI

43 44 45
	// PubSub returns an implementation of PubSub API
	PubSub() PubSubAPI

46
	// ResolvePath resolves the path using Unixfs resolver
47
	ResolvePath(context.Context, path.Path) (path.Resolved, error)
48 49 50

	// ResolveNode resolves the path (if not resolved already) using Unixfs
	// resolver, gets and returns the resolved Node
Łukasz Magiera's avatar
Łukasz Magiera committed
51
	ResolveNode(context.Context, path.Path) (ipld.Node, error)
Łukasz Magiera's avatar
Łukasz Magiera committed
52 53 54 55

	// WithOptions creates new instance of CoreAPI based on this instance with
	// a set of options applied
	WithOptions(...options.ApiOption) (CoreAPI, error)
56
}