5824: Add Get() method to arvadosclient.
authorTom Clegg <tom@curoverse.com>
Thu, 23 Jul 2015 04:01:52 +0000 (00:01 -0400)
committerTom Clegg <tom@curoverse.com>
Tue, 11 Aug 2015 00:26:41 +0000 (20:26 -0400)
sdk/go/arvadosclient/arvadosclient.go
sdk/go/arvadosclient/arvadosclient_test.go

index 99b08186a533f101a88f0ca3910cc1fcbe06ab3d..c262be1ca7fac58ebf5295389e37902cddbd9884 100644 (file)
@@ -270,6 +270,21 @@ func (this ArvadosClient) Update(resource string, uuid string, parameters Dict,
        return this.Call("PUT", resource, uuid, "", parameters, output)
 }
 
+// Get a resource.
+func (c ArvadosClient) Get(resource string, uuid string, parameters Dict, output interface{}) (err error) {
+       if uuid == "" {
+               // There's no endpoint for that because GET /type/ is
+               // the List API. If there were an endpoint, the
+               // response would be 404: no object has uuid == "".
+               return APIServerError{
+                       ServerAddress:     c.ApiServer,
+                       HttpStatusCode:    404,
+                       HttpStatusMessage: "Not Found",
+               }
+       }
+       return c.Call("GET", resource, uuid, "", parameters, output)
+}
+
 // List the instances of a resource
 //
 //   resource - the arvados resource on which to list
index 6a9e13bb27a9d39e8af98e4cc5a22fbd01b29f97..c2cf83ef3fe87e4dbfccb172b895c50d3ba97b9e 100644 (file)
@@ -62,6 +62,13 @@ func (s *ServerRequiredSuite) TestCreatePipelineTemplate(c *C) {
        c.Assert(getback["components"].(map[string]interface{})["c2"].(map[string]interface{})["script"], Equals, "script2")
 
        uuid := getback["uuid"].(string)
+
+       getback = make(Dict)
+       err = arv.Get("pipeline_templates", uuid, nil, &getback)
+       c.Assert(err, Equals, nil)
+       c.Assert(getback["name"], Equals, "tmp")
+       c.Assert(getback["components"].(map[string]interface{})["c1"].(map[string]interface{})["script"], Equals, "script1")
+
        getback = make(Dict)
        err = arv.Update("pipeline_templates", uuid,
                Dict{