closes #5179
[arvados.git] / sdk / go / arvadosclient / arvadosclient.go
index f606a68d6d4f88d15bcc16d8ab66072718ec991e..4c16398397fa8881ffe8060f45b2e910007d506e 100644 (file)
@@ -12,6 +12,7 @@ import (
        "net/http"
        "net/url"
        "os"
+       "regexp"
        "strings"
 )
 
@@ -22,7 +23,7 @@ var MissingArvadosApiToken = errors.New("Missing required environment variable A
 type ArvadosApiError struct {
        error
        HttpStatusCode int
-       HttpStatus     string
+       HttpStatus string
 }
 
 func (e ArvadosApiError) Error() string { return e.error.Error() }
@@ -53,8 +54,9 @@ type ArvadosClient struct {
 // variables ARVADOS_API_HOST, ARVADOS_API_TOKEN, and (optionally)
 // 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")
+       var matchTrue = regexp.MustCompile("^(?i:1|yes|true)$")
+       insecure := matchTrue.MatchString(os.Getenv("ARVADOS_API_HOST_INSECURE"))
+       external := matchTrue.MatchString(os.Getenv("ARVADOS_EXTERNAL_CLIENT"))
 
        kc = ArvadosClient{
                ApiServer:   os.Getenv("ARVADOS_API_HOST"),
@@ -92,9 +94,7 @@ func (this ArvadosClient) CallRaw(method string, resource string, uuid string, a
                Scheme: "https",
                Host:   this.ApiServer}
 
-       if resource != API_DISCOVERY_RESOURCE {
-               u.Path = "/arvados/v1"
-       }
+       u.Path = "/arvados/v1"
 
        if resource != "" {
                u.Path = u.Path + "/" + resource
@@ -249,25 +249,3 @@ func (this ArvadosClient) Update(resource string, uuid string, parameters Dict,
 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"
-
-var DISCOVERY Dict
-
-func (this ArvadosClient) Discovery(parameter string) (valueMap Dict, err error) {
-       if len(DISCOVERY) == 0 {
-               DISCOVERY = make(Dict)
-               this.Call("GET", API_DISCOVERY_RESOURCE, "", "", nil, &DISCOVERY)
-       }
-
-       valueMap = make(Dict)
-       valueMap[parameter] = DISCOVERY[parameter]
-
-       return valueMap, err
-}