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

import (
	"context"

8
	path "gitlab.dms3.io/dms3/interface-go-dms3-core/path"
Łukasz Magiera's avatar
Łukasz Magiera committed
9

10 11 12
	"gitlab.dms3.io/dms3/interface-go-dms3-core/options"

	ld "gitlab.dms3.io/dms3/go-ld-format"
13 14
)

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

20 21 22
	// Index returns the IndexAPI interface implementation backed by the go-dms3fs node
	// Index() IndexAPI

Łukasz Magiera's avatar
Łukasz Magiera committed
23
	// Block returns an implementation of Block API
24 25
	Block() BlockAPI

Łukasz Magiera's avatar
Łukasz Magiera committed
26
	// Dag returns an implementation of Dag API
27
	Dag() APIDagService
28

Łukasz Magiera's avatar
Łukasz Magiera committed
29
	// Name returns an implementation of Name API
30 31
	Name() NameAPI

Łukasz Magiera's avatar
Łukasz Magiera committed
32
	// Key returns an implementation of Key API
33
	Key() KeyAPI
Łukasz Magiera's avatar
Łukasz Magiera committed
34 35

	// Pin returns an implementation of Pin API
36 37 38 39 40
	Pin() PinAPI

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

Łukasz Magiera's avatar
Łukasz Magiera committed
41 42 43
	// Dht returns an implementation of Dht API
	Dht() DhtAPI

Łukasz Magiera's avatar
Łukasz Magiera committed
44 45 46
	// Swarm returns an implementation of Swarm API
	Swarm() SwarmAPI

47 48 49
	// PubSub returns an implementation of PubSub API
	PubSub() PubSubAPI

50
	// ResolvePath resolves the path using Unixfs resolver
51
	ResolvePath(context.Context, path.Path) (path.Resolved, error)
52 53 54

	// ResolveNode resolves the path (if not resolved already) using Unixfs
	// resolver, gets and returns the resolved Node
55
	ResolveNode(context.Context, path.Path) (ld.Node, error)
Łukasz Magiera's avatar
Łukasz Magiera committed
56 57 58 59

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