pinsvc

package
v1.0.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2022 License: Apache-2.0, MIT, Apache-2.0, + 1 more Imports: 8 Imported by: 0

Documentation

Overview

Package pinsvc contains type definitions for the Pinning Services API

Index

Constants

View Source
const (
	StatusUndefined Status = 0
	StatusQueued           = 1 << iota
	StatusPinned
	StatusPinning
	StatusFailed
)

Values for the Status type.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Reason  string `json:"reason"`
	Details string `json:"details"`
}

APIError is returned by the API as a body when an error occurs. It implements the error interface.

func (APIError) Error

func (apiErr APIError) Error() string

type ListOptions

type ListOptions struct {
	Cids             []types.Cid
	Name             string
	MatchingStrategy MatchingStrategy
	Status           Status
	Before           time.Time
	After            time.Time
	Limit            int
	Meta             map[string]string
}

ListOptions represents possible options given to the List endpoint.

func (*ListOptions) FromQuery

func (lo *ListOptions) FromQuery(q url.Values) error

FromQuery parses ListOptions from url.Values.

type MatchingStrategy

type MatchingStrategy int

MatchingStrategy defines a type of match for filtering pin lists.

const (
	MatchingStrategyUndefined MatchingStrategy = iota
	MatchingStrategyExact
	MatchingStrategyIexact
	MatchingStrategyPartial
	MatchingStrategyIpartial
)

Values for MatchingStrategy.

func MatchingStrategyFromString

func MatchingStrategyFromString(str string) MatchingStrategy

MatchingStrategyFromString converts a string to its MatchingStrategy value.

type Pin

type Pin struct {
	Cid     types.Cid         `json:"cid"`
	Name    PinName           `json:"name"`
	Origins []types.Multiaddr `json:"origins"`
	Meta    map[string]string `json:"meta"`
}

Pin contains basic information about a Pin and pinning options.

func (Pin) Defined

func (p Pin) Defined() bool

Defined returns if the pinis empty (Cid not set).

func (Pin) MatchesMeta

func (p Pin) MatchesMeta(metaOpts map[string]string) bool

MatchesMeta returns true if the pin status metadata matches the given. The metadata should have all the keys in the given metaOpts and the values should, be the same (metadata map includes metaOpts).

func (Pin) MatchesName

func (p Pin) MatchesName(nameOpt string, strategy MatchingStrategy) bool

MatchesName returns in a pin status matches a name option with a given match strategy.

type PinList

type PinList struct {
	Count   int         `json:"count"`
	Results []PinStatus `json:"results"`
}

PinList is the result of a call to List pins

type PinName

type PinName string

PinName is a string limited to 255 chars when serializing JSON.

func (PinName) MarshalJSON

func (pname PinName) MarshalJSON() ([]byte, error)

MarshalJSON converts the string to JSON.

func (*PinName) UnmarshalJSON

func (pname *PinName) UnmarshalJSON(data []byte) error

UnmarshalJSON reads the JSON string and errors if over 256 chars.

type PinStatus

type PinStatus struct {
	RequestID string            `json:"requestid"`
	Status    Status            `json:"status"`
	Created   time.Time         `json:"created"`
	Pin       Pin               `json:"pin"`
	Delegates []types.Multiaddr `json:"delegates"`
	Info      map[string]string `json:"info"`
}

PinStatus provides information about a Pin stored by the Pinning API.

type Status

type Status int

Status represents a pin status, which defines the current state of the pin in the system.

func StatusFromString

func StatusFromString(str string) Status

StatusFromString parses a string and returns the matching Status value. The string can be a comma-separated list representing a Status filter. Unknown status names are ignored.

func (Status) MarshalJSON

func (st Status) MarshalJSON() ([]byte, error)

MarshalJSON uses the string representation of Status for JSON encoding.

func (Status) Match

func (st Status) Match(filter Status) bool

Match returns true if the tracker status matches the given filter.

func (Status) String

func (st Status) String() string

String converts a Status into a readable string. If the given Status is a filter (with several bits set), it will return a comma-separated list.

func (*Status) UnmarshalJSON

func (st *Status) UnmarshalJSON(data []byte) error

UnmarshalJSON sets a tracker status from its JSON representation.

Jump to

Keyboard shortcuts

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