Documentation ¶
Index ¶
- Constants
- Variables
- func MakeTLSConfig(insecure bool) *tls.Config
- func StringBool(s string) bool
- type APIServerError
- type ArvadosClient
- func (c *ArvadosClient) Call(method, resourceType, uuid, action string, parameters Dict, output interface{}) error
- func (c *ArvadosClient) CallRaw(method string, resourceType string, uuid string, action string, ...) (reader io.ReadCloser, err error)
- func (c *ArvadosClient) Create(resourceType string, parameters Dict, output interface{}) error
- func (c *ArvadosClient) Delete(resource string, uuid string, parameters Dict, output interface{}) (err error)
- func (c *ArvadosClient) Discovery(parameter string) (value interface{}, err error)
- func (c *ArvadosClient) Get(resourceType string, uuid string, parameters Dict, output interface{}) (err error)
- func (c *ArvadosClient) List(resource string, parameters Dict, output interface{}) (err error)
- func (c *ArvadosClient) Update(resourceType string, uuid string, parameters Dict, output interface{}) (err error)
- type ClientPool
- type Dict
- type StringMatcher
Constants ¶
const ApiDiscoveryResource = "discovery/v1/apis/arvados/v1/rest"
Variables ¶
var CertFiles = []string{
"/etc/arvados/ca-certificates.crt",
"/etc/ssl/certs/ca-certificates.crt",
"/etc/pki/tls/certs/ca-bundle.crt",
}
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.
var MissingArvadosApiHost = errors.New("Missing required environment variable ARVADOS_API_HOST")
Functions ¶
func MakeTLSConfig ¶
MakeTLSConfig sets up TLS configuration for communicating with Arvados and Keep services.
Types ¶
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 // If true, sets the X-External-Client header to indicate // the client is outside the cluster. External bool // 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() (ac *ArvadosClient, err error)
MakeArvadosClient creates a new ArvadosClient using the standard environment variables ARVADOS_API_HOST, ARVADOS_API_TOKEN, ARVADOS_API_HOST_INSECURE, ARVADOS_EXTERNAL_CLIENT, 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) 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.
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 ¶
var PDHMatch StringMatcher = regexp.MustCompile(`^[0-9a-f]{32}\+\d+$`).MatchString
var UUIDMatch StringMatcher = regexp.MustCompile(`^[a-z0-9]{5}-[a-z0-9]{5}-[a-z0-9]{15}$`).MatchString