lib

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2021 License: GPL-3.0 Imports: 75 Imported by: 4

Documentation

Overview

Package lib implements core qri business logic. It exports canonical methods that a qri instance can perform regardless of client interface. API's of any sort must use lib methods

Index

Constants

View Source
const (

	// AEList lists all datasets in your collection
	AEList = APIEndpoint("/list")
	// AEDiff is an endpoint for generating dataset diffs
	AEDiff = APIEndpoint("/diff")
	// AEChanges is an endpoint for generating dataset change reports
	AEChanges = APIEndpoint("/changes")
	// AESQL executes SQL commands
	AESQL = APIEndpoint("/sql")

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

	// AEApply invokes a transform apply
	AEApply = APIEndpoint("/auto/apply")

	// AEComponentStatus returns what changed for a specific commit
	AEComponentStatus = APIEndpoint("/ds/componentstatus")
	// 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")

	// 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("/remote/search")

	// AEStatus returns the filesystem dataset status
	AEStatus = APIEndpoint("/wd/status")
	// AEInit invokes a dataset initialization on the filesystem
	AEInit = APIEndpoint("/wd/init")
	// AECanInitDatasetWorkDir returns whether a dataset can be initialized
	AECanInitDatasetWorkDir = APIEndpoint("/wd/caninitworkdir")
	// AECheckout invokes a dataset checkout to the filesystem
	AECheckout = APIEndpoint("/wd/checkout")
	// AERestore invokes a restore
	AERestore = APIEndpoint("/wd/restore")
	// AEFSIWrite writes input data to the filesystem
	AEFSIWrite = APIEndpoint("/wd/write")
	// AEFSICreateLink creates an fsi link
	AEFSICreateLink = APIEndpoint("/wd/createlink")
	// AEFSIUnlink removes the fsi link
	AEFSIUnlink = APIEndpoint("/wd/unlink")
	// AEEnsureRef ensures that the ref is fsi linked
	AEEnsureRef = APIEndpoint("/wd/ensureref")

	// 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 qri & IPFS connections
	AEConnections = APIEndpoint("/connections")
	// AEConnectedQriProfiles lists qri profile connections
	AEConnectedQriProfiles = APIEndpoint("/connections/qri")

	// DenyHTTP will disable HTTP access to a method
	DenyHTTP = APIEndpoint("")
)
View Source
const (
	// QriStTagFspath means the field is a filesystem path and needs to be absolute
	QriStTagFspath = "fspath"
	// QriStTagRefOrPath means the field is either a dataset ref, or is a filesys path
	QriStTagRefOrPath = "dsrefOrFspath"
)

qri struct tags augment how fields are marshalled for dispatched methods

View Source
const DefaultPageSize = 100

DefaultPageSize is the max number of items in a page if no Limit param is provided to a paginated method

Variables

View Source
var (
	// ErrDispatchNilInstance indicates that the instance that dispatch as been called on is nil
	ErrDispatchNilInstance = errors.New("instance is nil, cannot dispatch")
	// ErrDispatchNilParam indicates that the param passed to dispatch is nil
	ErrDispatchNilParam = errors.New("param is nil, cannot dispatch")
)
View Source
var (
	// ErrBadArgs is an error for when a user provides bad arguments
	ErrBadArgs = errors.New("bad arguments provided")
	// ErrNoRepo is an error for  when a repo does not exist at a given path
	ErrNoRepo = errors.New("no repo exists")
)
View Source
var (
	// LastPubVerHash is a hard-coded reference the gx "lastpubver" file of the previous release
	LastPubVerHash = "/ipfs/QmcXZCLAgUdvXpt1fszjNGVGn6WnhsrJahkQXY3JJqxUWJ"
	// PrevIPNSName is the dnslink address to check for version agreement
	PrevIPNSName = "/ipns/cli.previous.qri.io"
	// ErrUpdateRequired means this version of qri is out of date
	ErrUpdateRequired = fmt.Errorf("update required")
)
View Source
var ErrCantRemoveDirectoryDirty = fmt.Errorf("cannot remove files while working directory is dirty")

ErrCantRemoveDirectoryDirty is returned when a directory is dirty so the files cant' be removed

ErrListWarning is a warning that can occur while listing

View Source
var ErrUnsupportedRPC = errors.New("method is not supported over RPC")

ErrUnsupportedRPC is an error for when running a method that is not supported via HTTP RPC

Functions

func CheckVersion

func CheckVersion(ctx context.Context, res namesys.Resolver, lookupAddr, localHash string) (latest string, err error)

CheckVersion uses a name resolver to lookup prevIPNSName, checking if the hard-coded lastPubVerHash and the returned lookup match. If they don't, CheckVersion returns ErrUpdateRequired

func DecodeParams added in v0.10.0

func DecodeParams(r *http.Request, p interface{}) error

DecodeParams decodes a json body into params

func DsRefFromPath added in v0.10.0

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

DsRefFromPath parses a path and returns a dsref.Ref

func HTTPPathToQriPath added in v0.10.0

func HTTPPathToQriPath(path string) string

HTTPPathToQriPath converts a http path to a qri path

func IsSelectorScriptFile added in v0.10.0

func IsSelectorScriptFile(selector string) bool

IsSelectorScriptFile takes a selector string and returns true if the selector contains "script"

func NewHTTPRequestHandler added in v0.10.0

func NewHTTPRequestHandler(inst *Instance, libMethod string) http.HandlerFunc

NewHTTPRequestHandler creates a JSON-API endpoint for a registered dispatch method

func PathJoinPosix added in v0.9.13

func PathJoinPosix(left, right string) string

PathJoinPosix joins two paths, and makes it explicitly clear we want POSIX slashes

func QriRepoExists added in v0.9.10

func QriRepoExists(path string) error

QriRepoExists returns nil if a qri repo is defined at the given path does not attempt to open the repo

func ReadDatasetFiles added in v0.7.3

func ReadDatasetFiles(pathList ...string) (*dataset.Dataset, error)

ReadDatasetFiles reads zero or more files, each representing a dataset or component of a dataset, and deserializes them, merging the results into a single dataset object. It is an error to provide any combination of files whose contents overlap (modify the same component).

func Setup

func Setup(p SetupParams) error

Setup provisions a new qri instance, it intentionally doesn't conform to the RPC function signature because remotely invoking setup doesn't make sense

func SourceFromRequest added in v0.10.0

func SourceFromRequest(r *http.Request) string

SourceFromRequest retrieves from the http request the source for resolving refs

func Teardown

func Teardown(p TeardownParams) error

Teardown reverses the setup process, destroying a user's privateKey and removing local qri data

Types

type APIEndpoint added in v0.10.0

type APIEndpoint string

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

func (APIEndpoint) NoTrailingSlash added in v0.10.0

func (ae APIEndpoint) NoTrailingSlash() string

NoTrailingSlash returns the path without a traling slash

func (APIEndpoint) String added in v0.10.0

func (ae APIEndpoint) String() string

String allows for less casting in general code

func (APIEndpoint) WithSuffix added in v0.10.0

func (ae APIEndpoint) WithSuffix(suffix string) APIEndpoint

WithSuffix returns a new endpoint with added path suffix

