http

package
v0.0.0-...-5ddb3d2 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2022 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// JSONMimeType is the JSON content type header value
	JSONMimeType = "application/json"
	// SourceResolver header name
	SourceResolver = "SourceResolver"
)

Variables

View Source
var (

	// ErrUnsupportedRPC is an error for when running a method that is not supported via HTTP RPC
	ErrUnsupportedRPC = errors.New("method is not supported over RPC")
)

Functions

func DatasetRefFromReq

func DatasetRefFromReq(prefix string, r *http.Request) (dsref.Ref, error)

DatasetRefFromReq examines the path element of a request URL to

func DsRefFromPath

func DsRefFromPath(prefix, path string) (dsref.Ref, error)

DsRefFromPath parses a path and returns a dsref.Ref

func PathToaffixPath

func PathToaffixPath(prefix, path string) string

PathToaffixPath converts a http path to a affix path

Types

type APIEndpoint

type APIEndpoint string

APIEndpoint is a simple alias to have a consistent definition of our API endpoints

const (

	// AEList lists all datasets in your collection
	AEList APIEndpoint = "/list"
	// AECollectionGet returns info on a head dataset in your collection
	AECollectionGet APIEndpoint = "/collection/get"
	// AEDiff is an endpoint for generating dataset diffs
	AEDiff APIEndpoint = "/diff"
	// AEChanges is an endpoint for generating dataset change reports
	AEChanges APIEndpoint = "/changes"

	// AECreateAuthToken creates an auth token for a user
	AECreateAuthToken APIEndpoint = "/access/token"

	// AEApply invokes a transform apply
	AEApply APIEndpoint = "/auto/apply"
	// AEDeploy creates, updates, or deploys a workflow
	AEDeploy APIEndpoint = "/auto/deploy"
	// AERun manually runs a workflow
	AERun APIEndpoint = "/auto/run"
	// AERunInfo fetches the full run info for a workflow run
	AERunInfo APIEndpoint = "/auto/runinfo"
	// AECancel cancels a run
	AECancel APIEndpoint = "/auto/cancel"
	// AEWorkflow fetches a workflow
	AEWorkflow APIEndpoint = "/auto/workflow"
	// AERemoveWorkflow removes a workflow
	AERemoveWorkflow APIEndpoint = "/auto/remove"
	// AEAnalyzeTransform performs static analysis on a starlark transform script
	AEAnalyzeTransform APIEndpoint = "/auto/analyze-transform"

	// AEGet is an endpoint for fetch individual dataset components
	AEGet APIEndpoint = "/ds/get"
	// AEActivity is an endpoint that returns a dataset activity list
	AEActivity APIEndpoint = "/ds/activity"
	// AERename is an endpoint for renaming datasets
	AERename APIEndpoint = "/ds/rename"
	// AESave is an endpoint for saving a dataset
	AESave APIEndpoint = "/ds/save"
	// AEPull facilittates dataset pull requests from a remote
	AEPull APIEndpoint = "/ds/pull"
	// AEPush facilitates dataset push requests to a remote
	AEPush APIEndpoint = "/ds/push"
	// AERender renders the current dataset ref
	AERender APIEndpoint = "/ds/render"
	// AERemove exposes the dataset remove mechanics
	AERemove APIEndpoint = "/ds/remove"
	// AEValidate is an endpoint for validating datasets
	AEValidate APIEndpoint = "/ds/validate"
	// AEManifest generates a manifest for a dataset path
	AEManifest APIEndpoint = "/ds/manifest"
	// AEManifestMissing generates a manifest of blocks that are not present on this repo for a given manifest
	AEManifestMissing APIEndpoint = "/ds/manifest/missing"
	// AEDAGInfo generates a dag.Info for a dataset path
	AEDAGInfo APIEndpoint = "/ds/daginfo"
	// AEWhatChanged gets what changed at a specific version in history
	AEWhatChanged APIEndpoint = "/ds/whatchanged"

	// AEPeer fetches a specific peer
	AEPeer APIEndpoint = "/peer"
	// AEConnect initiates an explicit connection to a peer
	AEConnect APIEndpoint = "/peer/connect"
	// AEDisconnect closes an explicit connection to a peer
	AEDisconnect APIEndpoint = "/peer/disconnect"
	// AEPeers fetches all the peers
	AEPeers APIEndpoint = "/peer/list"

	// AEGetProfile is an alias for the me endpoint
	AEGetProfile APIEndpoint = "/profile"
	// AESetProfile is an endpoint to set the profile
	AESetProfile APIEndpoint = "/profile/set"
	// AESetProfilePhoto is an endpoint to set the profile photo
	AESetProfilePhoto APIEndpoint = "/profile/photo"
	// AESetPosterPhoto is an endpoint to set the profile poster
	AESetPosterPhoto APIEndpoint = "/profile/poster"

	// AEFeeds fetches and index of named feeds
	AEFeeds APIEndpoint = "/remote/feeds"
	// AEPreview fetches a dataset preview from the registry
	AEPreview APIEndpoint = "/remote/preview"
	// AERemoteRemove removes a dataset from a given remote
	AERemoteRemove APIEndpoint = "/remote/remove"
	// AERegistryNew creates a new user on the registry
	AERegistryNew APIEndpoint = "/remote/registry/profile/new"
	// AERegistryProve links an the current peer with an existing
	// user on the registry
	AERegistryProve APIEndpoint = "/remote/registry/profile/prove"
	// AESearch returns a list of dataset search results
	AESearch APIEndpoint = "/registry/search"
	// AERegistryGetFollowing returns a list of datasets a user follows
	AERegistryGetFollowing APIEndpoint = "/registry/follow/list"
	// AERegistryFollow updates the follow status of the current user for a given dataset
	AERegistryFollow APIEndpoint = "/registry/follow"

	// AERemoteDSync exposes the dsync mechanics
	AERemoteDSync APIEndpoint = "/remote/dsync"
	// AERemoteLogSync exposes the logsync mechanics
	AERemoteLogSync APIEndpoint = "/remote/logsync"
	// AERemoteRefs exposes the remote ref resolution mechanics
	AERemoteRefs APIEndpoint = "/remote/refs"

	// AEConnections lists affix & IPFS connections
	AEConnections APIEndpoint = "/connections"
	// AEConnectedaffixProfiles lists affix profile connections
	AEConnectedaffixProfiles APIEndpoint = "/connections/affix"

	// DenyHTTP will disable HTTP access to a method
	DenyHTTP = APIEndpoint("")
)

