X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/fed6d3b24a6c49df01601dfdc27182fd0770b013..da705110826943b04151f959e059b5f4ffcc4c5e:/sdk/go/arvadosclient/arvadosclient.go diff --git a/sdk/go/arvadosclient/arvadosclient.go b/sdk/go/arvadosclient/arvadosclient.go index f606a68d6d..4c16398397 100644 --- a/sdk/go/arvadosclient/arvadosclient.go +++ b/sdk/go/arvadosclient/arvadosclient.go @@ -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 -}