type AccessMethods added in v0.10.0

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

AccessMethods is a group of methods for access control & user authentication

func (AccessMethods) Attributes added in v0.10.0

func (m AccessMethods) Attributes() map[string]AttributeSet

Attributes defines attributes for each method

func (AccessMethods) CreateAuthToken added in v0.10.0

func (m AccessMethods) CreateAuthToken(ctx context.Context, p *CreateAuthTokenParams) (string, error)

CreateAuthToken constructs a JWT string token suitable for making OAuth requests as the grantee user. Creating an access token requires a stored private key for the grantee. Callers can provide either GranteeUsername OR GranteeProfileID

func (AccessMethods) Name added in v0.10.0

func (m AccessMethods) Name() string

Name returns the name of this method group

type ActivityParams added in v0.10.0

type ActivityParams struct {
	ListParams
	// Reference to data to fetch history for
	Ref  string
	Pull bool
}

ActivityParams defines parameters for the Activity method

type ApplyParams added in v0.10.0

type ApplyParams struct {
	Ref       string
	Transform *dataset.Transform
	Secrets   map[string]string
	Wait      bool
	// TODO(arqu): substitute with websockets when working over the wire
	ScriptOutput io.Writer `json:"-"`
}

ApplyParams are parameters for the apply command

func (*ApplyParams) Validate added in v0.10.0

func (p *ApplyParams) Validate() error

Validate returns an error if ApplyParams fields are in an invalid state

type ApplyResult added in v0.10.0

type ApplyResult struct {
	Data  *dataset.Dataset
	RunID string `json:"runID"`
}

ApplyResult is the result of an apply command

type AttributeSet added in v0.10.0

type AttributeSet struct {
	Endpoint APIEndpoint
	HTTPVerb string
	// the default source used for resolving references
	DefaultSource string
	// whether to deny RPC for this endpoint, normal HTTP may still be allowed
	DenyRPC bool
}

AttributeSet is extra information about each method, such as: http endpoint, http verb, (TODO) permissions, and (TODO) other metadata Each method is required to have associated attributes in order to successfully register Variables are exported so that external packages such as docs can access them

type AutomationMethods added in v0.10.0

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

AutomationMethods groups together methods for automations

func (AutomationMethods) Apply added in v0.10.0

Apply runs a transform script

func (AutomationMethods) Attributes added in v0.10.0

func (m AutomationMethods) Attributes() map[string]AttributeSet

Attributes defines attributes for each method

func (AutomationMethods) Name added in v0.10.0

func (m AutomationMethods) Name() string

Name returns the name of this method group

type ChangeReport added in v0.10.0

type ChangeReport = changes.ChangeReportResponse

ChangeReport is a simple utility type declaration

type ChangeReportParams added in v0.10.0

type ChangeReportParams struct {
	LeftRef  string `schema:"leftRef" json:"leftRef"`
	RightRef string `schema:"rightRef" json:"rightRef"`
}

ChangeReportParams defines parameters for diffing two sources

type CollectionMethods added in v0.10.0

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

CollectionMethods encapsulates business logic for working with aggregate methods

func (CollectionMethods) Attributes added in v0.10.0

func (m CollectionMethods) Attributes() map[string]AttributeSet

Attributes defines attributes for each method

func (CollectionMethods) List added in v0.10.0

List gets the reflist for either the local repo or a peer

func (CollectionMethods) ListRawRefs added in v0.10.0

func (m CollectionMethods) ListRawRefs(ctx context.Context, p *EmptyParams) (string, error)

ListRawRefs gets the list of raw references as string

func (CollectionMethods) Name added in v0.10.0

func (m CollectionMethods) Name() string

Name returns the name of this method group

type ConfigMethods added in v0.8.0

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

ConfigMethods encapsulates changes to a qri configuration

func (ConfigMethods) Attributes added in v0.10.0

func (m ConfigMethods) Attributes() map[string]AttributeSet

Attributes defines attributes for each method

func (ConfigMethods) GetConfig added in v0.8.0

func (m ConfigMethods) GetConfig(ctx context.Context, p *GetConfigParams) ([]byte, error)

GetConfig returns the Config, or one of the specified fields of the Config, as a slice of bytes the bytes can be formatted as json, concise json, or yaml

func (ConfigMethods) GetConfigKeys added in v0.9.8

func (m ConfigMethods) GetConfigKeys(ctx context.Context, p *GetConfigParams) ([]byte, error)

GetConfigKeys returns the Config key fields, or sub keys of the specified fields of the Config, as a slice of bytes to be used for auto completion

func (ConfigMethods) Name added in v0.10.0

func (m ConfigMethods) Name() string

Name returns the name of this method group

func (ConfigMethods) SetConfig added in v0.8.0

func (m ConfigMethods) SetConfig(ctx context.Context, update *config.Config) (*bool, error)

SetConfig validates, updates and saves the config

type ConnectParamsPod added in v0.10.0

type ConnectParamsPod struct {
	Peername  string
	ProfileID string
	NetworkID string
	Multiaddr string
}

ConnectParamsPod defines parameters for defining a connection to a peer as plain-old-data

func NewConnectParamsPod added in v0.10.0

func NewConnectParamsPod(s string) *ConnectParamsPod

NewConnectParamsPod attempts to turn a string into peer connection parameters

func (ConnectParamsPod) Decode added in v0.10.0

func (p ConnectParamsPod) Decode() (cp p2p.PeerConnectionParams, err error)

Decode turns plain-old-data into it's rich types

func (ConnectParamsPod) String added in v0.10.0

func (p ConnectParamsPod) String() string

type ConnectionsParams added in v0.10.0

type ConnectionsParams struct {
	Limit  int
	Offset int
}

ConnectionsParams defines parameters for the Connections method

type CreateAuthTokenParams added in v0.10.0

type CreateAuthTokenParams struct {
	GranteeUsername  string
	GranteeProfileID string
	TTL              time.Duration
}

CreateAuthTokenParams are input parameters for Access().CreateAuthToken

func (*CreateAuthTokenParams) SetNonZeroDefaults added in v0.10.0

func (p *CreateAuthTokenParams) SetNonZeroDefaults()

SetNonZeroDefaults uses default token time-to-live if one isn't set

func (*CreateAuthTokenParams) Validate added in v0.10.0

func (p *CreateAuthTokenParams) Validate() error

Validate returns an error if input params are invalid

type Cursor added in v0.10.0

type Cursor interface{}

Cursor is used to paginate results for methods that support it

type DAGInfoParams added in v0.7.3

type DAGInfoParams struct {
	Ref   string
	Label string
}

DAGInfoParams defines parameters for the DAGInfo method

type DataResponse added in v0.10.0

type DataResponse struct {
	Path string          `json:"path"`
	Data json.RawMessage `json:"data"`
}

DataResponse is the struct used to respond to api requests made to the /body endpoint It is necessary because we need to include the 'path' field in the response

type DatasetMethods added in v0.9.9

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

DatasetMethods encapsulates business logic for working with Datasets on Qri

func (DatasetMethods) Activity added in v0.10.0

func (m DatasetMethods) Activity(ctx context.Context, params *ActivityParams) ([]dsref.VersionInfo, error)

