Version: v0.0.0-...-2b7d05c Latest Latest

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

Go to latest
Published: Nov 21, 2022 License: AGPL-3.0, Apache-2.0, CC-BY-SA-3.0 Imports: 16 Imported by: 1




View Source
const ApiDiscoveryResource = "discovery/v1/apis/arvados/v1/rest"


View Source
var CertFiles = []string{
View Source
var ErrInvalidArgument = errors.New("Invalid argument")
View Source
var MaxIdleConnectionDuration = 30 * time.Second

A common failure mode is to reuse a keepalive connection that has been terminated (in a way that we can't detect) for being idle too long. POST and DELETE are not safe to retry automatically, so we minimize such failures by always using a new or recently active socket.

View Source
var MissingArvadosApiHost = errors.New("Missing required environment variable ARVADOS_API_HOST")
View Source
var MissingArvadosApiToken = errors.New("Missing required environment variable ARVADOS_API_TOKEN")
View Source
var RetryDelay = 2 * time.Second


func MakeTLSConfig

func MakeTLSConfig(insecure bool) *tls.Config

MakeTLSConfig sets up TLS configuration for communicating with Arvados and Keep services.

func StringBool

func StringBool(s string) bool

StringBool tests whether s is suggestive of true. It returns true if s is a mixed/uppoer/lower-case variant of "1", "yes", or "true".


type APIServerError

type APIServerError struct {
	// Address of server returning error, of the form "host:port".
	ServerAddress string

	// Components of server response.
	HttpStatusCode    int
	HttpStatusMessage string

	// Additional error details from response body.
	ErrorDetails []string

APIServerError contains an error that was returned by the API server.

func (APIServerError) Error

func (e APIServerError) Error() string

type ArvadosClient

type ArvadosClient struct {
	// https
	Scheme string

	// Arvados API server, form "host:port"
	ApiServer string

	// Arvados API token for authentication
	ApiToken string

	// Whether to require a valid SSL certificate or not
	ApiInsecure bool

	// Client object shared by client requests.  Supports HTTP KeepAlive.
	Client *http.Client

	// Base URIs of Keep services, e.g., {"https://host1:8443",
	// "https://host2:8443"}.  If this is nil, Keep clients will
	// use the arvados.v1.keep_services.accessible API to discover
	// available services.
	KeepServiceURIs []string

	// Discovery document
	DiscoveryDoc Dict

	// Number of retries
	Retries int

	// X-Request-Id for outgoing requests
	RequestID string
	// contains filtered or unexported fields

ArvadosClient contains information about how to contact the Arvados server

func MakeArvadosClient

func MakeArvadosClient() (*ArvadosClient, error)

MakeArvadosClient creates a new ArvadosClient using the standard environment variables ARVADOS_API_HOST, ARVADOS_API_TOKEN, ARVADOS_API_HOST_INSECURE, and ARVADOS_KEEP_SERVICES.

func New

func New(c *arvados.Client) (*ArvadosClient, error)

New returns an ArvadosClient using the given arvados.Client configuration. This is useful for callers who load arvados.Client fields from configuration files but still need to use the arvadosclient.ArvadosClient package.

func (*ArvadosClient) Call

func (c *ArvadosClient) Call(method, resourceType, uuid, action string, parameters Dict, output interface{}) error

Call an API endpoint and parse the JSON response into an object.

method - HTTP method: GET, HEAD, PUT, POST, PATCH or DELETE.
resourceType - the type of arvados resource to act on (e.g., "collections", "pipeline_instances").
uuid - the uuid of the specific item to access. May be empty.
action - API method name (e.g., "lock"). This is often empty if implied by method and uuid.
parameters - method parameters.
output - a map or annotated struct which is a legal target for encoding/json/Decoder.

Returns a non-nil error if an error occurs making the API call, the API responds with a non-successful HTTP status, or an error occurs parsing the response body.

func (*ArvadosClient) CallRaw

func (c *ArvadosClient) CallRaw(method string, resourceType string, uuid string, action string, parameters Dict) (reader io.ReadCloser, err error)

CallRaw is the same as Call() but returns a Reader that reads the response body, instead of taking an output object.

func (*ArvadosClient) ClusterConfig

func (c *ArvadosClient) ClusterConfig(key string) (config interface{}, err error)

ClusterConfig returns the value of the given key in the current cluster's exported config. If key is an empty string, it'll return the entire config.

func (*ArvadosClient) Create

func (c *ArvadosClient) Create(resourceType string, parameters Dict, output interface{}) error

Create a new resource. See Call for argument descriptions.

func (*ArvadosClient) Delete

func (c *ArvadosClient) Delete(resource string, uuid string, parameters Dict, output interface{}) (err error)

Delete a resource. See Call for argument descriptions.

func (*ArvadosClient) Discovery

func (c *ArvadosClient) Discovery(parameter string) (value interface{}, err error)

Discovery returns the value of the given parameter in the discovery document. Returns a non-nil error if the discovery document cannot be retrieved/decoded. Returns ErrInvalidArgument if the requested parameter is not found in the discovery document.

func (*ArvadosClient) Get

func (c *ArvadosClient) Get(resourceType string, uuid string, parameters Dict, output interface{}) (err error)

Get a resource. See Call for argument descriptions.

func (*ArvadosClient) List

func (c *ArvadosClient) List(resource string, parameters Dict, output interface{}) (err error)

List resources of a given type. See Call for argument descriptions.

func (*ArvadosClient) Update

func (c *ArvadosClient) Update(resourceType string, uuid string, parameters Dict, output interface{}) (err error)

Update attributes of a resource. See Call for argument descriptions.

type ClientPool

type ClientPool struct {
	// Initialize new clients by copying this one.
	Prototype *ArvadosClient
	// contains filtered or unexported fields

A ClientPool is a pool of ArvadosClients. This is useful for applications that make API calls using a dynamic set of tokens, like web services that pass through their own clients' credentials. See arvados-git-httpd for an example, and sync.Pool for more information about garbage collection.

func MakeClientPool

func MakeClientPool() *ClientPool

MakeClientPool returns a new empty ClientPool, using environment variables to initialize the prototype.

func MakeClientPoolWith

func MakeClientPoolWith(client *arvados.Client) *ClientPool

MakeClientPoolWith returns a new empty ClientPool with a previously initialized arvados.Client.

func (*ClientPool) Err

func (p *ClientPool) Err() error

Err returns the error that was encountered last time Get returned nil.

func (*ClientPool) Get

func (p *ClientPool) Get() *ArvadosClient

Get returns an ArvadosClient taken from the pool, or a new one if the pool is empty. If an existing client is returned, its state (including its ApiToken) will be just as it was when it was Put back in the pool.

func (*ClientPool) Put

func (p *ClientPool) Put(c *ArvadosClient)

Put puts an ArvadosClient back in the pool.

type Dict

type Dict map[string]interface{}

Dict is a helper type so we don't have to write out 'map[string]interface{}' every time.

type StringMatcher

type StringMatcher func(string) bool
var PDHMatch StringMatcher = arvados.PDHMatch
var UUIDMatch StringMatcher = arvados.UUIDMatch

Jump to

Keyboard shortcuts

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