[ARVADOS] updated: 906022feeb3347b95962eddd2e9d0ca10d92742a
git at public.curoverse.com
git at public.curoverse.com
Tue Jun 10 09:00:56 EDT 2014
Summary of changes:
sdk/go/src/arvados.org/sdk/sdk.go | 60 +++++++++++++++++++++++++++++++++++++--
1 file changed, 57 insertions(+), 3 deletions(-)
via 906022feeb3347b95962eddd2e9d0ca10d92742a (commit)
from ebb46af486978010c55bf124e7b1d78589a433e7 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 906022feeb3347b95962eddd2e9d0ca10d92742a
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Tue Jun 10 09:00:51 2014 -0400
2826: Added documentation comments.
diff --git a/sdk/go/src/arvados.org/sdk/sdk.go b/sdk/go/src/arvados.org/sdk/sdk.go
index 8a66645..1931826 100644
--- a/sdk/go/src/arvados.org/sdk/sdk.go
+++ b/sdk/go/src/arvados.org/sdk/sdk.go
@@ -1,3 +1,5 @@
+/* Simple Arvados Go SDK for communicating with API server. */
+
package sdk
import (
@@ -12,6 +14,7 @@ import (
"os"
)
+// Errors
var MissingArvadosApiHost = errors.New("Missing required environment variable ARVADOS_API_HOST")
var MissingArvadosApiToken = errors.New("Missing required environment variable ARVADOS_API_TOKEN")
var ArvadosErrorForbidden = errors.New("Forbidden")
@@ -19,9 +22,10 @@ var ArvadosErrorNotFound = errors.New("Not found")
var ArvadosErrorBadRequest = errors.New("Bad request")
var ArvadosErrorServerError = errors.New("Server error")
+// Helper type so we don't have to write out 'map[string]interface{}' every time.
type Dict map[string]interface{}
-// Information about Arvados and Keep servers.
+// Information about how to contact the Arvados server
type ArvadosClient struct {
ApiServer string
ApiToken string
@@ -32,8 +36,7 @@ type ArvadosClient struct {
// Create a new KeepClient, initialized with standard Arvados environment
// variables ARVADOS_API_HOST, ARVADOS_API_TOKEN, and (optionally)
-// ARVADOS_API_HOST_INSECURE. This will contact the API server to discover
-// Keep servers.
+// ARVADOS_API_HOST_INSECURE.
func MakeArvadosClient() (kc ArvadosClient, err error) {
insecure := (os.Getenv("ARVADOS_API_HOST_INSECURE") == "true")
external := (os.Getenv("ARVADOS_EXTERNAL_CLIENT") == "true")
@@ -56,6 +59,17 @@ func MakeArvadosClient() (kc ArvadosClient, err error) {
return kc, err
}
+// Low-level access to a resource.
+//
+// method - HTTP method, one of GET, HEAD, PUT, POST or DELETE
+// resource - the arvados resource to act on
+// uuid - the uuid of the specific item to access (may be empty)
+// action - sub-action to take on the resource or uuid (may be empty)
+// parameters - method parameters
+//
+// return
+// reader - the body reader, or nil if there was an error
+// err - error accessing the resource, or nil if no error
func (this *ArvadosClient) CallRaw(method string, resource string, uuid string, action string, parameters Dict) (reader io.ReadCloser, err error) {
var req *http.Request
@@ -132,6 +146,16 @@ func (this *ArvadosClient) CallRaw(method string, resource string, uuid string,
}
}
+// Access to a resource.
+//
+// method - HTTP method, one of GET, HEAD, PUT, POST or DELETE
+// resource - the arvados resource to act on
+// uuid - the uuid of the specific item to access (may be empty)
+// action - sub-action to take on the resource or uuid (may be empty)
+// parameters - method parameters
+// output - a map or annotated struct which is a legal target for encoding/json/Decoder
+// return
+// err - error accessing the resource, or nil if no error
func (this *ArvadosClient) Call(method string, resource string, uuid string, action string, parameters Dict, output interface{}) (err error) {
var reader io.ReadCloser
reader, err = this.CallRaw(method, resource, uuid, action, parameters)
@@ -151,18 +175,48 @@ func (this *ArvadosClient) Call(method string, resource string, uuid string, act
return nil
}
+// Create a new instance of a resource.
+//
+// resource - the arvados resource on which to create an item
+// parameters - method parameters
+// output - a map or annotated struct which is a legal target for encoding/json/Decoder
+// return
+// err - error accessing the resource, or nil if no error
func (this *ArvadosClient) Create(resource string, parameters Dict, output interface{}) (err error) {
return this.Call("POST", resource, "", "", parameters, output)
}
+// Delete an instance of a resource.
+//
+// resource - the arvados resource on which to delete an item
+// uuid - the item to delete
+// parameters - method parameters
+// output - a map or annotated struct which is a legal target for encoding/json/Decoder
+// return
+// err - error accessing the resource, or nil if no error
func (this *ArvadosClient) Delete(resource string, uuid string, parameters Dict, output interface{}) (err error) {
return this.Call("DELETE", resource, uuid, "", parameters, output)
}
+// Update fields of an instance of a resource.
+//
+// resource - the arvados resource on which to update the item
+// uuid - the item to update
+// parameters - method parameters
+// output - a map or annotated struct which is a legal target for encoding/json/Decoder
+// return
+// err - error accessing the resource, or nil if no error
func (this *ArvadosClient) Update(resource string, uuid string, parameters Dict, output interface{}) (err error) {
return this.Call("PUT", resource, uuid, "", parameters, output)
}
+// List the instances of a resource
+//
+// resource - the arvados resource on which to list
+// parameters - method parameters
+// output - a map or annotated struct which is a legal target for encoding/json/Decoder
+// return
+// err - error accessing the resource, or nil if no error
func (this *ArvadosClient) List(resource string, parameters Dict, output interface{}) (err error) {
return this.Call("GET", resource, "", "", parameters, output)
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list