Activity returns the activity and changes for a given dataset

func (DatasetMethods) Attributes added in v0.10.0

func (m DatasetMethods) Attributes() map[string]AttributeSet

Attributes defines attributes for each method

func (DatasetMethods) ComponentStatus added in v0.10.0

func (m DatasetMethods) ComponentStatus(ctx context.Context, p *LinkParams) ([]StatusItem, error)

ComponentStatus gets changes that happened at a particular version in the history of the given dataset reference.

func (DatasetMethods) DAGInfo added in v0.9.9

func (m DatasetMethods) DAGInfo(ctx context.Context, p *DAGInfoParams) (*dag.Info, error)

DAGInfo generates a dag.Info for a dataset path. If a label is given, DAGInfo will generate a sub-dag.Info at that label.

func (DatasetMethods) Get added in v0.9.9

Get retrieves datasets and components for a given reference. p.Ref is parsed to create a reference, which is used to load the dataset. It will be loaded from the local repo or from the filesystem if it has a linked working directory. Using p.Selector will control what components are returned in res.Value. The default, a blank selector, will also fill the entire dataset at res.Value. If the selector contains ".script" then res.Bytes is loaded with the script contents as bytes. If the selector is "stats", then res.Value is loaded with the generated stats.

func (DatasetMethods) GetCSV added in v0.10.0

func (m DatasetMethods) GetCSV(ctx context.Context, p *GetParams) ([]byte, error)

GetCSV fetches the body as a csv encoded byte slice, it recognizes Limit, Offset, and All list params

func (DatasetMethods) GetZip added in v0.10.0

GetZip fetches an entire dataset as a zip archive

func (DatasetMethods) Manifest added in v0.9.9

func (m DatasetMethods) Manifest(ctx context.Context, p *ManifestParams) (*dag.Manifest, error)

Manifest generates a manifest for a dataset path

func (DatasetMethods) ManifestMissing added in v0.9.9

func (m DatasetMethods) ManifestMissing(ctx context.Context, p *ManifestMissingParams) (*dag.Manifest, error)

ManifestMissing generates a manifest of blocks that are not present on this repo for a given manifest

func (DatasetMethods) Name added in v0.10.0

func (m DatasetMethods) Name() string

Name returns the name of this method group

func (DatasetMethods) Pull added in v0.9.10

Pull downloads and stores an existing dataset to a peer's repository via a network connection

func (DatasetMethods) Push added in v0.10.0

func (m DatasetMethods) Push(ctx context.Context, p *PushParams) (*dsref.Ref, error)

Push posts a dataset version to a remote

func (DatasetMethods) Remove added in v0.9.9

Remove a dataset entirely or remove a certain number of revisions

func (DatasetMethods) Rename added in v0.9.9

Rename changes a user's given name for a dataset

func (DatasetMethods) Render added in v0.10.0

func (m DatasetMethods) Render(ctx context.Context, p *RenderParams) ([]byte, error)

Render renders a viz or readme component as html

func (DatasetMethods) Save added in v0.9.9

Save adds a history entry, updating a dataset

func (DatasetMethods) Validate added in v0.9.9

Validate gives a dataset of errors and issues for a given dataset

type Delta added in v0.7.1

type Delta = deepdiff.Delta

Delta is an alias for deepdiff.Delta, abstracting the deepdiff implementation away from packages that depend on lib

type DiffMethods added in v0.10.0

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

DiffMethods encapsulates logic for diffing Datasets on Qri

func (DiffMethods) Attributes added in v0.10.0

func (m DiffMethods) Attributes() map[string]AttributeSet

Attributes defines attributes for each method

func (DiffMethods) Changes added in v0.10.0

Changes resolves the requested datasets and tries to generate a change report

func (DiffMethods) Diff added in v0.10.0

Diff computes the diff of two sources

func (DiffMethods) Name added in v0.10.0

func (m DiffMethods) Name() string

Name returns the name of this method group

type DiffMode added in v0.9.9

type DiffMode int

DiffMode is one of the methods that diff can perform

const (
	// InvalidDiffMode is the default diff mode
	InvalidDiffMode DiffMode = iota
	// DatasetRefDiffMode will diff two dataset references
	DatasetRefDiffMode
	// FilepathDiffMode will diff two files
	FilepathDiffMode
	// WorkingDirectoryDiffMode will diff a working directory against its dataset head
	WorkingDirectoryDiffMode
	// PrevVersionDiffMode will diff a dataset head against its previous version
	PrevVersionDiffMode
)

type DiffParams

type DiffParams struct {
	// File paths or reference to datasets
	LeftSide  string `schema:"leftPath" json:"leftPath" qri:"dsrefOrFspath"`
	RightSide string `schema:"rightPath" json:"rightPath" qri:"dsrefOrFspath"`
	// If not null, the working directory that the diff is using
	WorkingDir string `qri:"fspath"`
	// Whether to get the previous version of the left parameter
	UseLeftPrevVersion bool

	// Which component or part of a dataset to compare
	Selector string
}

DiffParams defines parameters for diffing two sources. There are three valid ways to use these parameters: 1) both LeftSide and RightSide set, 2) only LeftSide set with a WorkingDir, 3) only LeftSide set with the UseLeftPrevVersion flag.

type DiffResponse added in v0.7.1

type DiffResponse struct {
	Stat       *DiffStat `json:"stat,omitempty"`
	SchemaStat *DiffStat `json:"schemaStat,omitempty"`
	Schema     []*Delta  `json:"schema,omitempty"`
	Diff       []*Delta  `json:"diff,omitempty"`
}

DiffResponse is the result of a call to diff

type DiffStat added in v0.7.1

type DiffStat = deepdiff.Stats

DiffStat is an alias for deepdiff.Stat, abstracting the deepdiff implementation away from packages that depend on lib

type EmptyParams added in v0.10.0

type EmptyParams struct {
}

EmptyParams is for methods that don't need any input

type FSIMethods added in v0.9.0

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

FSIMethods groups together methods for FSI

func (FSIMethods) Attributes added in v0.10.0

func (m FSIMethods) Attributes() map[string]AttributeSet

Attributes defines attributes for each method

func (FSIMethods) CanInitDatasetWorkDir added in v0.9.9

func (m FSIMethods) CanInitDatasetWorkDir(ctx context.Context, p *InitDatasetParams) error

CanInitDatasetWorkDir returns nil if the directory can init a dataset, or an error if not

func (FSIMethods) Checkout added in v0.9.0

func (m FSIMethods) Checkout(ctx context.Context, p *LinkParams) error

Checkout method writes a dataset to a directory as individual files.

func (m FSIMethods) CreateLink(ctx context.Context, p *LinkParams) (*dsref.VersionInfo, error)

CreateLink creates a connection between a working directory and a dataset history

func (FSIMethods) EnsureRef added in v0.9.3

func (m FSIMethods) EnsureRef(ctx context.Context, p *LinkParams) (*dsref.VersionInfo, error)

EnsureRef will modify the directory path in the repo for the given reference

func (FSIMethods) Init added in v0.10.0

Init initializes a new working directory for a linked dataset

func (FSIMethods) Name added in v0.10.0

func (m FSIMethods) Name() string

