"net/http"
"net/url"
"os"
+ "regexp"
"strings"
)
type ArvadosApiError struct {
error
HttpStatusCode int
- HttpStatus string
+ HttpStatus string
}
func (e ArvadosApiError) Error() string { return e.error.Error() }
// 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"),
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
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
-}