// If true, sets the X-External-Client header to indicate
// the client is outside the cluster.
External bool
+
+ // Discovery document
+ DiscoveryDoc Dict
}
// Create a new ArvadosClient, initialized with standard Arvados environment
Scheme: "https",
Host: this.ApiServer}
- u.Path = "/arvados/v1"
+ if resource != API_DISCOVERY_RESOURCE {
+ u.Path = "/arvados/v1"
+ }
if resource != "" {
u.Path = u.Path + "/" + resource
func (this ArvadosClient) List(resource string, parameters Dict, output interface{}) (err error) {
return this.Call("GET", resource, "", "", parameters, output)
}
+
+// API Discovery
+//
+// parameter - name of parameter to be discovered
+// return
+// valueMap - Dict key value pair of the discovered parameter
+// err - error accessing the resource, or nil if no error
+var API_DISCOVERY_RESOURCE string = "discovery/v1/apis/arvados/v1/rest"
+
+func (this *ArvadosClient) Discovery(parameter string) (valueMap Dict, err error) {
+ if len(this.DiscoveryDoc) == 0 {
+ this.DiscoveryDoc = make(Dict)
+ err = this.Call("GET", API_DISCOVERY_RESOURCE, "", "", nil, &this.DiscoveryDoc)
+ }
+
+ valueMap = make(Dict)
+ valueMap[parameter] = this.DiscoveryDoc[parameter]
+
+ return valueMap, err
+}
c.Assert(err.(APIServerError).HttpStatusCode, Equals, 404)
}
}
+
+func (s *ServerRequiredSuite) TestAPIDiscovery_Get_defaultCollectionReplication(c *C) {
+ arv, err := MakeArvadosClient()
+ valueMap, err := arv.Discovery("defaultCollectionReplication")
+ c.Assert(err, IsNil)
+ c.Assert(valueMap["defaultCollectionReplication"], NotNil)
+}
+
+func (s *ServerRequiredSuite) TestAPIDiscovery_Get_noSuchParameter(c *C) {
+ arv, err := MakeArvadosClient()
+ valueMap, err := arv.Discovery("noSuchParameter")
+ c.Assert(err, IsNil)
+ c.Assert(valueMap["noSuchParameter"], IsNil)
+}