lib

package
v0.9.8 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2020 License: GPL-3.0 Imports: 62 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 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 (
	// 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 (
	// ErrBadArgs is an error for when a user provides bad arguments
	ErrBadArgs = errors.New("bad arguments provided")
)
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

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 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 much sense

func Teardown

func Teardown(p TeardownParams) error

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

Types

type AddParams added in v0.9.0

type AddParams struct {
	Ref        string
	LinkDir    string
	RemoteAddr string // remote to attempt to pull from
	LogsOnly   bool   // only fetch logbook data
}

AddParams encapsulates parameters to the add command

type CheckoutParams added in v0.9.0

type CheckoutParams struct {
	Dir string
	Ref string
}

CheckoutParams provides parameters to the Checkout method.

type CompleteParams added in v0.7.3

type CompleteParams struct {
	SessionID string
}

CompleteParams holds parameters to send when completing a dsync sent to a remote

type ConfigMethods added in v0.8.0

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

ConfigMethods encapsulates changes to a qri configuration

func NewConfigMethods added in v0.8.0

func NewConfigMethods(inst *Instance) *ConfigMethods

NewConfigMethods creates a configuration handle from an instance

func (ConfigMethods) CoreRequestsName added in v0.8.0

func (m ConfigMethods) CoreRequestsName() string

CoreRequestsName specifies this is a configuration handle

func (*ConfigMethods) GetConfig added in v0.8.0