Name returns the name of this method group

func (FSIMethods) Restore added in v0.9.0

func (m FSIMethods) Restore(ctx context.Context, p *RestoreParams) error

Restore method restores a component or all of the component files of a dataset from the repo

func (FSIMethods) Status added in v0.9.0

func (m FSIMethods) Status(ctx context.Context, p *LinkParams) ([]StatusItem, error)

Status checks for any modifications or errors in a linked directory against its previous version in the repo. Must only be called if FSI is enabled for this dataset.

func (m FSIMethods) Unlink(ctx context.Context, p *LinkParams) (string, error)

Unlink removes the connection between a working directory and a dataset. If given only a directory, will remove the link file from that directory. If given only a reference, will remove the fsi path from that reference, and remove the link file from that fsi path

func (FSIMethods) Write added in v0.9.0

func (m FSIMethods) Write(ctx context.Context, p *FSIWriteParams) ([]StatusItem, error)

Write mutates a linked dataset on the filesystem

type FSIWriteParams added in v0.9.0

type FSIWriteParams struct {
	Ref     string
	Dataset *dataset.Dataset
}

FSIWriteParams encapsultes arguments for writing to an FSI-linked directory

type FileParams

type FileParams struct {
	// url to download data from. either Url or Data is required
	// Url      string
	// Filename of data file. extension is used for filetype detection
	Filename string `qri:"fspath"`
	// Data is the file as slice of bytes
	Data []byte
}

FileParams defines parameters for Files as arguments to lib methods either `Filename` or `Data` is required. If both fields are set, the content in the `Data` field is favored

type GetConfigParams

type GetConfigParams struct {
	Field          string
	WithPrivateKey bool
	Format         string
	Concise        bool
}

GetConfigParams are the params needed to format/specify the fields in bytes returned from the GetConfig function

type GetParams

type GetParams struct {
	Ref string `json:"ref"`

	// selector is a component or nested field names to extract from the dataset
	Selector string `json:"selector"`

	Limit  int `json:"limit"`
	Offset int `json:"offset"`
	// TODO(dustmop): Remove `All` once `Cursor` is in use. Instead, callers should
	// loop over their `Cursor` in order to get all rows.
	All bool `json:"all"`
}

GetParams defines parameters for looking up the head or body of a dataset

func (*GetParams) SetNonZeroDefaults added in v0.10.0

func (p *GetParams) SetNonZeroDefaults()

SetNonZeroDefaults assigns default values

func (*GetParams) UnmarshalFromRequest added in v0.10.0

func (p *GetParams) UnmarshalFromRequest(r *http.Request) error

UnmarshalFromRequest satisfies the Unmarshaller interface

func (*GetParams) Validate added in v0.10.0

func (p *GetParams) Validate() error

Validate returns an error if GetParams fields are in an invalid state

type GetResult added in v0.7.0

type GetResult struct {
	Value interface{} `json:"value,omitempty"`
	Bytes []byte      `json:"bytes,omitempty"`
}

GetResult returns the dataset or some part of it as structured data inside the `Value` field The `Bytes` field is reserved for data that can only be expressed as a slice of bytes Byte slices must be treated as a special case because of json.Marshal. json.Marshal will serialize a slice of bytes as base64 encoded json. If this is deserialized into an `interface{}`, it will remain a string. It needs to be explicitly deserialized into a `[]byte` field to not degredate the information

type GetZipResults added in v0.10.0

type GetZipResults struct {
	Bytes         []byte
	GeneratedName string
}

GetZipResults is returned by `GetZip` It contains a byte slice of the compressed data as well as a generated name based on the dataset

type HTTPClient added in v0.10.0

type HTTPClient struct {
	Address  string
	Protocol string
}

HTTPClient implements the qri http client

func NewHTTPClient added in v0.10.0

func NewHTTPClient(multiaddr string) (*HTTPClient, error)

NewHTTPClient instantiates a new HTTPClient

func NewHTTPClientWithProtocol added in v0.10.0

func NewHTTPClientWithProtocol(multiaddr string, protocol string) (*HTTPClient, error)

NewHTTPClientWithProtocol instantiates a new HTTPClient with a specified protocol

func (HTTPClient) Call added in v0.10.0

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

Call calls API endpoint and passes on parameters, context info

func (HTTPClient) CallMethod added in v0.10.0

func (c HTTPClient) 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 (HTTPClient) CallMethodRaw added in v0.10.0

func (c HTTPClient) 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 (HTTPClient) CallRaw added in v0.10.0

func (c HTTPClient) 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

type InitDatasetParams added in v0.10.0

type InitDatasetParams = fsi.InitParams

InitDatasetParams proxies parameters to initialization

type Instance added in v0.8.0

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

Instance bundles the foundational values qri relies on, including a qri configuration, p2p node, and base context. An instance wraps required state for for "Method" constructors, which contain qri business logic. Think of instance as the "core" of the qri ecosystem. Create an Instance pointer with NewInstance

func NewInstance added in v0.8.0

func NewInstance(ctx context.Context, repoPath string, opts ...Option) (qri *Instance, err error)

NewInstance creates a new Qri Instance, if no Option funcs are provided, New uses a default set of Option funcs. Any Option functions passed to this function must check whether their fields are nil or not.

func NewInstanceFromConfigAndNode added in v0.8.0

func NewInstanceFromConfigAndNode(ctx context.Context, cfg *config.Config, node *p2p.QriNode) *Instance

NewInstanceFromConfigAndNode is a temporary solution to create an instance from an already-allocated QriNode & configuration don't write new code that relies on this, instead create a configuration and options that can be fed to NewInstance This function must only be used for testing purposes

func NewInstanceFromConfigAndNodeAndBus added in v0.9.10

func NewInstanceFromConfigAndNodeAndBus(ctx context.Context, cfg *config.Config, node *p2p.QriNode, bus event.Bus) *Instance

NewInstanceFromConfigAndNodeAndBus adds a bus argument to the horrible, hacky instance construtor

func (*Instance) Access added in v0.10.0

func (inst *Instance) Access() AccessMethods

Access returns the AccessMethods that Instance has registered

func (*Instance) AllMethods added in v0.10.0

func (inst *Instance) AllMethods() []MethodSet

AllMethods returns a method set for documentation purposes TODO(arqu): this is intended to merge with RegisterMethods as it's only exposed for generating the OpenAPI spec

func (*Instance) Automation added in v0.10.0

func (inst *Instance) Automation() AutomationMethods

Automation returns the AutomationMethods that Instance has registered

func (*Instance) Bus added in v0.9.5

func (inst *Instance) Bus() event.Bus

Bus exposes the instance event bus

func (*Instance) ChangeConfig added in v0.8.0

func (inst *Instance) ChangeConfig(cfg *config.Config) (err error)

ChangeConfig implements the ConfigSetter interface

func (*Instance) Collection added in v0.10.0

func (inst *Instance) Collection() CollectionMethods

Collection returns the CollectionMethods that Instance has registered

func (*Instance) Config added in v0.8.0

func (inst *Instance) Config() ConfigMethods

Config returns the ConfigMethods that Instance has registered

func (*Instance) Connect added in v0.9.0