func (APIEndpoint) NoTrailingSlash

func (ae APIEndpoint) NoTrailingSlash() string

NoTrailingSlash returns the path without a traling slash

func (APIEndpoint) String

func (ae APIEndpoint) String() string

String allows for less casting in general code

func (APIEndpoint) WithSuffix

func (ae APIEndpoint) WithSuffix(suffix string) APIEndpoint

WithSuffix returns a new endpoint with added path suffix

type Client

type Client struct {
	Address  string
	Protocol string
}

Client makes remote procedure calls to a affix node over HTTP

func NewClient

func NewClient(multiaddrStr string) (*Client, error)

NewClient instantiates a new Client

func NewClientWithProtocol

func NewClientWithProtocol(multiaddrStr, protocol string) (*Client, error)

NewClientWithProtocol instantiates a new Client with either http or https protocols

func (Client) Call

func (c Client) Call(ctx context.Context, apiEndpoint APIEndpoint, source string, params interface{}, result interface{}) error

Call calls API endpoint and passes on parameters, context info

func (Client) CallMethod

func (c Client) CallMethod(ctx context.Context, apiEndpoint APIEndpoint, httpMethod string, source string, params interface{}, result interface{}) error

CallMethod calls API endpoint and passes on parameters, context info and specific HTTP Method

func (Client) CallMethodRaw

func (c Client) CallMethodRaw(ctx context.Context, apiEndpoint APIEndpoint, httpMethod string, source string, params interface{}, result interface{}) error

CallMethodRaw calls API endpoint and passes on parameters, context info, specific HTTP Method and returns the []byte result

func (Client) CallRaw

func (c Client) CallRaw(ctx context.Context, apiEndpoint APIEndpoint, source string, params interface{}, result interface{}) error

CallRaw calls API endpoint and passes on parameters, context info and returns the []byte result

Jump to

Keyboard shortcuts

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