regclient

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: 9 Imported by: 0

Documentation

Overview

Package regclient defines a client for interacting with a registry server

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoRegistry indicates that no registry has been specified
	// all client methods MUST return ErrNoRegistry for all method calls
	// when config.Registry.Location is an empty string
	ErrNoRegistry = errors.New("registry: no registry specified")
	// ErrNoConnection indicates no path to the registry can be found
	ErrNoConnection = errors.New("registry: no connection")
	// ErrNotRegistered indicates this client is not registered
	ErrNotRegistered = errors.New("registry: not registered")

	// HTTPClient is hoisted here in case you'd like to use a different client instance
	// by default we just use http.DefaultClient
	HTTPClient = http.DefaultClient
)

Functions

This section is empty.

Types

type Client

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

Client wraps a registry configuration with methods for interacting with the configured registry

func NewClient

func NewClient(cfg *Config) *Client

NewClient creates a registry from a provided Registry configuration

func (*Client) CreateProfile

func (c *Client) CreateProfile(p *registry.Profile, pk crypto.PrivKey) (*registry.Profile, error)

CreateProfile creates a user profile, associating a public key in the process

func (*Client) DeleteProfile

func (c *Client) DeleteProfile(p *registry.Profile, privKey crypto.PrivKey) error

DeleteProfile removes a profile from the registry

func (Client) GetProfile

func (c Client) GetProfile(p *registry.Profile) error

GetProfile fills in missing fields in p with registry data

func (*Client) ProveKeyForProfile added in v0.10.0

func (c *Client) ProveKeyForProfile(p *registry.Profile) (map[string]string, error)

ProveKeyForProfile proves to the registry that the user owns the profile and is associating a new keypair

func (*Client) PutProfile

func (c *Client) PutProfile(p *registry.Profile, privKey crypto.PrivKey) (*registry.Profile, error)

PutProfile adds a profile to the registry

func (Client) Search

func (c Client) Search(p *SearchParams) ([]*dataset.Dataset, error)

Search makes a registry search request

func (*Client) UpdateProfile added in v0.10.0

func (c *Client) UpdateProfile(p *registry.Profile, pk crypto.PrivKey) (*registry.Profile, error)

UpdateProfile updates some information about the profile in the registry

type Config

type Config struct {
	// Location is the URL base to call to
	Location string
}

Config encapsulates options for working with a registry

type RegistryResponse added in v0.10.0

type RegistryResponse struct {
	Data map[string]string
	Meta struct {
		Error  string
		Status string
		Code   int
	}
}

RegistryResponse is a generic container for registry requests TODO(dustmop): Only used currently for ProveKey TODO(arqu): update with common API response object

type SearchFilter

type SearchFilter struct {
	// Type denotes the ype of search filter
	Type string
	// Relation indicates the relation between the key and value
	// supported options include ["eq"|"neq"|"gt"|"gte"|"lt"|"lte"]
	Relation string
	// Key corresponds to the name of the index mapping that we wish to
	// apply the filter to
	Key string
	// Value is the predicate of the subject-relation-predicate triple
	// eg. [key=timestamp] [gte] [value=[today]]
	Value interface{}
}

SearchFilter stores various types of filters that may be applied to a search

type SearchParams

type SearchParams struct {
	Query   string
	Filters []SearchFilter
	Limit   int
	Offset  int
}

SearchParams contains the parameters that are passed to a Client.Search method

Jump to

Keyboard shortcuts

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