func (inst *Instance) Connect(ctx context.Context) (err error)

Connect takes an instance online

func (*Instance) Dataset added in v0.10.0

func (inst *Instance) Dataset() DatasetMethods

Dataset returns the DatasetMethods that Instance has registered

func (*Instance) Diff added in v0.10.0

func (inst *Instance) Diff() DiffMethods

Diff returns the DiffMethods that Instance has registered

func (*Instance) Dispatch added in v0.10.0

func (inst *Instance) Dispatch(ctx context.Context, method string, param interface{}) (res interface{}, cur Cursor, err error)

Dispatch is a system for handling calls to lib. Should only be called by top-level lib methods.

When programs are using qri as a library (such as the `cmd` package), calls to `lib` will arrive at dispatch, before being routed to the actual implementation routine. This solves a few problems:

  1. Multiple methods can be running on qri at once, dispatch will schedule as needed (TODO)
  2. Access to core qri data structures (like logbook) can be handled safetly (TODO)
  3. User identity, permissions, etc is scoped to a single call, not the global process (TODO)
  4. The qri http api maps directly onto dispatch's behavior, leading to a simpler api
  5. A `qri connect` process can be transparently forwarded a method call with little work

At construction time, the Instance registers all methods that dispatch can access, as well as the input and output parameters for those methods, and associates a string name for each method. Dispatch works by looking up that method name, constructing the necessary input, then invoking the actual implementation. Dispatch returns the custom value from the implementation, then a non-nil Cursor if the method supports pagination, then an error or nil.

func (*Instance) Dscache added in v0.9.9

func (inst *Instance) Dscache() *dscache.Dscache

Dscache returns the dscache that the instance has

func (*Instance) FSI added in v0.9.3

func (inst *Instance) FSI() *fsi.FSI

FSI returns methods for using filesystem integration

func (*Instance) Filesys added in v0.10.0

func (inst *Instance) Filesys() FSIMethods

Filesys returns the FSIMethods that Instance has registered

func (*Instance) GetConfig deprecated added in v0.10.0

func (inst *Instance) GetConfig() *config.Config

GetConfig provides methods for manipulating Qri configuration

Deprecated: this method will be removed in a future release. Use inst.Config().GetConfig instead

func (*Instance) GiveAPIServer added in v0.10.0

func (inst *Instance) GiveAPIServer(middleware func(handler http.HandlerFunc) http.HandlerFunc, ignoreMethods []string) *mux.Router

GiveAPIServer creates an API server that gives access to lib's registered methods

func (*Instance) HTTPClient added in v0.10.0

func (inst *Instance) HTTPClient() *HTTPClient

HTTPClient accesses the instance HTTP client if one exists

func (*Instance) Log added in v0.10.0

func (inst *Instance) Log() LogMethods

Log returns the LogMethods that Instance has registered

func (*Instance) NewInputParam added in v0.10.0

func (inst *Instance) NewInputParam(method string) interface{}

NewInputParam takes a method name that has been registered, and constructs an instance of that input parameter

func (*Instance) Node added in v0.8.0

func (inst *Instance) Node() *p2p.QriNode

Node accesses the instance qri node if one exists

func (*Instance) ParseAndResolveRef added in v0.9.9

func (inst *Instance) ParseAndResolveRef(ctx context.Context, refStr, source string, useFSI bool) (dsref.Ref, string, error)

ParseAndResolveRef combines reference parsing and resolution

func (*Instance) Peer added in v0.10.0

func (inst *Instance) Peer() PeerMethods

Peer returns the PeerMethods that Instance has registered

func (*Instance) Profile added in v0.10.0

func (inst *Instance) Profile() ProfileMethods

Profile returns the ProfileMethods that Instance has registered

func (*Instance) RegisterMethods added in v0.10.0

func (inst *Instance) RegisterMethods()

RegisterMethods iterates the methods provided by the lib API, and makes them visible to dispatch

func (*Instance) Registry added in v0.10.0

func (inst *Instance) Registry() RegistryClientMethods

Registry returns the RegistryMethods that Instance has registered

func (*Instance) Remote added in v0.9.0

func (inst *Instance) Remote() RemoteMethods

Remote returns the RemoteMethods that Instance has registered

func (*Instance) RemoteClient added in v0.9.0

func (inst *Instance) RemoteClient() remote.Client

RemoteClient exposes the instance client for making requests to remotes

func (*Instance) RemoteServer added in v0.10.0

func (inst *Instance) RemoteServer() *remote.Remote

RemoteServer accesses the remote subsystem if one exists

func (*Instance) Repo added in v0.8.0

func (inst *Instance) Repo() repo.Repo

Repo accesses the instance Repo if one exists

func (*Instance) RepoPath added in v0.8.0

func (inst *Instance) RepoPath() string

RepoPath returns the path to the directory qri is operating from

func (*Instance) ResolveReference added in v0.9.9

func (inst *Instance) ResolveReference(ctx context.Context, ref *dsref.Ref, source string) (string, error)

ResolveReference finds the identifier & HEAD path for a dataset reference. the source parameter determines which subsystems of Qri to use when resolving

func (*Instance) SQL added in v0.10.0

func (inst *Instance) SQL() SQLMethods

SQL returns the SQLMethods that Instance has registered

func (*Instance) Search added in v0.10.0

func (inst *Instance) Search() SearchMethods

Search returns the SearchMethods that Instance has registered

func (*Instance) Shutdown added in v0.9.9

func (inst *Instance) Shutdown() <-chan error

Shutdown closes the instance, releasing all held resources. the returned channel will write any closing error, including context cancellation timeout

func (*Instance) WithSource added in v0.10.0

func (inst *Instance) WithSource(source string) *InstanceSourceWrap

WithSource returns a wrapped instance that will resolve refs from the given source

type InstanceContextKey added in v0.9.3

type InstanceContextKey string

InstanceContextKey is used by context to set keys for constucting a lib.Instance

type InstanceOptions added in v0.8.0

type InstanceOptions struct {
	Cfg     *config.Config
	Streams ioes.IOStreams
	// contains filtered or unexported fields
}

InstanceOptions provides details to NewInstance. New will alter InstanceOptions by applying any provided Option functions to distinguish "Options" from "Config": * Options contains state that can only be determined at runtime * Config consists only of static values stored in a configuration file Options may override config in specific cases to avoid undefined state

type InstanceSourceWrap added in v0.10.0

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

InstanceSourceWrap is a wrapped instance with an explicit resolver source added TODO(dustmop): This struct is a temporary solution. The better approach is to make it easy to copy the Instance cheaply. All of Instance's "heavy" state, such as the Bus, and Logbook, should live on a shared object, while values that can be overwritten should live as separate fields. Then `WithSource` can be replaced with a method that constructs a new Instance that points to the original shared object, with other fields assigned as needed.

func (*InstanceSourceWrap) Dataset added in v0.10.0

func (isw *InstanceSourceWrap) Dataset() DatasetMethods

Dataset returns the DatasetMethods that Instance has registered

func (*InstanceSourceWrap) Dispatch added in v0.10.0

func (isw *InstanceSourceWrap) Dispatch(ctx context.Context, method string, param interface{}) (res interface{}, cur Cursor, err error)

