creek

package module
v0.0.0-...-2c3e39f Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: Apache-2.0, MIT Imports: 13 Imported by: 0

README

Creek

A Go client for Estuary

go.dev reference Check Status Test Status

Work In Progress

This is a work in progress with only partial coverage of the Estuary API. See the demo for examples of usage.

Currently implemented:

  • Estuary: get health, get node info
  • Public services: info about cid, miner stats, miner deals, miner deal failures, storage ask
  • Content: add from file and add from ipfs
  • Pins: list, add, get, replace and delete

Documentation

Index

Constants

View Source
const (

	// Version is the current version of the client library.
	Version = "0.1.0"

	// DefaultUserAgent is the default user agent header used by the client library.
	DefaultUserAgent = "estuary-client/" + Version
	DefaultAddr      = "api.estuary.tech"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddedContent

type AddedContent struct {
	Cid       string   `json:"cid"`
	EstuaryId uint     `json:"estuaryId"`
	Providers []string `json:"providers"`
}

type AuthedClient

type AuthedClient struct {
	Pins *PinServices
	// contains filtered or unexported fields
}

AuthedClient is the base client used for interacting with services that require authentication.

func NewAuthedClient

func NewAuthedClient(client *http.Client, addr string, token string) *AuthedClient

New creates a new client that will use the supplied HTTP client and connect via the specified API host address.

func (*AuthedClient) ContentAdd

func (c *AuthedClient) ContentAdd(name string, r io.Reader) *ContentAddReq

func (*AuthedClient) ContentAddFromIpfs

func (c *AuthedClient) ContentAddFromIpfs(root cid.Cid) *ContentAddFromIpfsReq

type Client

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

Client is the base client used for interacting with services that do not require authentication.

func New

func New(client *http.Client, addr string) *Client

New creates a new client that will use the supplied HTTP client and connect via the specified API host address.

func NewDefault

func NewDefault() *Client

NewDefault creates a new client that will use the default HTTP client and connect to api.estuary.tech.

func (*Client) Health

func (c *Client) Health() *HealthReq

PublicNodeInfo prepares a request for the health of the Estuary node.

func (*Client) PublicContentByCid

func (c *Client) PublicContentByCid(ci cid.Cid) *PublicContentByCidReq

PublicContentByCid prepares a request for information about content by its cid

func (*Client) PublicMinerDeals

func (c *Client) PublicMinerDeals(addr address.Address) *PublicMinerDealsReq

PublicMinerDeals prepares a request for information about deals made with a miner.

func (*Client) PublicMinerFailures

func (c *Client) PublicMinerFailures(addr address.Address) *PublicMinerFailuresReq

PublicMinerFailures prepares a request for information about miner deal failures.

func (*Client) PublicMinerStats

func (c *Client) PublicMinerStats(addr address.Address) *PublicMinerStatsReq

PublicMinerStats prepares a request for public stats about a miner.

func (*Client) PublicMinerStorageAsk

func (c *Client) PublicMinerStorageAsk(addr address.Address) *PublicMinerStorageAskReq

PublicMinerStorageAsk prepares a request for a miner's storage ask details.

func (*Client) PublicNodeInfo

func (c *Client) PublicNodeInfo() *PublicNodeInfoReq

PublicNodeInfo prepares a request for information about the Estuary node.

func (*Client) PublicStats

func (c *Client) PublicStats() *StatsReq

func (*Client) WithToken

func (c *Client) WithToken(token string) *AuthedClient

WithToken creates a Client with the supplied authentication token, copying options set on the receiver.

type Content

type Content struct {
	ID           uint   `json:"id"`
	Cid          string `json:"cid"`
	Name         string `json:"name"`
	UserID       uint   `json:"userId"`
	Description  string `json:"description"`
	Size         int64  `json:"size"`
	Active       bool   `json:"active"`
	Offloaded    bool   `json:"offloaded"`
	Replication  int    `json:"replication"`
	AggregatedIn uint   `json:"aggregatedIn"`
	Aggregate    bool   `json:"aggregate"`
	Pinning      bool   `json:"pinning"`
	PinMeta      string `json:"pinMeta"`
	Failed       bool   `json:"failed"`
	Location     string `json:"location"`
	DagSplit     bool   `json:"dagSplit"`
}

type ContentAddFromIpfsReq

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

func (*ContentAddFromIpfsReq) Collection

func (*ContentAddFromIpfsReq) Context

Context sets the context to be used during this request.

func (*ContentAddFromIpfsReq) Name

func (*ContentAddFromIpfsReq) Peers

func (*ContentAddFromIpfsReq) Send

type ContentAddReq

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

func (*ContentAddReq) Context

func (r *ContentAddReq) Context(ctx context.Context) *ContentAddReq

Context sets the context to be used during this request.

func (*ContentAddReq) Send

func (r *ContentAddReq) Send() (*AddedContent, error)

type ContentDeal

type ContentDeal struct {
	ID               uint      `json:"id"`
	Content          uint      `json:"content"`
	PropCid          string    `json:"propCid"`
	Miner            string    `json:"miner"`
	DealID           int64     `json:"dealId"`
	Failed           bool      `json:"failed"`
	Verified         bool      `json:"verified"`
	FailedAt         time.Time `json:"failedAt,omitempty"`
	DTChan           string    `json:"dtChan"`
	TransferStarted  time.Time `json:"transferStarted"`
	TransferFinished time.Time `json:"transferFinished"`
	OnChainAt        time.Time `json:"onChainAt"`
	SealedAt         time.Time `json:"sealedAt"`
}

type ContentInfo

type ContentInfo struct {
	Content      Content       `json:"content"`
	AggregatedIn *Content      `json:"aggregatedIn,omitempty"`
	Deals        []ContentDeal `json:"deals"`
}

type Error

type Error struct {
	Error string `json:"error"`
}

type Health

type Health struct {
	Status string `json:"status"`
}

type HealthReq

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

func (*HealthReq) Context

func (r *HealthReq) Context(ctx context.Context) *HealthReq

Context sets the context to be used during this request.

func (*HealthReq) Send

func (r *HealthReq) Send() (*Health, error)

Send sends the prepared request and returns the health status reported by the Estuary node.

type IpfsPin

type IpfsPin struct {
	Cid     string                 `json:"cid"`
	Name    string                 `json:"name"`
	Origins []string               `json:"origins"`
	Meta    map[string]interface{} `json:"meta"`
}

type IpfsPinStatus

type IpfsPinStatus struct {
	RequestId string                 `json:"requestid"`
	Status    string                 `json:"status"`
	Created   time.Time              `json:"created"`
	Pin       IpfsPin                `json:"pin"`
	Delegates []string               `json:"delegates"`
	Info      map[string]interface{} `json:"info"`
}

type MinerChainInfo

type MinerChainInfo struct {
	PeerID    string   `json:"peerId"`
	Addresses []string `json:"addresses"`
	Owner     string   `json:"owner"`
	Worker    string   `json:"worker"`
}

type MinerDeal

type MinerDeal struct {
	ID               uint      `json:"id"`
	Content          uint      `json:"content"`
	PropCid          string    `json:"propCid"`
	Miner            string    `json:"miner"`
	DealID           int64     `json:"dealId"`
	Failed           bool      `json:"failed"`
	Verified         bool      `json:"verified"`
	FailedAt         time.Time `json:"failedAt,omitempty"`
	DTChan           string    `json:"dtChan"`
	TransferStarted  time.Time `json:"transferStarted"`
	TransferFinished time.Time `json:"transferFinished"`
	OnChainAt        time.Time `json:"onChainAt"`
	SealedAt         time.Time `json:"sealedAt"`
	ContentCid       string    `json:"contentCid"`
}

type MinerDealFailure

type MinerDealFailure struct {
	ID           uint   `json:"id"`
	Miner        string `json:"miner"`
	Phase        string `json:"phase"`
	Message      string `json:"message"`
	Content      uint   `json:"content"`
	MinerVersion string `json:"minerVersion"`
}

type MinerStats

type MinerStats struct {
	Miner           string          `json:"miner"`
	Name            string          `json:"name"`
	Version         string          `json:"version"`
	UsedByEstuary   bool            `json:"usedByEstuary"`
	DealCount       int64           `json:"dealCount"`
	ErrorCount      int64           `json:"errorCount"`
	Suspended       bool            `json:"suspended"`
	SuspendedReason string          `json:"suspendedReason"`
	ChainInfo       *MinerChainInfo `json:"chainInfo"`
}

type MinerStorageAsk

type MinerStorageAsk struct {
	Miner         string `json:"miner"`
	Price         string `json:"price"`
	VerifiedPrice string `json:"verifiedPrice"`
	MinPieceSize  uint64 `json:"minPieceSize"`
	MaxPieceSize  uint64 `json:"maxPieceSize"`
}

type PinList

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

type PinServices

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

PinServices provides access to pin related API services.

func NewPinServices

func NewPinServices(a *AuthedClient) *PinServices

func (*PinServices) Add

func (s *PinServices) Add(ci cid.Cid) *PinServicesAddReq

Add prepares a request to add a pin.

func (*PinServices) Delete

func (s *PinServices) Delete(requestId string) *PinServicesDeleteReq

Get prepares a request to delete a pin

func (*PinServices) Get

func (s *PinServices) Get(requestId string) *PinServicesGetReq

Get prepares a request to get the status of a pin

func (*PinServices) List

func (s *PinServices) List() *PinServicesListReq

List prepares a request for a list of pins.

func (*PinServices) Replace

func (s *PinServices) Replace(requestId string, ci cid.Cid) *PinServicesReplaceReq

Replace prepares a request to replace a pin.

type PinServicesAddReq

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

func (*PinServicesAddReq) Collection

func (r *PinServicesAddReq) Collection(v string) *PinServicesAddReq

Collection sets a collection to be associated with the pin.

func (*PinServicesAddReq) Context

Context sets the context to be used during this request.

func (*PinServicesAddReq) Meta

func (r *PinServicesAddReq) Meta(meta map[string]interface{}) *PinServicesAddReq

Meta sets additional metadata to be associated with the pin.

func (*PinServicesAddReq) Name

Name sets a name to be associated with the pin.

func (*PinServicesAddReq) Origins

func (r *PinServicesAddReq) Origins(addrs ...peer.AddrInfo) *PinServicesAddReq

Origins sets one or more origin addresses to be associated with the pin.

func (*PinServicesAddReq) Send

func (r *PinServicesAddReq) Send() (*IpfsPinStatus, error)

Send sends the prepared request and returns the status of the added pin.

type PinServicesDeleteReq

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

func (*PinServicesDeleteReq) Context

Context sets the context to be used during this request.

func (*PinServicesDeleteReq) Send

func (r *PinServicesDeleteReq) Send() error

Send sends the prepared request and returns the status of the pin.

type PinServicesGetReq

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

func (*PinServicesGetReq) Context

Context sets the context to be used during this request.

func (*PinServicesGetReq) Send

func (r *PinServicesGetReq) Send() (*IpfsPinStatus, error)

Send sends the prepared request and returns the status of the pin.

type PinServicesListReq

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

func (*PinServicesListReq) Context

Context sets the context to be used during this request.

func (*PinServicesListReq) Send

func (r *PinServicesListReq) Send() (*PinList, error)

Send sends the prepared request and returns a list of pins.

type PinServicesReplaceReq

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

func (*PinServicesReplaceReq) Collection

Collection sets a collection to be associated with the pin.

func (*PinServicesReplaceReq) Context

Context sets the context to be used during this request.

func (*PinServicesReplaceReq) Meta

func (r *PinServicesReplaceReq) Meta(meta map[string]interface{}) *PinServicesReplaceReq

Meta sets additional metadata to be associated with the pin.

func (*PinServicesReplaceReq) Name

Name sets a name to be associated with the pin.

func (*PinServicesReplaceReq) Origins

Origins sets one or more origin addresses to be associated with the pin.

func (*PinServicesReplaceReq) Send

Send sends the prepared request and returns the status of the replaced pin.

type PublicContentByCidReq

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

func (*PublicContentByCidReq) Context

Context sets the context to be used during this request.

func (*PublicContentByCidReq) Send

func (r *PublicContentByCidReq) Send() ([]ContentInfo, error)

Send sends the prepared request and returns public information about the content.

type PublicMinerDealsReq

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

func (*PublicMinerDealsReq) Context

Context sets the context to be used during this request.

func (*PublicMinerDealsReq) Send

func (r *PublicMinerDealsReq) Send() ([]MinerDeal, error)

Send sends the prepared request and returns information about deals made with a miner.

type PublicMinerFailuresReq

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

func (*PublicMinerFailuresReq) Context

Context sets the context to be used during this request.

func (*PublicMinerFailuresReq) Send

Send sends the prepared request and returns information about miner deal failures.

type PublicMinerStatsReq

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

func (*PublicMinerStatsReq) Context

Context sets the context to be used during this request.

func (*PublicMinerStatsReq) Send

func (r *PublicMinerStatsReq) Send() (*MinerStats, error)

Send sends the prepared request and returns public stats about the miner.

type PublicMinerStorageAskReq

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

func (*PublicMinerStorageAskReq) Context

Context sets the context to be used during this request.

func (*PublicMinerStorageAskReq) Send

Send sends the prepared request and returns the miner's storage ask details.

type PublicNodeInfo

type PublicNodeInfo struct {
	PrimaryAddress string `json:"primaryAddress"`
}

type PublicNodeInfoReq

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

func (*PublicNodeInfoReq) Context

Context sets the context to be used during this request.

func (*PublicNodeInfoReq) Send

func (r *PublicNodeInfoReq) Send() (*PublicNodeInfo, error)

Send sends the prepared request and returns public information about the Estuary node.

type PublicStats

type PublicStats struct {
	TotalStorage     int64 `json:"totalStorage"`
	TotalFilesStored int64 `json:"totalFiles"`
	DealsOnChain     int64 `json:"dealsOnChain"`
}

type ResponseError

type ResponseError struct {
	Message    string
	StatusCode int
	URL        string
}

func (*ResponseError) Error

func (e *ResponseError) Error() string

type StatsReq

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

func (*StatsReq) Context

func (r *StatsReq) Context(ctx context.Context) *StatsReq

Context sets the context to be used during this request.

func (*StatsReq) Send

func (r *StatsReq) Send() (*PublicStats, error)

Send sends the prepared request and decodes the response.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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