func (m *ConfigMethods) GetConfig(p *GetConfigParams, res *[]byte) (err 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(p *GetConfigParams, res *[]byte) (err 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) SetConfig added in v0.8.0

func (m *ConfigMethods) SetConfig(update *config.Config, set *bool) (err error)

SetConfig validates, updates and saves the config

type DAGInfoParams added in v0.7.3

type DAGInfoParams struct {
	RefStr, Label string
}

DAGInfoParams defines parameters for the DAGInfo method

type DatasetLogItem added in v0.9.1

type DatasetLogItem = logbook.DatasetLogItem

DatasetLogItem is a line item in a dataset logbook

type DatasetRequests

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

DatasetRequests encapsulates business logic for working with Datasets on Qri TODO (b5): switch to using an Instance instead of separate fields

func NewDatasetRequests

func NewDatasetRequests(node *p2p.QriNode, cli *rpc.Client) *DatasetRequests

NewDatasetRequests creates a DatasetRequests pointer from either a repo or an rpc.Client

Deprecated. use NewDatasetRequestsInstance

func NewDatasetRequestsInstance added in v0.9.0

func NewDatasetRequestsInstance(inst *Instance) *DatasetRequests

NewDatasetRequestsInstance creates a DatasetRequests pointer from a qri instance

func (*DatasetRequests) Add

func (r *DatasetRequests) Add(p *AddParams, res *reporef.DatasetRef) (err error)

Add adds an existing dataset to a peer's repository

func (DatasetRequests) CoreRequestsName

func (DatasetRequests) CoreRequestsName() string

CoreRequestsName implements the Requets interface

func (*DatasetRequests) DAGInfo added in v0.7.3

func (r *DatasetRequests) DAGInfo(s *DAGInfoParams, i *dag.Info) (err 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 (*DatasetRequests) Diff

func (r *DatasetRequests) Diff(p *DiffParams, res *DiffResponse) (err error)

Diff computes the diff of two datasets

func (*DatasetRequests) Get

func (r *DatasetRequests) Get(p *GetParams, res *GetResult) (err error)

Get retrieves datasets and components for a given reference. p.Refstr 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 direoctry. Using p.Selector will control what components are returned in res.Bytes. The default, a blank selector, will also fill the entire dataset at res.Data. If the selector is "body" then res.Bytes is loaded with the body. If the selector is "stats", then res.Bytes is loaded with the generated stats.

func (*DatasetRequests) List

func (r *DatasetRequests) List(p *ListParams, res *[]dsref.VersionInfo) error

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

func (*DatasetRequests) ListRawRefs added in v0.9.3

func (r *DatasetRequests) ListRawRefs(p *ListParams, text *string) (err error)

ListRawRefs gets the list of raw references as string

func (*DatasetRequests) Manifest added in v0.6.1

func (r *DatasetRequests) Manifest(refstr *string, m *dag.Manifest) (err error)

Manifest generates a manifest for a dataset path

func (*DatasetRequests) ManifestMissing added in v0.6.1

func (r *DatasetRequests) ManifestMissing(a, b *dag.Manifest) (err error)

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

func (*DatasetRequests) Remove

func (r *DatasetRequests) Remove(p *RemoveParams, res *RemoveResponse) error

Remove a dataset entirely or remove a certain number of revisions

func (*DatasetRequests) Rename

func (r *DatasetRequests) Rename(p *RenameParams, res *dsref.VersionInfo) (err error)

Rename changes a user's given name for a dataset

func (*DatasetRequests) Save

func (r *DatasetRequests) Save(p *SaveParams, res *reporef.DatasetRef) (err error)

Save adds a history entry, updating a dataset

func (*DatasetRequests) SetPublishStatus added in v0.6.0

func (r *DatasetRequests) SetPublishStatus(p *SetPublishStatusParams, publishedRef *reporef.DatasetRef) (err error)

SetPublishStatus updates the publicity of a reference in the peer's namespace

func (*DatasetRequests) Stats added in v0.9.2

func (r *DatasetRequests) Stats(p *StatsParams, res *StatsResponse) (err error)

Stats generates stats for a dataset

func (*DatasetRequests) Validate

func (r *DatasetRequests) Validate(p *ValidateDatasetParams, valerrs *[]jsonschema.ValError) (err error)

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 DiffParams

type DiffParams struct {
	// File path or reference to a dataset
	LeftPath, RightPath string

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

	// If not null, the working directory that the diff is using
	WorkingDir string
	// Whether to get the previous version of the left parameter
	IsLeftAsPrevious bool

	Limit, Offset int
	All           bool
}

DiffParams defines parameters for diffing two datasets with Diff

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 EnsureParams added in v0.9.3

type EnsureParams struct {
	Dir string
	Ref string
}

EnsureParams holds values for EnsureRef call

type ExportParams added in v0.6.2

type ExportParams struct {
	Ref       string
	TargetDir string
	Output    string
	Format    string
	Zipped    bool
}

ExportParams defines parameters for the export method

type ExportRequests added in v0.6.2

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

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

func NewExportRequests added in v0.6.2

func NewExportRequests(node *p2p.QriNode, cli *rpc.Client) *ExportRequests

NewExportRequests creates a ExportRequests pointer from either a repo or an rpc.Client

func (ExportRequests) CoreRequestsName added in v0.6.2

func (r ExportRequests) CoreRequestsName() string

CoreRequestsName implements the Requests interface

func (*ExportRequests) Export added in v0.6.2

func (r *ExportRequests) Export(p *ExportParams, fileWritten *string) (err error)

Export exports a dataset in the specified format

type FSIMethods added in v0.9.0

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

FSIMethods encapsulates filesystem integrations methods

func NewFSIMethods added in v0.9.0

func NewFSIMethods(inst *Instance) *FSIMethods

NewFSIMethods creates a fsi handle from an instance

func (*FSIMethods) Checkout added in v0.9.0

func (m *FSIMethods) Checkout(p *CheckoutParams, out *string) (err error)

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

func (FSIMethods) CoreRequestsName added in v0.9.0

func (m FSIMethods) CoreRequestsName() string

CoreRequestsName specifies this is a fsi handle

func (m *FSIMethods) CreateLink(p *LinkParams, res *string) (err error)

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

func (*FSIMethods) EnsureRef added in v0.9.3

func (m *FSIMethods) EnsureRef(p *EnsureParams, out *bool) error

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

func (*FSIMethods) InitDataset added in v0.9.0

func (m *FSIMethods) InitDataset(p *InitFSIDatasetParams, name *string) (err error)

InitDataset creates a new dataset and FSI link

func (*FSIMethods) LinkedRefs added in v0.9.0

func (m *FSIMethods) LinkedRefs(p *ListParams, res *[]reporef.DatasetRef) (err error)

LinkedRefs lists all fsi links

func (*FSIMethods) Restore added in v0.9.0

func (m *FSIMethods) Restore(p *RestoreParams, out *string) (err 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(dir *string, res *[]StatusItem) (err 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 (*FSIMethods) StatusForAlias added in v0.9.0

func (m *FSIMethods) StatusForAlias(alias *string, res *[]StatusItem) (err error)

StatusForAlias receives an alias for a dataset that must be linked to the filesystem, and checks the status of its current working directory. It is an error to call this for a reference that is not linked.

func (m *FSIMethods) Unlink(p *LinkParams, res *string) (err 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) WhatChanged added in v0.9.7

func (m *FSIMethods) WhatChanged(ref *string, res *[]StatusItem) (err error)

WhatChanged gets changes that happened at a particular version in the history of the given dataset reference. Not used for FSI.

func (*FSIMethods) Write added in v0.9.0

func (m *FSIMethods) Write(p *FSIWriteParams, res *[]StatusItem) (err error)

Write mutates a linked dataset on the filesystem

type FSIWriteParams added in v0.9.0

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

FSIWriteParams encapsultes arguments for writing to an FSI-linked directory

type FetchParams added in v0.9.1

type FetchParams struct {
	Ref        string
	RemoteName string
}

FetchParams encapsulates parameters for a fetch request

type FileParams

type FileParams struct {
	// Url      string    // url to download data from. either Url or Data is required
	Filename string    // filename of data file. extension is used for filetype detection
	Data     io.Reader // reader of structured data. either Url or Data is required
}

FileParams defines parameters for Files as arguments to lib methods

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 {
	// Refstr to get, representing a dataset ref to be parsed
	Refstr string

	// read from a filesystem link instead of stored version
	Format       string
	FormatConfig dataset.FormatConfig

	Selector string

	Limit, Offset int
	All           bool
}

GetParams defines parameters for looking up the body of a dataset

type GetResult added in v0.7.0

type GetResult struct {
	Ref       *dsref.Ref       `json:"ref"`
	Dataset   *dataset.Dataset `json:"data"`
	Bytes     []byte           `json:"bytes"`
	FSIPath   string           `json:"fsipath"`
	Published bool             `json:"published"`
}

GetResult combines data with it's hashed path

type InitFSIDatasetParams added in v0.9.0

type InitFSIDatasetParams = fsi.InitParams

InitFSIDatasetParams proxies parameters to initialization

type Instance added in v0.8.0

type Instance struct {
	Watcher *watchfs.FilesysWatcher
	// 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(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

func (*Instance) Bus added in v0.9.5

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

Bus returns the 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) Config added in v0.8.0

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

Config provides methods for manipulating Qri configuration

func (*Instance) Connect added in v0.9.0

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

Connect takes an instance online

func (*Instance) Context added in v0.8.0

func (inst *Instance) Context() context.Context

Context returns the base context for this instance

func (*Instance) FSI added in v0.9.3

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

FSI returns methods for using filesystem integration

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) RPC added in v0.8.0

func (inst *Instance) RPC() *rpc.Client

RPC accesses the instance RPC client if one exists

func (*Instance) Remote added in v0.9.0

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

Remote accesses the remote subsystem if one exists

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) 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) Teardown added in v0.8.0

func (inst *Instance) Teardown()

Teardown destroys the instance, releasing reserved resources

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 Job added in v0.8.0

type Job = cron.Job

Job aliases a cron.Job, removing the need to import the cron package to work with lib.UpdateMethods

type LinkParams added in v0.9.0

type LinkParams struct {
	Dir string
	Ref string
}

LinkParams encapsulate parameters to the link method

type ListParams

type ListParams struct {
	ProfileID profile.ID
	Term      string
	Peername  string
	OrderBy   string
	Limit     int
	Offset    int
	// RPC is a horrible hack while we work to replace the net/rpc package
	// TODO - remove this
	RPC bool
	// Published only applies to listing datasets
	Published bool
	// ShowNumVersions only applies to listing datasets
	ShowNumVersions bool
	// EnsureFSIExists controls whether to ensure references in the repo have correct FSIPaths
	EnsureFSIExists bool
	// UseDscache controls whether to build a dscache to use to list the references
	UseDscache 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 (lp ListParams) Page() util.Page

Page converts a ListParams struct to a util.Page struct

type LogEntry added in v0.9.1

type LogEntry = logbook.LogEntry

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

type LogParams

type LogParams struct {
	ListParams
	// Reference to data to fetch history for
	Ref string
}

LogParams defines parameters for the Log method

type LogRequests added in v0.5.2

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

LogRequests encapsulates business logic for the log of changes to datasets, think "git log" TODO (b5): switch to using an Instance instead of separate fields

func NewLogRequests added in v0.5.2

func NewLogRequests(node *p2p.QriNode, cli *rpc.Client) *LogRequests

NewLogRequests creates a LogRequests pointer from either a repo or an rpc.Client

func (LogRequests) CoreRequestsName added in v0.5.2

func (r LogRequests) CoreRequestsName() string

CoreRequestsName implements the Requets interface

func (*LogRequests) Log added in v0.5.2

func (r *LogRequests) Log(params *LogParams, res *[]DatasetLogItem) (err error)

Log returns the history of changes for a given dataset

func (*LogRequests) Logbook added in v0.9.1

func (r *LogRequests) Logbook(p *RefListParams, res *[]LogEntry) error

Logbook lists log entries for actions taken on a given dataset

func (*LogRequests) PlainLogs added in v0.9.5

func (r *LogRequests) PlainLogs(p *PlainLogsParams, res *PlainLogs) (err error)

PlainLogs encodes the full logbook as human-oriented json

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

func Receivers

func Receivers(inst *Instance) []Methods

Receivers returns a slice of CoreRequests that defines the full local API of lib methods

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 OptCheckConfigMigrations added in v0.8.0

func OptCheckConfigMigrations(cfgPath string) 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 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 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(fn func(opt *remote.Options)) 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 configures the directory to read IPFS from (only if the configured store is IPFS). If the given path is the empty string, default to the standard IPFS config: * IPFS_PATH environment variable if set * if none set: "$HOME/.ipfs"

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 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 PeerConnectionParamsPod

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

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

func NewPeerConnectionParamsPod

func NewPeerConnectionParamsPod(s string) *PeerConnectionParamsPod

NewPeerConnectionParamsPod attempts to turn a string into peer connection parameters

func (PeerConnectionParamsPod) Decode

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

type PeerInfoParams

type PeerInfoParams struct {
	Peername  string
	ProfileID profile.ID
	// 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 PeerRefsParams

type PeerRefsParams struct {
	PeerID string
	Limit  int
	Offset int
}

PeerRefsParams defines params for the GetReferences method

type PeerRequests

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

PeerRequests encapsulates business logic for methods relating to peer-to-peer interaction TODO (b5): switch to using an Instance instead of separate fields

func NewPeerRequests

func NewPeerRequests(node *p2p.QriNode, cli *rpc.Client) *PeerRequests

NewPeerRequests creates a PeerRequests pointer from either a qri Node or an rpc.Client

func (*PeerRequests) ConnectToPeer

func (d *PeerRequests) ConnectToPeer(p *PeerConnectionParamsPod, res *config.ProfilePod) error

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

func (*PeerRequests) ConnectedIPFSPeers

func (d *PeerRequests) ConnectedIPFSPeers(limit *int, peers *[]string) error

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

func (*PeerRequests) ConnectedQriProfiles

func (d *PeerRequests) ConnectedQriProfiles(limit *int, peers *[]*config.ProfilePod) (err error)

ConnectedQriProfiles lists profiles we're currently connected to

func (PeerRequests) CoreRequestsName

func (d PeerRequests) CoreRequestsName() string

CoreRequestsName implements the Requets interface

func (*PeerRequests) DisconnectFromPeer

func (d *PeerRequests) DisconnectFromPeer(p *PeerConnectionParamsPod, res *bool) error

DisconnectFromPeer explicitly closes a peer connection

func (*PeerRequests) GetReferences

func (d *PeerRequests) GetReferences(p *PeerRefsParams, res *[]reporef.DatasetRef) error

GetReferences lists a peer's named datasets

func (*PeerRequests) Info

Info shows peer profile details

func (*PeerRequests) List

func (d *PeerRequests) List(p *PeerListParams, res *[]*config.ProfilePod) (err error)

List lists Peers on the qri network

type PlainLogs added in v0.9.5

type PlainLogs = []logbook.PlainLog

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

type PlainLogsParams added in v0.9.5

type PlainLogsParams struct {
}

PlainLogsParams enapsulates parameters for the PlainLogs methods

type PreviewParams added in v0.9.5

type PreviewParams struct {
	RemoteName string
	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 NewProfileMethods added in v0.8.0

func NewProfileMethods(inst *Instance) *ProfileMethods

NewProfileMethods creates a ProfileMethods pointer from either a repo or an rpc.Client

func (ProfileMethods) CoreRequestsName added in v0.8.0

func (ProfileMethods) CoreRequestsName() string

CoreRequestsName implements the Request interface

func (*ProfileMethods) GetProfile added in v0.8.0

func (m *ProfileMethods) GetProfile(in *bool, res *config.ProfilePod) (err error)

GetProfile get's this node's peer profile

func (*ProfileMethods) PosterPhoto added in v0.8.0

func (m *ProfileMethods) PosterPhoto(req *config.ProfilePod, res *[]byte) (err error)

PosterPhoto fetches the byte slice of a given user's poster photo

func (*ProfileMethods) ProfilePhoto added in v0.8.0

func (m *ProfileMethods) ProfilePhoto(req *config.ProfilePod, res *[]byte) (err error)

ProfilePhoto fetches the byte slice of a given user's profile photo

func (*ProfileMethods) SaveProfile added in v0.8.0

func (m *ProfileMethods) SaveProfile(p *config.ProfilePod, res *config.ProfilePod) error

SaveProfile stores changes to this peer's editable profile

func (*ProfileMethods) SetPosterPhoto added in v0.8.0

func (m *ProfileMethods) SetPosterPhoto(p *FileParams, res *config.ProfilePod) error

SetPosterPhoto changes this peer's poster image

func (*ProfileMethods) SetProfilePhoto added in v0.8.0

func (m *ProfileMethods) SetProfilePhoto(p *FileParams, res *config.ProfilePod) error

SetProfilePhoto changes this peer's profile image

type PublicationParams added in v0.9.0

type PublicationParams struct {
	Ref        string
	RemoteName string
	// All indicates all versions of a dataset and the dataset namespace should
	// be either published or removed
	All bool
}

PublicationParams encapsulates parmeters for dataset publication

type PushParams added in v0.7.3

type PushParams struct {
	Ref           string
	RemoteName    string
	PinOnComplete bool
}

PushParams holds parameters for pushing daginfo to remotes

type ReceiveParams added in v0.7.3

type ReceiveParams struct {
	Peername  string
	Name      string
	ProfileID profile.ID
	DagInfo   *dag.Info
}

ReceiveParams hold parameters for receiving daginfo's when running as a remote

type ReceiveResult added in v0.7.3

type ReceiveResult struct {
	Success      bool
	RejectReason string
	SessionID    string
	Diff         *dag.Manifest
}

ReceiveResult is the result of receiving a posted dataset when running as a remote

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 NewRegistryClientMethods added in v0.9.0

func NewRegistryClientMethods(inst *Instance) *RegistryClientMethods

NewRegistryClientMethods creates client methods from an instance

func (RegistryClientMethods) CoreRequestsName added in v0.9.0

func (RegistryClientMethods) CoreRequestsName() string

CoreRequestsName implements the Requests interface

func (RegistryClientMethods) CreateProfile added in v0.9.0

func (m RegistryClientMethods) CreateProfile(p *RegistryProfile, ok *bool) (err error)

CreateProfile creates a profile

func (RegistryClientMethods) ProveProfileKey added in v0.9.0

func (m RegistryClientMethods) ProveProfileKey(p *RegistryProfile, ok *bool) error

ProveProfileKey asserts to a registry that this user has control of a specified private key

type RegistryProfile added in v0.9.0

type RegistryProfile = registry.Profile

RegistryProfile is a user profile as stored on a registry

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 NewRemoteMethods added in v0.9.0

func NewRemoteMethods(inst *Instance) *RemoteMethods

NewRemoteMethods creates a RemoteMethods pointer from either a node or an rpc.Client

func (*RemoteMethods) CoreRequestsName added in v0.9.0

func (*RemoteMethods) CoreRequestsName() string

CoreRequestsName implements the Requests interface

func (*RemoteMethods) Feeds added in v0.9.5

func (r *RemoteMethods) Feeds(remoteName *string, res *map[string][]dsref.VersionInfo) error

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) Fetch added in v0.9.1

func (r *RemoteMethods) Fetch(p *FetchParams, res *[]DatasetLogItem) error

Fetch pulls a logbook from a remote

func (*RemoteMethods) Preview added in v0.9.5

func (r *RemoteMethods) Preview(p *PreviewParams, res *dataset.Dataset) error

Preview requests a dataset preview from a remote

func (*RemoteMethods) Publish added in v0.9.0

func (r *RemoteMethods) Publish(p *PublicationParams, res *dsref.Ref) error

Publish posts a dataset version to a remote

func (*RemoteMethods) PullDataset added in v0.9.0

func (r *RemoteMethods) PullDataset(p *PublicationParams, res *bool) error

PullDataset fetches a dataset ref from a remote

func (*RemoteMethods) Unpublish added in v0.9.0

func (r *RemoteMethods) Unpublish(p *PublicationParams, res *dsref.Ref) error

Unpublish 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

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 dsref.Ref
}

RenameParams defines parameters for Dataset renaming

type RenderParams

type RenderParams struct {
	// Ref is a string reference to the dataset to render
	Ref string
	// 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"
	OutFormat string
}

RenderParams defines parameters for the Render method

func (*RenderParams) Validate added in v0.9.5

func (p *RenderParams) Validate() error

Validate checks if render parameters are valid

type RenderRequests

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

RenderRequests encapsulates business logic for this node's user profile TODO (b5): switch to using an Instance instead of separate fields

func NewRenderRequests

func NewRenderRequests(r repo.Repo, cli *rpc.Client) *RenderRequests

NewRenderRequests creates a RenderRequests pointer from either a repo or an rpc.Client

func (RenderRequests) CoreRequestsName

func (RenderRequests) CoreRequestsName() string

CoreRequestsName implements the Requets interface

func (*RenderRequests) RenderReadme added in v0.9.1

func (r *RenderRequests) RenderReadme(p *RenderParams, res *string) (err error)

RenderReadme renders the readme into html for the given dataset

func (*RenderRequests) RenderViz added in v0.9.1

func (r *RenderRequests) RenderViz(p *RenderParams, res *[]byte) (err error)

RenderViz renders a viz component as html

type RestoreParams added in v0.9.0

type RestoreParams struct {
	Dir       string
	Ref       string
	Component string
}

RestoreParams provides parameters to the restore method.

type SQLMethods added in v0.9.7

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

SQLMethods encapsulates business logic for the qri search command TODO (b5): switch to using an Instance instead of separate fields

func NewSQLMethods added in v0.9.7

func NewSQLMethods(inst *Instance) *SQLMethods

NewSQLMethods creates SQLMethods from a qri Instance

func (SQLMethods) CoreRequestsName added in v0.9.7

func (m SQLMethods) CoreRequestsName() string

CoreRequestsName implements the requests interface

func (*SQLMethods) Exec added in v0.9.7

func (m *SQLMethods) Exec(p *SQLQueryParams, results *[]byte) error

Exec runs an SQL query

type SQLQueryParams added in v0.9.7

type SQLQueryParams struct {
	Query        string
	OutputFormat string
}

SQLQueryParams defines paremeters for the exec Method ExecParams provides parameters to the execute command

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
	// absolute path or URL to the list of dataset files or components to load
	FilePaths []string
	// 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

	// 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, set saved dataset to published
	Publish bool
	// run without saving, returning results
	DryRun bool
	// if true, res.Dataset.Body will be a fs.file of the body
	ReturnBody bool
	// if true, convert body to the format of the previous version, if applicable
	ConvertFormatToPrev bool
	// string of references to recall before saving
	Recall 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
	// whether to create a new dscache if none exists
	UseDscache bool
}

SaveParams encapsulates arguments to Save

func (*SaveParams) AbsolutizePaths added in v0.8.0

func (p *SaveParams) AbsolutizePaths() error

AbsolutizePaths converts any relative path references to their absolute variations, safe to call on a nil instance

type ScheduleParams added in v0.8.0

type ScheduleParams struct {
	Name        string
	Periodicity string
	RepoPath    string

	// SaveParams only applies to dataset saves
	SaveParams *SaveParams
}

ScheduleParams encapsulates parameters for scheduling updates

type SearchMethods added in v0.9.0

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

SearchMethods encapsulates business logic for the qri search command TODO (b5): switch to using an Instance instead of separate fields

func NewSearchMethods added in v0.9.0

func NewSearchMethods(inst *Instance) *SearchMethods

NewSearchMethods creates SearchMethods from a qri Instance

func (SearchMethods) CoreRequestsName added in v0.9.0

func (m SearchMethods) CoreRequestsName() string

CoreRequestsName implements the requests

func (*SearchMethods) Search added in v0.9.0

func (m *SearchMethods) Search(p *SearchParams, results *[]SearchResult) error

Search queries for items on qri related to given parameters

type SearchParams

type SearchParams struct {
	QueryString 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 ServiceStatus added in v0.8.0

type ServiceStatus struct {
	Name       string
	Running    bool
	Daemonized bool // if true this service is scheduled
	Started    *time.Time
	Address    string
	Metrics    map[string]interface{}
}

ServiceStatus describes the current state of a service

type SetPublishStatusParams added in v0.6.1

type SetPublishStatusParams struct {
	Ref           string
	PublishStatus bool
}

SetPublishStatusParams encapsulates parameters for setting the publication status of a dataset

type SetupParams

type SetupParams struct {
	Config              *config.Config
	QriRepoPath         string
	ConfigFilepath      string
	SetupIPFS           bool
	Register            bool
	IPFSFsPath          string
	SetupIPFSConfigData []byte
	Generator           gen.CryptoGenerator
}

SetupParams encapsulates arguments for Setup

type StatsParams added in v0.9.2

type StatsParams struct {
	// string representation of a dataset reference
	Ref string
	// if we get a Dataset from the params, then we do not have to
	// attempt to open a dataset from the reference
	Dataset *dataset.Dataset
}

StatsParams defines the params for a Stats request

type StatsResponse added in v0.9.2

type StatsResponse struct {
	StatsBytes []byte
}

StatsResponse defines the response for a Stats request

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
	QriRepoPath    string
	ConfigFilepath string
}

TeardownParams encapsulates arguments for Setup

type UpdateMethods added in v0.8.0

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

UpdateMethods enapsulates logic for scheduled updates

func NewUpdateMethods added in v0.8.0

func NewUpdateMethods(inst *Instance) *UpdateMethods

NewUpdateMethods creates a configuration handle from an instance

func (*UpdateMethods) CoreRequestsName added in v0.8.0

func (m *UpdateMethods) CoreRequestsName() string

CoreRequestsName specifies this is a Methods object

func (*UpdateMethods) Job added in v0.8.0

func (m *UpdateMethods) Job(name *string, job *Job) (err error)

Job gets a job by name

func (*UpdateMethods) List added in v0.8.0

func (m *UpdateMethods) List(p *ListParams, jobs *[]*Job) error

List gets scheduled jobs

func (*UpdateMethods) LogFile added in v0.8.0

func (m *UpdateMethods) LogFile(logName *string, data *[]byte) error

LogFile reads log file data for a given logName

func (*UpdateMethods) Logs added in v0.8.0

func (m *UpdateMethods) Logs(p *ListParams, res *[]*Job) error

Logs shows the history of job execution

func (*UpdateMethods) Run added in v0.8.0

func (m *UpdateMethods) Run(p *Job, res *reporef.DatasetRef) (err error)

Run advances a dataset to the latest known version from either a peer or by re-running a transform in the peer's namespace

func (*UpdateMethods) Schedule added in v0.8.0

func (m *UpdateMethods) Schedule(in *ScheduleParams, out *cron.Job) (err error)

Schedule creates a job and adds it to the scheduler

func (*UpdateMethods) ServiceRestart added in v0.8.0

func (m *UpdateMethods) ServiceRestart(in, out *bool) error

ServiceRestart uses shell commands to restart the scheduler service

func (*UpdateMethods) ServiceStart added in v0.8.0

func (m *UpdateMethods) ServiceStart(p *UpdateServiceStartParams, started *bool) error

ServiceStart ensures the scheduler is running

func (*UpdateMethods) ServiceStatus added in v0.8.0

func (m *UpdateMethods) ServiceStatus(in *bool, out *ServiceStatus) error

ServiceStatus reports status of the update daemon

func (*UpdateMethods) ServiceStop added in v0.8.0

func (m *UpdateMethods) ServiceStop(in, out *bool) error

ServiceStop halts the scheduler

func (*UpdateMethods) Unschedule added in v0.8.0

func (m *UpdateMethods) Unschedule(name *string, unscheduled *bool) error

Unschedule removes a job from the scheduler by name

type UpdateServiceStartParams added in v0.8.0

type UpdateServiceStartParams struct {
	Ctx       context.Context
	Daemonize bool

	// TODO (b5): I'm really not a fan of passing these configuration-derived
	// bits as parameters. Ideally this would come from the underlying instance
	// these are needed because lib.NewInstance creates a cron client
	// that intereferes with the start service process. We're currently getting
	// around this by avoiding calls to lib.NewInstance, or passing in resulting
	// params when called. We should clean this up.
	RepoPath  string
	UpdateCfg *config.Update
}

UpdateServiceStartParams configures startup

type ValidateDatasetParams

type ValidateDatasetParams struct {
	Ref string
	// URL          string
	BodyFilename      string
	SchemaFilename    string
	StructureFilename string
}

ValidateDatasetParams defines parameters for dataset data validation

Jump to

Keyboard shortcuts

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