Dispatch calls the same instance Dispatch but with an explicit source for ref resolution

func (*InstanceSourceWrap) Log added in v0.10.0

func (isw *InstanceSourceWrap) Log() LogMethods

Log returns the LogMethods that Instance has registered

func (*InstanceSourceWrap) Remote added in v0.10.0

func (isw *InstanceSourceWrap) Remote() RemoteMethods

Remote returns the RemoteMethods that Instance has registered

func (*InstanceSourceWrap) SQL added in v0.10.0

func (isw *InstanceSourceWrap) SQL() SQLMethods

SQL returns the SQLMethods that Instance has registered

type LinkParams added in v0.9.0

type LinkParams struct {
	Dir string `qri:"fspath"`
	Ref string
}

LinkParams encapsulate parameters for linked datasets

type ListParams

type ListParams struct {
	ProfileID profile.ID `json:"-"`
	Term      string
	Username  string
	OrderBy   string
	Limit     int
	Offset    int
	// Public only applies to listing datasets, shows only datasets that are
	// set to visible
	Public bool
	// ShowNumVersions only applies to listing datasets
	ShowNumVersions bool
	// EnsureFSIExists controls whether to ensure references in the repo have correct FSIPaths
	EnsureFSIExists bool
}

ListParams is the general input for any sort of Paginated Request ListParams define limits & offsets, not pages & page sizes. TODO - rename this to PageParams.

func ListParamsFromRequest

func ListParamsFromRequest(r *http.Request) ListParams

ListParamsFromRequest extracts ListParams from an http.Request pointer

func NewListParams

func NewListParams(orderBy string, page, pageSize int) ListParams

NewListParams creates a ListParams from page & pagesize, pages are 1-indexed (the first element is 1, not 0), NewListParams performs the conversion

func (ListParams) Page

func (p ListParams) Page() util.Page

Page converts a ListParams struct to a util.Page struct

func (*ListParams) SetNonZeroDefaults added in v0.10.0

func (p *ListParams) SetNonZeroDefaults()

SetNonZeroDefaults sets OrderBy to "created" if it's value is the empty string

type LogEntry added in v0.9.1

type LogEntry = logbook.LogEntry

LogEntry is a record in a log of operations on a dataset

type LogMethods added in v0.9.9

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

LogMethods extends a lib.Instance with business logic for working with lists of dataset versions. think "git log".

func (LogMethods) Attributes added in v0.10.0

func (m LogMethods) Attributes() map[string]AttributeSet

Attributes defines attributes for each method

func (LogMethods) Log added in v0.9.9

func (m LogMethods) Log(ctx context.Context, p *RefListParams) ([]LogEntry, error)

Log lists log entries for actions taken on a given dataset

func (LogMethods) LogbookSummary added in v0.9.9

func (m LogMethods) LogbookSummary(ctx context.Context, p *struct{}) (*string, error)

LogbookSummary returns a string overview of the logbook

func (LogMethods) Name added in v0.10.0

func (m LogMethods) Name() string

Name returns the name of this method group

func (LogMethods) RawLogbook added in v0.10.0

func (m LogMethods) RawLogbook(ctx context.Context, p *RawLogbookParams) (*RawLogs, error)

RawLogbook encodes the full logbook as human-oriented json

type ManifestMissingParams added in v0.10.0

type ManifestMissingParams struct {
	Manifest *dag.Manifest
}

ManifestMissingParams encapsulates parameters to the missing manifest command

type ManifestParams added in v0.10.0

type ManifestParams struct {
	Ref string
}

ManifestParams encapsulates parameters to the manifest command

type MethodSet added in v0.10.0

type MethodSet interface {
	Name() string
	Attributes() map[string]AttributeSet
}

MethodSet represents a set of methods to be registered Each registered method should have 2 input parameters and 1-3 output values

Input: (context.Context, input struct)
Output, 1: (error)
        2: (output, error)
        3: (output, Cursor, error)

The implementation should have the same input and output as the method, except with the context.Context replaced by a scope. No other functions are allowed to be defined, other that those that are going to be registered (as described above) and those that are required by the interface.

type Methods added in v0.8.0

type Methods interface {
	// CoreRequestsName confirms participation in the CoreRequests interface while
	// also giving a human readable string for logging purposes
	// TODO (b5): rename this interface to "MethodsName", or remove entirely
	CoreRequestsName() string
}

Methods is a related set of library functions

type NZDefaultSetter added in v0.10.0

type NZDefaultSetter interface {
	SetNonZeroDefaults()
}

NZDefaultSetter modifies zero values to non-zero defaults when called

type Option added in v0.8.0

type Option func(o *InstanceOptions) error

Option is a function that manipulates config details when fed to New(). Fields on the o parameter may be null, functions cannot assume the Config is non-null.

func OptBus added in v0.10.0

func OptBus(bus event.Bus) Option

OptBus overrides the configured `event.Bus` with a manually provided one

func OptCheckConfigMigrations added in v0.8.0

func OptCheckConfigMigrations(shouldRunFn func() bool, errOnSuccess bool) Option

OptCheckConfigMigrations checks for any configuration migrations that may need to be run. running & updating config if so

func OptConfig added in v0.8.0

func OptConfig(cfg *config.Config) Option

OptConfig supplies a configuration directly

func OptDscache added in v0.10.0

func OptDscache(dscache *dscache.Dscache) Option

OptDscache overrides the configured `dscache.Dscache` with a manually provided one

func OptEnableRemote added in v0.9.10

func OptEnableRemote() Option

OptEnableRemote enables the remote functionality in the node

func OptEventHandler added in v0.9.10

func OptEventHandler(handler event.Handler, events ...event.Type) Option

OptEventHandler provides an event handler & list of event types to subscribe to. The canonical list of events a qri instance emits are defined in the github.com/qri-io/qri/event package plase note that event handlers in qri are synchronous. A handler function that takes a long time to return will slow down the performance of qri generally

func OptIOStreams added in v0.8.0

func OptIOStreams(streams ioes.IOStreams) Option

OptIOStreams sets the input IOStreams

func OptLogbook added in v0.9.3

func OptLogbook(bk *logbook.Book) Option

OptLogbook overrides the configured logbook with a manually provided one

func OptNoBootstrap added in v0.9.10

func OptNoBootstrap() Option

OptNoBootstrap ensures the node will not attempt to bootstrap to any other nodes in the network

func OptProfiles added in v0.10.0

func OptProfiles(pros profile.Store) Option

OptProfiles supplies a profile store for the instance

func OptQriNode added in v0.9.0

func OptQriNode(node *p2p.QriNode) Option

OptQriNode configures bring-your-own qri node

func OptRegistryClient added in v0.9.0

func OptRegistryClient(cli *regclient.Client) Option

OptRegistryClient overrides any configured registry client

func OptRemoteOptions added in v0.9.0

func OptRemoteOptions(fns []remote.OptionsFunc) Option

OptRemoteOptions provides options to the instance remote the provided configuration function is called with the Qri configuration-derived remote settings applied, allowing partial-overrides.

func OptSetIPFSPath added in v0.8.0

func OptSetIPFSPath(path string) Option

