go_pinning_service_http_client

package module
v0.0.0-...-ef87570 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2022 License: Apache-2.0, MIT Imports: 11 Imported by: 0

README

go-pinning-service-http-client

An IPFS Pinning Service HTTP Client

This repo is contains a reference implementation of a client for the IPFS Pinning Services API Spec

Lead Maintainer

Adin Schmahmann

Updating Pinning Service Spec

Download the openapi-generator from https://github.com/OpenAPITools/openapi-generator and generate the code using:

Current code generated with: openapi-generator 5.0.0-beta

openapi-generator generate -g go-experimental -i https://raw.githubusercontent.com/ipfs/pinning-services-api-spec/master/ipfs-pinning-service.yaml -o openapi
rm openapi/go.mod openapi/go.sum

Notes: Due to https://github.com/OpenAPITools/openapi-generator/issues/7473 the code generator the http error codes processing may need some manual editing.

go-experimental is becoming mainstream and so in later versions will be replaced with go

Contributing

Contributions are welcome! This repository is part of the IPFS project and therefore governed by our contributing guidelines.

License

SPDX-License-Identifier: Apache-2.0 OR MIT

Documentation

Index

Constants

View Source
const UserAgent = "go-pinning-service-http-client"

Variables

View Source
var PinOpts = pinOpts{}

Functions

This section is empty.

Types

type AddOption

type AddOption func(options *addSettings) error

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(url, bearerToken string) *Client

func (*Client) Add

func (c *Client) Add(ctx context.Context, cid cid.Cid, opts ...AddOption) (PinStatusGetter, error)

func (*Client) AddIpns

func (c *Client) AddIpns(ctx context.Context, ipnsname string, cid cid.Cid, opts ...AddOption) (PinStatusGetter, error)

func (*Client) DeleteByID

func (c *Client) DeleteByID(ctx context.Context, pinID string) error

func (*Client) GetStatusByID

func (c *Client) GetStatusByID(ctx context.Context, pinID string) (PinStatusGetter, error)

func (*Client) Ls

func (c *Client) Ls(ctx context.Context, opts ...LsOption) (chan PinStatusGetter, chan error)

func (*Client) LsBatchSync

func (c *Client) LsBatchSync(ctx context.Context, opts ...LsOption) ([]PinStatusGetter, int, error)

Manual version of Ls that returns a single batch of results and int with total count

func (*Client) LsSync

func (c *Client) LsSync(ctx context.Context, opts ...LsOption) ([]PinStatusGetter, error)

func (*Client) Replace

func (c *Client) Replace(ctx context.Context, pinID string, cid cid.Cid, opts ...AddOption) (PinStatusGetter, error)

type LsOption

type LsOption func(options *lsSettings) error

type PinGetter

type PinGetter interface {
	fmt.Stringer
	json.Marshaler
	// CID to be pinned recursively
	GetCid() cid.Cid
	// Optional name for pinned data; can be used for lookups later
	GetName() string
	// Optional list of multiaddrs known to provide the data
	GetOrigins() []string
	// Optional metadata for pin object
	GetMeta() map[string]string
}

PinGetter Getter for Pin object

type PinStatusGetter

type PinStatusGetter interface {
	fmt.Stringer
	json.Marshaler
	// Globally unique ID of the pin request; can be used to check the status of ongoing pinning, modification of pin object, or pin removal
	GetRequestId() string
	GetStatus() Status
	// Immutable timestamp indicating when a pin request entered a pinning service; can be used for filtering results and pagination
	GetCreated() time.Time
	GetPin() PinGetter
	// List of multiaddrs designated by pinning service for transferring any new data from external peers
	GetDelegates() []multiaddr.Multiaddr
	// Optional info for PinStatus response
	GetInfo() map[string]string
}

PinStatusGetter Getter for Pin object with status

type Status

type Status string
const (
	StatusUnknown Status = ""
	StatusQueued  Status = Status(openapi.QUEUED)
	StatusPinning Status = Status(openapi.PINNING)
	StatusPinned  Status = Status(openapi.PINNED)
	StatusFailed  Status = Status(openapi.FAILED)
)

func (Status) String

func (s Status) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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