regclient

package
v0.9.0-alpha Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2019 License: GPL-3.0 Imports: 8 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) GetReputation

func (c Client) GetReputation(id string) (*registry.ReputationResponse, error)

GetReputation gets the reputation of a profile using the ProfileID

func (*Client) ProveProfileKey

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

ProveProfileKey associates a public key with a profile by proving this user can sign messages with the private key

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) ([]*registry.Result, error)

Search makes a registry search request

type Config

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

Config encapsulates options for working with a registry

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 {
	QueryString 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