OptSetIPFSPath sets the directory to read IPFS from. Passing the empty string adjusts qri to use the go-ipfs default: first checking the IPFS_PATH env variable, then falling back to $HOME/.ipfs if no ipfs filesystem is configured, this option creates one

func OptSetLogAll added in v0.9.4

func OptSetLogAll(logAll bool) Option

OptSetLogAll sets the logAll value so that debug level logging is enabled for all qri packages

func OptSetOpenFileTimeout added in v0.9.10

func OptSetOpenFileTimeout(d time.Duration) Option

OptSetOpenFileTimeout sets a timeout duration for opening files

func OptStatsCache added in v0.9.2

func OptStatsCache(statsCache stats.Cache) Option

OptStatsCache overrides the configured stats cache

func OptStdIOStreams added in v0.8.0

func OptStdIOStreams() Option

OptStdIOStreams sets treams to std, stdout, & stderr

type ParamValidator added in v0.10.0

type ParamValidator interface {
	Validate() error
}

ParamValidator may be implemented by method parameter structs, and if so then Dispatch will validate the parameters are okay before calling anything

type PeerInfoParams

type PeerInfoParams struct {
	Peername  string
	ProfileID string
	// Verbose adds network details from the p2p Peerstore
	Verbose bool
}

PeerInfoParams defines parameters for the Info method

type PeerListParams

type PeerListParams struct {
	Limit, Offset int
	// Cached == true will return offline peers from the repo
	// as well as online peers, default is to list connected peers only
	Cached bool
}

PeerListParams defines parameters for the List method

type PeerMethods added in v0.9.9

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

PeerMethods extends a lib.Instance with business logic for peer-to-peer interaction

func (PeerMethods) Attributes added in v0.10.0

func (m PeerMethods) Attributes() map[string]AttributeSet

Attributes defines attributes for each method

func (PeerMethods) Connect added in v0.10.0

Connect attempts to create a connection with a peer for a given peer.ID

func (PeerMethods) ConnectedQriProfiles added in v0.9.9

func (m PeerMethods) ConnectedQriProfiles(ctx context.Context, p *ConnectionsParams) ([]*config.ProfilePod, error)

ConnectedQriProfiles lists profiles we're currently connected to

func (PeerMethods) Connections added in v0.10.0

func (m PeerMethods) Connections(ctx context.Context, p *ConnectionsParams) ([]string, error)

Connections lists PeerID's we're currently connected to. If running IPFS this will also return connected IPFS nodes

func (PeerMethods) Disconnect added in v0.10.0

func (m PeerMethods) Disconnect(ctx context.Context, p *ConnectParamsPod) error

Disconnect explicitly closes a peer connection

func (PeerMethods) Info added in v0.9.9

Info shows peer profile details

func (PeerMethods) List added in v0.9.9

List lists Peers on the qri network

func (PeerMethods) Name added in v0.10.0

func (m PeerMethods) Name() string

Name returns the name of this method group

type PreviewParams added in v0.9.5

type PreviewParams struct {
	Ref string
}

PreviewParams provides arguments to the preview method

type ProfileMethods added in v0.8.0

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

ProfileMethods encapsulates business logic for this node's user profile TODO (b5) - alterations to user profile are a subset of configuration changes. all of this code should be refactored into subroutines of general configuration getters & setters

func (ProfileMethods) Attributes added in v0.10.0

func (m ProfileMethods) Attributes() map[string]AttributeSet

Attributes defines attributes for each method

func (ProfileMethods) GetProfile added in v0.8.0

GetProfile get's this node's peer profile

func (ProfileMethods) Name added in v0.10.0

func (m ProfileMethods) Name() string

Name returns the name of this method group

func (ProfileMethods) SetPosterPhoto added in v0.8.0

func (m ProfileMethods) SetPosterPhoto(ctx context.Context, p *FileParams) (*config.ProfilePod, error)

SetPosterPhoto changes this active peer's poster image

func (ProfileMethods) SetProfile added in v0.10.0

SetProfile stores changes to the active peer's editable profile

func (ProfileMethods) SetProfilePhoto added in v0.8.0

func (m ProfileMethods) SetProfilePhoto(ctx context.Context, p *FileParams) (*config.ProfilePod, error)

SetProfilePhoto changes the active peer's profile image

type ProfileParams added in v0.10.0

type ProfileParams struct{}

ProfileParams define parameters for getting a profile

type PullParams added in v0.9.10

type PullParams struct {
	Ref      string
	LinkDir  string `qri:"fspath"`
	LogsOnly bool   // only fetch logbook data
}

PullParams encapsulates parameters to the add command

type PushParams added in v0.7.3

type PushParams struct {
	Ref    string `schema:"ref" json:"ref"`
	Remote string
	// All indicates all versions of a dataset and the dataset namespace should
	// be either published or removed
	All bool
}

PushParams encapsulates parmeters for dataset publication

type RawLogbookParams added in v0.10.0

type RawLogbookParams struct {
}

RawLogbookParams enapsulates parameters for the RawLogbook methods

type RawLogs added in v0.9.1

type RawLogs = []logbook.PlainLog

RawLogs is an alias for a human representation of a plain-old-data logbook

type RefListParams added in v0.9.1

type RefListParams struct {
	// String value of a reference
	Ref string
	// Pagination Parameters
	Offset, Limit int
}

RefListParams encapsulates parameters for requests to a single reference that will produce a paginated result

type RegistryClientMethods added in v0.9.0

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

RegistryClientMethods defines business logic for working with registries

func (RegistryClientMethods) Attributes added in v0.10.0

func (m RegistryClientMethods) Attributes() map[string]AttributeSet

Attributes defines attributes for each method

func (RegistryClientMethods) CreateProfile added in v0.9.0

CreateProfile creates a profile

func (RegistryClientMethods) Name added in v0.10.0

func (m RegistryClientMethods) Name() string

Name returns the name of this method group

func (RegistryClientMethods) ProveProfileKey added in v0.9.0

ProveProfileKey sends proof to the registry that this user has control of a specified private key, and modifies the user's config in order to reconcile it with any already existing identity the registry knows about

type RegistryProfile added in v0.9.0

type RegistryProfile = registry.Profile

RegistryProfile is a user profile as stored on a registry

type RegistryProfileParams added in v0.10.0

type RegistryProfileParams struct {
	Profile *RegistryProfile
}

RegistryProfileParams encapsulates arguments for creating or proving a registry profile

type RemoteMethods added in v0.9.0

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

RemoteMethods encapsulates business logic of remote operation TODO (b5): switch to using an Instance instead of separate fields

func (RemoteMethods) Attributes added in v0.10.0

func (m RemoteMethods) Attributes() map[string]AttributeSet

Attributes defines attributes for each method

func (RemoteMethods) Feeds added in v0.9.5

Feeds returns a listing of datasets from a number of feeds like featured and popular. Each feed is keyed by string in the response

func (RemoteMethods) Name added in v0.10.0

func (m RemoteMethods) Name() string

Name returns the name of this method group

func (RemoteMethods) Preview added in v0.9.5

Preview requests a dataset preview from a remote

func (RemoteMethods) Remove added in v0.9.10

func (m RemoteMethods) Remove(ctx context.Context, p *PushParams) (*dsref.Ref, error)

