pin.go 1.48 KB
Newer Older
1 2 3 4
package iface

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

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

// Pin holds information about pinned resource
type Pin interface {
	// Path to the pinned object
13
	Path() path.Resolved
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

	// Type of the pin
	Type() string
}

// PinStatus holds information about pin health
type PinStatus interface {
	// Ok indicates whether the pin has been verified to be correct
	Ok() bool

	// BadNodes returns any bad (usually missing) nodes from the pin
	BadNodes() []BadPinNode
}

// BadPinNode is a node that has been marked as bad by Pin.Verify
type BadPinNode interface {
	// Path is the path of the node
31
	Path() path.Resolved
32 33 34 35 36 37 38 39 40

	// Err is the reason why the node has been marked as bad
	Err() error
}

// PinAPI specifies the interface to pining
type PinAPI interface {
	// Add creates new pin, be default recursive - pinning the whole referenced
	// tree
Łukasz Magiera's avatar
Łukasz Magiera committed
41
	Add(context.Context, path.Path, ...options.PinAddOption) error
42 43 44 45 46

	// Ls returns list of pinned objects on this node
	Ls(context.Context, ...options.PinLsOption) ([]Pin, error)

	// Rm removes pin for object specified by the path
Łukasz Magiera's avatar
Łukasz Magiera committed
47
	Rm(context.Context, path.Path, ...options.PinRmOption) error
48 49 50

	// Update changes one pin to another, skipping checks for matching paths in
	// the old tree
Łukasz Magiera's avatar
Łukasz Magiera committed
51
	Update(ctx context.Context, from path.Path, to path.Path, opts ...options.PinUpdateOption) error
52 53 54 55

	// Verify verifies the integrity of pinned objects
	Verify(context.Context) (<-chan PinStatus, error)
}