Remove asks a remote to remove a dataset

type RemoveParams added in v0.6.2

type RemoveParams struct {
	Ref       string
	Revision  *dsref.Rev
	KeepFiles bool
	Force     bool
}

RemoveParams defines parameters for remove command

func (*RemoveParams) SetNonZeroDefaults added in v0.10.0

func (p *RemoveParams) SetNonZeroDefaults()

SetNonZeroDefaults assigns default values

type RemoveResponse added in v0.7.0

type RemoveResponse struct {
	Ref        string
	NumDeleted int
	Message    string
	Unlinked   bool
}

RemoveResponse gives the results of a remove

type RenameParams

type RenameParams struct {
	Current, Next string
}

RenameParams defines parameters for Dataset renaming

type RenderParams

type RenderParams struct {
	// Ref is a string reference to the dataset to render
	Ref string `json:"ref"`
	// Optionally pass an entire dataset in for rendering, if providing a dataset,
	// the Ref field must be empty
	Dataset *dataset.Dataset
	// Optional template override
	Template []byte
	// If true,
	UseFSI bool
	// Output format. defaults to "html"
	Format string
	// Selector
	Selector string `json:"selector"`
}

RenderParams defines parameters for the Render method

func (*RenderParams) SetNonZeroDefaults added in v0.10.0

func (p *RenderParams) SetNonZeroDefaults()

SetNonZeroDefaults assigns default values

func (*RenderParams) Validate added in v0.9.5

func (p *RenderParams) Validate() error

Validate checks if render parameters are valid

type RestoreParams added in v0.9.0

type RestoreParams struct {
	Dir      string `qri:"fspath"`
	Ref      string
	Version  string
	Selector string
}

RestoreParams provides parameters to the restore method.

type SQLMethods added in v0.9.7

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

SQLMethods groups together methods for SQL

func (SQLMethods) Attributes added in v0.10.0

func (m SQLMethods) Attributes() map[string]AttributeSet

Attributes defines attributes for each method

func (SQLMethods) Exec added in v0.9.7

func (m SQLMethods) Exec(ctx context.Context, p *SQLQueryParams) ([]byte, error)

Exec runs an SQL query

func (SQLMethods) Name added in v0.10.0

func (m SQLMethods) Name() string

Name returns the name of this method group

type SQLQueryParams added in v0.9.7

type SQLQueryParams struct {
	Query  string
	Format string
}

SQLQueryParams defines paremeters for running a SQL query

func (*SQLQueryParams) SetNonZeroDefaults added in v0.10.0

func (p *SQLQueryParams) SetNonZeroDefaults()

SetNonZeroDefaults sets format to "json" if it's value is an empty string

type SaveParams

type SaveParams struct {
	// dataset supplies params directly, all other param fields override values
	// supplied by dataset
	Dataset *dataset.Dataset

	// dataset reference string, the name to save to
	Ref string
	// commit title, defaults to a generated string based on diff
	Title string
	// commit message, defaults to blank
	Message string
	// path to body data
	BodyPath string `qri:"fspath"`
	// absolute path or URL to the list of dataset files or components to load
	FilePaths []string `qri:"fspath"`
	// secrets for transform execution
	Secrets map[string]string
	// optional writer to have transform script record standard output to
	// note: this won't work over RPC, only on local calls
	ScriptOutput io.Writer `json:"-"`

	// Apply runs a transform script to create the next version to save
	Apply bool
	// Replace writes the entire given dataset as a new snapshot instead of
	// applying save params as augmentations to the existing history
	Replace bool
	// option to make dataset private. private data is not currently implimented,
	// see https://github.com/qri-io/qri/issues/291 for updates
	Private bool
	// if true, convert body to the format of the previous version, if applicable
	ConvertFormatToPrev bool
	// comma separated list of component names to delete before saving
	Drop string
	// force a new commit, even if no changes are detected
	Force bool
	// save a rendered version of the template along with the dataset
	ShouldRender bool
	// new dataset only, don't create a commit on an existing dataset, name will be unused
	NewName bool
}

SaveParams encapsulates arguments to Save

func (*SaveParams) SetNonZeroDefaults added in v0.10.0

func (p *SaveParams) SetNonZeroDefaults()

SetNonZeroDefaults sets basic save path params to defaults

type SearchMethods added in v0.9.0

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

SearchMethods groups together methods for search

func (SearchMethods) Attributes added in v0.10.0

func (m SearchMethods) Attributes() map[string]AttributeSet

Attributes defines attributes for each method

func (SearchMethods) Name added in v0.10.0

func (m SearchMethods) Name() string

Name returns the name of this method group

func (SearchMethods) Search added in v0.9.0

Search queries for items on qri related to given parameters

type SearchParams

type SearchParams struct {
	Query  string `json:"q"`
	Limit  int    `json:"limit,omitempty"`
	Offset int    `json:"offset,omitempty"`
}

SearchParams defines paremeters for the search Method

type SearchResult

type SearchResult struct {
	Type, ID string
	URL      string
	Value    *dataset.Dataset
}

SearchResult struct

type SetProfileParams added in v0.10.0

type SetProfileParams struct {
	Pro *config.ProfilePod
}

SetProfileParams defines parameters for setting parts of a profile Cannot use this to set private keys, your peername, or peer id

type SetupParams

type SetupParams struct {
	// a configuration is required. defaults to config.DefaultConfig()
	Config *config.Config
	// where to initialize qri repository
	RepoPath string
	// submit new username to the configured registry
	Register bool
	// overwrite any existing repo, erasing all data and deleting private keys
	// this is almost always a bad idea
	Overwrite bool
	// attempt to setup an IFPS repo
	SetupIPFS           bool
	SetupIPFSConfigData []byte
	// setup requires a crypto source
	Generator key.CryptoGenerator
}

SetupParams encapsulates arguments for Setup

type StatusItem added in v0.9.0

type StatusItem = fsi.StatusItem

StatusItem is an alias for an fsi.StatusItem

type TeardownParams

type TeardownParams struct {
	Config         *config.Config
	RepoPath       string
	ConfigFilepath string
}

TeardownParams encapsulates arguments for Setup

type ValidateParams added in v0.9.13

type ValidateParams struct {
	Ref               string
	BodyFilename      string `qri:"fspath"`
	SchemaFilename    string `qri:"fspath"`
	StructureFilename string `qri:"fspath"`
}

ValidateParams defines parameters for dataset data validation

type ValidateResponse added in v0.9.13

type ValidateResponse struct {
	// Structure used to perform validation
	Structure *dataset.Structure
	// Validation Errors
	Errors []jsonschema.KeyError
}

ValidateResponse is the result of running validate against a dataset

type WebsocketHandler added in v0.10.0

type WebsocketHandler interface {
	WSConnectionHandler(w http.ResponseWriter, r *http.Request)
}

WebsocketHandler defines the handler interface

func NewWebsocketHandler added in v0.10.0

func NewWebsocketHandler(ctx context.Context, inst *Instance) (WebsocketHandler, error)

NewWebsocketHandler creates a new wsHandler instance that clients can connect to in order to get realtime events

Jump to

Keyboard shortcuts

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