diff --git a/bin/agave-curl b/bin/agave-curl new file mode 100755 index 0000000..f496a6e --- /dev/null +++ b/bin/agave-curl @@ -0,0 +1,141 @@ +#!/usr/bin/env python +import re +import argparse +import requests +import sys +import os +from os.path import expanduser + +cmd = '' +for a in sys.argv: + if re.search(r'[\s"]',a): + cmd += " '%s'" % a + else: + cmd += " " + a + +parser = argparse.ArgumentParser(description="Python-based Curl Replacement") +parser.add_argument("-s","--silent",help="Silent mode",action="store_true") +parser.add_argument("-k","--insecure",help="Allow insecure connections",action="store_true") +parser.add_argument("-u","--user",help="Environment variable to read for USER:PASSWORD") +parser.add_argument("-X","--request",help="Request Type") +parser.add_argument("-H","--header",help="Environment variable to read for a header",action="append") +parser.add_argument("-d","--data",help="HTTP POST data",action="append") +parser.add_argument("--data-urlencode",help="HTTP POST data",action="append") +parser.add_argument("--data-binary",help="HTTP POST data") +parser.add_argument("--globoff",help="Disable URL sequences and ranges using {} and []",action="store_true") +parser.add_argument("-F","--form",help="Specify HTTP multipart POST data",action="append") +parser.add_argument("url",nargs="?") +args = parser.parse_args() + +def loader(val,require_secure=False): + g = re.match(r'^\s*(@|\$)(.*)',val) + if g: + if g.group(1) == '@': + try: + if g.group(2) == '-': + return sys.stdin + else: + return open(expanduser(g.group(2)),"rb") + except: + sys.stderr.write('curl: couldn\'t open file "%s"' % g.group(2)) + return "" + else: # g.group(1) == '$' + try: + return os.environ[g.group(2)] + except: + sys.stderr.write('curl: couldn\'t read environment variable "%s"' % g.group(2)) + return "" + else: + #if require_secure: + # raise Exception("Credentials Exposed: "+cmd) + return val + +verify = True +if args.insecure: + pass #verify = not args.insecure + +request = "GET" +if args.request: + request = args.request + +headers = {} +if args.header: + for arg in args.header: + s = arg.split(":") + if s[0] == "Authorization": + headers[s[0]]=loader(s[1],True) + else: + headers[s[0]]=loader(s[1],False) + +data = [] + +if args.data: + for d1 in args.data: + for d in d1.split('&'): + g = re.match(r'(.*?)=(.*)',d) + if g: + data += [(g.group(1),loader(g.group(2)))] + else: + data += [(loader(d),'')] + +if args.data_urlencode: + for d1 in args.data_urlencode: + for d in d1.split('&'): + g = re.match(r'(.*?)=(.*)',d) + if g: + data += [(g.group(1),loader(g.group(2)))] + else: + data += [(loader(d),'')] + +if args.data_binary: + data = loader(args.data_binary) + if hasattr(data,"read"): + data = data.read() + +if args.user: + s = args.user.split(":") + auth = (s[0],loader(s[1],True)) +else: + auth = None + +form_data = {} +if args.form: + for f in args.form: + g = re.match(r'^(.*?)=(.*)$',f) + if g: + form_data[g.group(1)] = loader(g.group(2)) + +res = '' + +if request == "GET": + if args.user: + res = requests.get(args.url,headers=headers,data=data,auth=auth,verify=verify) + else: + res = requests.get(args.url,headers=headers,data=data,verify=verify) + +elif request == "POST": + if args.user: + res = requests.post(args.url,headers=headers,data=data,auth=auth,files=form_data,verify=verify) + else: + res = requests.post(args.url,headers=headers,data=data,files=form_data,verify=verify) + +elif request == "DELETE": + if args.user: + res = requests.delete(args.url,headers=headers,data=data,auth=auth,verify=verify) + else: + res = requests.delete(args.url,headers=headers,data=data,verify=verify) + +elif request == "PUT": + if args.user: + res = requests.put(args.url,headers=headers,data=data,auth=auth,verify=verify) + else: + res = requests.put(args.url,headers=headers,data=data,verify=verify) + +else: + raise Exception("Not supported: "+cmd) + +# Python 3 issue +if type(res.text) == str: + sys.stdout.write(res.text) +else: + sys.stdout.write(res.text.encode('utf-8')) diff --git a/bin/apps-addupdate b/bin/apps-addupdate index a892f74..80a017b 100755 --- a/bin/apps-addupdate +++ b/bin/apps-addupdate @@ -78,25 +78,25 @@ main() { # reading from stdin if [[ "$filetoupload" == "-" ]]; then - cmd="curl --globoff -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X POST --data-binary @- '${hosturl}${args}?pretty=true'" + cmd="agave-curl --globoff -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X POST --data-binary @- '${hosturl}${args}?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi # make sure we specify content type as application/json - response=`curl --globoff -sk -H "${authheader}" -H "Content-Type: application/json" -X POST --data-binary @- "${hosturl}${args}?pretty=true"` + response=`agave-curl --globoff -sk -H "${authheader}" -H "Content-Type: application/json" -X POST --data-binary @- "${hosturl}${args}?pretty=true"` # standard file upload else - cmd="curl -sk -H \"${authheader}\" -X POST -F \"fileToUpload=@$filetoupload\" '${hosturl}${args}?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X POST -F \"fileToUpload=@$filetoupload\" '${hosturl}${args}?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X POST -F "fileToUpload=@$filetoupload" "${hosturl}${args}?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X POST -F "fileToUpload=@$filetoupload" "${hosturl}${args}?pretty=true"` fi diff --git a/bin/apps-clone b/bin/apps-clone index 40b5005..c0da94f 100755 --- a/bin/apps-clone +++ b/bin/apps-clone @@ -96,13 +96,13 @@ main() { form_params="${form_params} --data-urlencode "${dat} fi - cmd="curl -sk -H \"${authheader}\" -X PUT '$hosturl$args?pretty=true' --data-urlencode "action=clone" '${form_params}'" + cmd="agave-curl -sk -H \"${authheader}\" -X PUT '$hosturl$args?pretty=true' --data-urlencode "action=clone" '${form_params}'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X PUT -d "$form_params" "$hosturl$args?pretty=true" --data-urlencode "action=clone" ${form_params}` + response=`agave-curl -sk -H "${authheader}" -X PUT -d "$form_params" "$hosturl$args?pretty=true" --data-urlencode "action=clone" ${form_params}` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/apps-delete b/bin/apps-delete index 6831eb6..224a279 100755 --- a/bin/apps-delete +++ b/bin/apps-delete @@ -57,13 +57,13 @@ main() { err $response else - cmd="curl -sk -H \"${authheader}\" -X DELETE '$hosturl$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X DELETE '$hosturl$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X DELETE "$hosturl$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X DELETE "$hosturl$args?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/apps-disable b/bin/apps-disable index b044b6f..c6d6dbe 100755 --- a/bin/apps-disable +++ b/bin/apps-disable @@ -56,13 +56,13 @@ main() { err "Please specify a valid app id to enable" else - cmd="curl -sk -H \"${authheader}\" -X PUT -d \"action=disable\" '$hosturl$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X PUT -d \"action=disable\" '$hosturl$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X PUT -d "action=disable" "$hosturl$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X PUT -d "action=disable" "$hosturl$args?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/apps-enable b/bin/apps-enable index 2bc63da..1eee73a 100755 --- a/bin/apps-enable +++ b/bin/apps-enable @@ -56,13 +56,13 @@ main() { err "Please specify a valid app id to enable" else - cmd="curl -sk -H \"${authheader}\" -X PUT -d \"action=enable\" '$hosturl$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X PUT -d \"action=enable\" '$hosturl$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X PUT -d "action=enable" "$hosturl$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X PUT -d "action=enable" "$hosturl$args?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/apps-erase b/bin/apps-erase index 653be74..47bd5fc 100755 --- a/bin/apps-erase +++ b/bin/apps-erase @@ -59,13 +59,13 @@ main() { err "Please specify a valid app id to erase" else - cmd="curl -sk -H \"${authheader}\" -X PUT -d \"action=erase\" '$hosturl$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X PUT -d \"action=erase\" '$hosturl$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X PUT -d "action=erase" "$hosturl$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X PUT -d "action=erase" "$hosturl$args?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/apps-history b/bin/apps-history index 8fbfe8c..d3f7aab 100755 --- a/bin/apps-history +++ b/bin/apps-history @@ -67,13 +67,13 @@ main() { [[ -n "${eventId}" ]] && hosturl="${hosturl}/${eventId}" - cmd="curl -sk -H \"${authheader}\" '$hosturl?pretty=true$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" '$hosturl?pretty=true$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "${hosturl}?pretty=true$(pagination)"` + response=`agave-curl -sk -H "${authheader}" "${hosturl}?pretty=true$(pagination)"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then diff --git a/bin/apps-list b/bin/apps-list index 0ccd104..aa29ba1 100755 --- a/bin/apps-list +++ b/bin/apps-list @@ -94,13 +94,13 @@ main() { fi fi - cmd="curl -sk -H \"${authheader}\" '$hosturl?${querystring}'" + cmd="agave-curl -sk -H \"${authheader}\" '$hosturl?${querystring}'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "$hosturl?${querystring}"` + response=`agave-curl -sk -H "${authheader}" "$hosturl?${querystring}"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "${response}") diff --git a/bin/apps-pems-delete b/bin/apps-pems-delete index fc2ec97..06e4728 100755 --- a/bin/apps-pems-delete +++ b/bin/apps-pems-delete @@ -57,13 +57,13 @@ main() { if [ -z "$args" ]; then err "Please specify an app id for which to set the permissions" else - cmd="curl -sk -H \"${authheader}\" -X DELETE '$hosturl$args/pems/$pemusername?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X DELETE '$hosturl$args/pems/$pemusername?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X DELETE "$hosturl$args/pems/$pemusername?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X DELETE "$hosturl$args/pems/$pemusername?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/apps-pems-list b/bin/apps-pems-list index f8bbecd..a9e9b52 100755 --- a/bin/apps-pems-list +++ b/bin/apps-pems-list @@ -59,13 +59,13 @@ main() { err "Please specify a valid app id for which to retrieve permissions" else - cmd="curl -sk -H \"${authheader}\" '$hosturl$args/pems/$pemusername?pretty=true$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" '$hosturl$args/pems/$pemusername?pretty=true$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "$hosturl$args/pems/$pemusername?pretty=true$(pagination)"` + response=`agave-curl -sk -H "${authheader}" "$hosturl$args/pems/$pemusername?pretty=true$(pagination)"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/apps-pems-update b/bin/apps-pems-update index 107ba1b..493a377 100755 --- a/bin/apps-pems-update +++ b/bin/apps-pems-update @@ -59,13 +59,13 @@ main() { if [ -z "$args" ]; then err "Please specify an app id for which to set the permissions" else - cmd="curl -sk -H \"${authheader}\" -X POST -d \"permission=$permission\" '$hosturl$args/pems/$pemusername?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X POST -d \"permission=$permission\" '$hosturl$args/pems/$pemusername?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X POST -d "permission=$permission" "$hosturl$args/pems/$pemusername?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X POST -d "permission=$permission" "$hosturl$args/pems/$pemusername?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/apps-publish b/bin/apps-publish index 53d7b92..8b440c7 100755 --- a/bin/apps-publish +++ b/bin/apps-publish @@ -103,13 +103,13 @@ main() { fi - cmd="curl -sk -H \"${authheader}\" -X PUT --data-urlencode \"action=publish\" ${publicAppparams} '$hosturl$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X PUT --data-urlencode \"action=publish\" ${publicAppparams} '$hosturl$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X PUT --data-urlencode "action=publish" ${publicAppparams} "$hosturl$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X PUT --data-urlencode "action=publish" ${publicAppparams} "$hosturl$args?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/apps-search b/bin/apps-search index 1bdb593..d02ddf9 100755 --- a/bin/apps-search +++ b/bin/apps-search @@ -119,13 +119,13 @@ main() { done fi - cmd="curl -G -sk -H \"${authheader}\" '$appsurl?pretty=true$(pagination)' $querystring)" + cmd="agave-curl -G -sk -H \"${authheader}\" '$appsurl?pretty=true$(pagination)' $querystring)" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -G -sk -H "${authheader}" $appsurl?pretty=true$(pagination) ${querystring}` + response=`agave-curl -G -sk -H "${authheader}" $appsurl?pretty=true$(pagination) ${querystring}` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/auth-switch b/bin/auth-switch index 6ee46b9..7b452f3 100755 --- a/bin/auth-switch +++ b/bin/auth-switch @@ -15,7 +15,6 @@ source "$DIR/common.sh" # set to 1 to prevent using cache. token creation requires a valid key savechanges=0 -disable_cache=1 # Script logic -- TOUCH THIS {{{ @@ -35,15 +34,11 @@ in subsequent calls to the API. -u, --username Agave tenant username -d, --devurl URL to the development server -b, --baseurl URL to the production API server - -t, --tenantid Current tenant id. ex. agave.prod - -s, --apisecret Client application api secret - -k, --apikey Client application api key - -n, --client_name Client application name - -z, --accesstoken Current auth token - -r, --refreshtoken Current refresh token - -l, --expires_in Token lifetime from last auth request - -e, --expires_at Timestamp when the token expires - -c, --created_at Timestamp when the token was created + -t, --tenantid Current tenant id. ex. iplantc.org + -s, --apisecret Consumer secret + -k, --apikey Consumer Key + -z, --access_token Current auth token + -r, --refresh_token Current refresh token -S, --savechanges Save the updated value -f, --force Skip all user interaction -i, --interactive Prompt for values @@ -66,8 +61,9 @@ source "$DIR/auth-common.sh" main() { #echo -n #set -x - - current_cache=$(kvget current) + local post_options="grant_type=password&username=${username}&password=${password}&scope=PRODUCTION" + + current_cache=$(kvget current ) if [ -e "$DIR/auth-switch-filter.sh" ]; then source $DIR/auth-switch-filter.sh @@ -78,94 +74,62 @@ main() { else dev=$(jsonquery "$current_cache" "devurl") fi - dev=$(trim "$dev") - - - if [[ ! "${user+1}" && -z "$user" ]]; then + + if [ -z "$user" ]; then user=$(jsonquery "$current_cache" "username") fi - user=$(trim "$user") - - - if [[ ! "${tenant+z}" && -z "$tenant" ]]; then + + if [ -z "$tenant" ]; then tenant=$(jsonquery "$current_cache" "tenantid") fi - tenant=$(trim "$tenant") - - - if [[ ! "${baseurl+1}" && -z "$baseurl" ]]; then + + if [ -z "$baseurl" ]; then baseurl=$(jsonquery "$current_cache" "baseurl") fi - baseurl=$(trim "$baseurl") - - - if [[ ! "${apisecret+1}" && -z "$apisecret" ]]; then + + if [ -z "$apisecret" ]; then apisecret=$(jsonquery "$current_cache" "apisecret") fi - apisecret=$(trim "$apisecret") - - - if [[ ! "${apikey+z}" && -z "$apikey" ]]; then + + if [ -z "$apikey" ]; then apikey=$(jsonquery "$current_cache" "apikey") fi - apikey=$(trim "$apikey") - - - if [[ ! "${accesstoken+access_1}" && -z "$accesstoken" ]]; then - accesstoken=$(jsonquery "$current_cache" "access_token") - fi - accesstoken=$(trim "$accesstoken") - - - if [[ ! "${refreshtoken+1}" && -z "$refreshtoken" ]]; then - refreshtoken=$(jsonquery "$current_cache" "refresh_token") - fi - refreshtoken=$(trim "$refreshtoken") - - - if [[ ! "${client_name+1}" && -z "$client_name" ]]; then - client_name=$(jsonquery "$current_cache" "client_name") - fi - client_name=$(trim "$client_name") - - - if [[ ! "${expires_in+1}" && -z "$expires_in" ]]; then - expires_in=$(jsonquery "$current_cache" "expires_in") + + if [ -z "$access_token" ]; then + access_token=$(jsonquery "$current_cache" "access_token") fi - expires_in=$(trim "$expires_in") - - - if [[ ! "${expires_at+1}" && -z "$expires_at" ]]; then - expires_at=$(jsonquery "$current_cache" "expires_at") + + if [ -z "$refresh_token" ]; then + refresh_token=$(jsonquery "$current_cache" "refresh_token") fi - expires_at=$(trim "$expires_at") - - - if [[ ! "${created_at+1}" && -z "$created_at" ]]; then - created_at=$(jsonquery "$current_cache" "created_at") + + if [ -z "$refresh_token" ]; then + refresh_token=$(jsonquery "$current_cache" "refresh_token") fi - created_at=$(trim "$created_at") - - - response="{\"tenantid\":\"$tenant\",\"baseurl\":\"${baseurl}\",\"devurl\":\"${dev}\",\"apisecret\":\"$apisecret\",\"apikey\":\"$apikey\",\"username\":\"$user\",\"access_token\":\"$accesstoken\",\"refresh_token\":\"$refreshtoken\",\"created_at\":\"$created_at\",\"expires_in\":\"$expires_in\",\"expires_at\":\"$expires_at\",\"client_name\":\"$client_name\"}" - format_api_json "$response" + expires_in=$(jsonquery "$current_cache" "expires_in") + + expires_at=$(jsonquery "$current_cache" "expires_at") + + created_at=$(jsonquery "$current_cache" "created_at") + + response="{\"tenantid\":\"$tenant\",\"baseurl\":\"${baseurl}\",\"devurl\":\"${dev}\",\"apisecret\":\"$apisecret\",\"apikey\":\"$apikey\",\"username\":\"$user\",\"access_token\":\"$access_token\",\"refresh_token\":\"$refresh_token\",\"created_at\":\"$created_at\",\"expires_in\":\"$expires_in\",\"expires_at\":\"$expires_at\"}" + + result=$(format_api_json "$response") + + success "$result" } format_api_json() { if ((savechanges)); then + kvset current "$1" + + echo "Cache successfully updated and saved to $AGAVE_CACHE_DIR/current"; fi - - if ((veryverbose)); then - echo "Cache successfully updated and saved to $AGAVE_CACHE_DIR/current"; - json_prettyify "${1}" - elif ((verbose)); then - json_prettyify "${1}" - else - echo "Cache successfully updated and saved to $AGAVE_CACHE_DIR/current"; - fi + + json_prettyify "${1}" } ################################################################## @@ -196,12 +160,8 @@ while [[ $1 = -?* ]]; do -t|--tenant) shift; tenant=$1 ;; -s|--apisecret) shift; apisecret=$1 ;; -k|--apikey) shift; apikey=$1 ;; - -n|--client_name) shift; client_name=$1 ;; - -z|--accesstoken) shift; accesstoken=$1 ;; - -r|--refreshtoken) shift; refreshtoken=$1 ;; - -l|--expires_in) shift; expires_in=$1 ;; - -e|--expires_at) shift; expires_at=$1 ;; - -c|--created_at) shift; created_at=$1 ;; + -z|--access_token) shift; access_token=$1 ;; + -r|--refresh_token) shift; refresh_token=$1 ;; -S|--savechanges) savechanges=1 ;; -v|--verbose) verbose=1 ;; -V|--veryverbose) veryverbose=1; verbose=1 ;; diff --git a/bin/auth-tokens-create b/bin/auth-tokens-create index 96cff88..2051e4d 100755 --- a/bin/auth-tokens-create +++ b/bin/auth-tokens-create @@ -22,7 +22,7 @@ storetoken=1 # A list of all variables to prompt in interactive mode. These variables HAVE # to be named exactly as the longname option definition in usage(). -interactive_opts=(apisecret apikey apiusername apipassword) +interactive_opts=(apisecret apikey username password) # Print usage usage() { @@ -37,10 +37,10 @@ For ease of use, the -S option can be specified to store the new credential for reuse in subsequent calls to the API. Options: - -u, --apiusername Agave tenant username. This will override the value of AGAVE_USERNAME in your environment. - -p, --apipassword Agave tenant password. This will override the value of AGAVE_PASSWORD in your environment. - -s, --apisecret Client api secret. This will override the value of AGAVE_CLIENT_SECRET in your environment. - -k, --apikey Client api key. This will override the value of AGAVE_CLIENT_KEY in your environment. + -u, --username Agave tenant username + -p, --password Agave tenant password + -s, --apisecret Consumer secret + -k, --apikey Consumer Key -x, --tokenuser API username for whom the returned token should apply, requires admin permissions -S, --storetoken Store the token for later use so you can work without reauthenticating on every command. This is the default behavior @@ -70,37 +70,30 @@ main() { #echo -n #set -x hosturl=${hosturl%/}/token + export apisecret - if [[ -z "$apikey" ]] || [[ -z "$apisecret" ]]; then - - error_no_client - - elif [ -n "$tokenuser" ]; then - - # the request is for an impersonation token. We separate the authenticating user from the impersonated user - authUsername=$apiusername - apiusername=$tokenuser - - cmd="curl -sku \"$apikey:$apisecret\" -X POST --data-urlencode \"token_username=${apiusername}\" --data-urlencode \"username=${authUsername}\" --data-urlencode \"password=${apipassword}\" --data-urlencode \"grant_type=admin_password\" --data-urlencode \"scope=PRODUCTION\" '${hosturl}'" + if [ -n "$tokenuser" ]; then + authUsername=$username + username=$tokenuser + + cmd="agave-curl -sku \"$apikey:\$apisecret\" -X POST --data-urlencode \"token_username=${tokenuser}\" --data-urlencode \"username=${authUsername}\" --data-urlencode \"password=${password}\" --data-urlencode \"grant_type=admin_password\" --data-urlencode \"scope=PRODUCTION\" '${hosturl}'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`json_prettyify $(curl -sku "$apikey:$apisecret" -X POST --data-urlencode "token_username=${apiusername}" --data-urlencode "username=${authUsername}" --data-urlencode "password=${apipassword}" --data-urlencode "grant_type=admin_password" --data-urlencode "scope=PRODUCTION" "$hosturl")` + response=`json_prettyify $(agave-curl -sku "$apikey:\$apisecret" -X POST --data-urlencode "token_username=${tokenuser}" --data-urlencode "username=${authUsername}" --data-urlencode "password=${password}" --data-urlencode "grant_type=admin_password" --data-urlencode "scope=PRODUCTION" "$hosturl")` else - - # standard auth request - authUsername=$apiusername + authUsername=$username - cmd="curl -sku \"$apikey:$apisecret\" -X POST --data-urlencode \"username=${authUsername}\" --data-urlencode \"password=${apipassword}\" --data-urlencode \"grant_type=password\" --data-urlencode \"scope=PRODUCTION\" '${hosturl}'" + cmd="agave-curl -sku \"$apikey:\\\$apisecret\" -X POST --data-urlencode \"username=${authUsername}\" --data-urlencode \"password=${password}\" --data-urlencode \"grant_type=password\" --data-urlencode \"scope=PRODUCTION\" '${hosturl}'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`json_prettyify $(curl -sku "$apikey:$apisecret" -X POST --data-urlencode "username=${authUsername}" --data-urlencode "password=${apipassword}" --data-urlencode "grant_type=password" --data-urlencode "scope=PRODUCTION" "$hosturl")` + response=`json_prettyify $(agave-curl -sku "$apikey:\\\$apisecret" -X POST --data-urlencode "username=${authUsername}" --data-urlencode "password=${password}" --data-urlencode "grant_type=password" --data-urlencode "scope=PRODUCTION" "$hosturl")` fi @@ -119,8 +112,7 @@ format_api_json() { jsonval access_token "$1" "access_token" jsonval refresh_token "$1" "refresh_token" jsonval expires_in "$1" "expires_in" - jsonval client_name "$(kvget current)" "client_name" - + created_at=$(date +%s) if date --version >/dev/null 2>&1 ; then @@ -129,9 +121,9 @@ format_api_json() { expires_at=`date -r $(expr $created_at + $expires_in)` fi - kvset current "{\"tenantid\":\"$tenantid\",\"baseurl\":\"$baseurl\",\"devurl\":\"$devurl\",\"apisecret\":\"$apisecret\",\"apikey\":\"$apikey\",\"username\":\"$apiusername\",\"access_token\":\"$access_token\",\"refresh_token\":\"$refresh_token\",\"created_at\":\"$created_at\",\"expires_in\":\"$expires_in\",\"expires_at\":\"$expires_at\",\"client_name\":\"$client_name\"}" + kvset current "{\"tenantid\":\"$tenantid\",\"baseurl\":\"$baseurl\",\"devurl\":\"$devurl\",\"apisecret\":\"$apisecret\",\"apikey\":\"$apikey\",\"username\":\"$username\",\"access_token\":\"$access_token\",\"refresh_token\":\"$refresh_token\",\"created_at\":\"$created_at\",\"expires_in\":\"$expires_in\",\"expires_at\":\"$expires_at\"}" - echo "Token for ${tenantid}:${apiusername} successfully refreshed and cached for ${expires_in} seconds"; + echo "Token for ${tenantid}:${username} successfully refreshed and cached for ${expires_in} seconds"; fi if ((veryverbose)); then @@ -166,8 +158,8 @@ while [[ $1 = -?* ]]; do case $1 in -h|--help) usage >&2; safe_exit ;; --version) version; copyright; disclaimer; safe_exit ;; - -u|--apiusername) shift; apiusername=$1 ;; - -p|--apipassword) shift; apipassword=$1 ;; + -u|--username) shift; username=$1 ;; + -p|--password) shift; password=$1 ;; -s|--apisecret) shift; apisecret=$1 ;; -k|--apikey) shift; apikey=$1 ;; -x|--tokenuser) shift; tokenuser=$1;; @@ -193,3 +185,15 @@ args+=("$@") # Run the script logic source "$DIR/runner.sh" + + +# print_options='-d "grant_type=admin_password" -d "username='$proxyuser'" -d "scope=PRODUCTION" -d "adminPassword=XXXXX"' +# post_options='--data-urlencode "grant_type=admin_password" --data-urlencode "username='$proxyuser'" --data-urlencode "scope=PRODUCTION" --data-urlencode "adminPassword='$password'"' +# cmd="agave-curl -sku \"$apikey:XXXXX\" -X POST --data-binary '$print_options' '$hosturl'" +# else +# print_options='{ "password": "admin_password", "username": "'$username'", "scope": "PRODUCTION", "password": "XXXXX"}' +# post_options='{ "password": "admin_password", "username": "'$username'", "scope": "PRODUCTION", "password": "'$password'"}' +# cmd="agave-curl -sku \"$apikey:XXXXX\" -X POST --data-binary '$print_options' '$hosturl'" +# fi + +# cmd="agave-curl -sku \"$apikey:XXXXX\" -X POST --data-binary '$print_options' '$hosturl'" diff --git a/bin/auth-tokens-refresh b/bin/auth-tokens-refresh index 2e2d626..a621ad1 100755 --- a/bin/auth-tokens-refresh +++ b/bin/auth-tokens-refresh @@ -31,9 +31,9 @@ Retrieves a new bearer token using the refresh token obtained from a previous auth-tokens-create call. Options: - -r, --refresh_token Active refresh token used to request a new auth token. - -s, --apisecret Client api secret. This will override the value of AGAVE_CLIENT_SECRET in your environment. - -k, --apikey Client api key. This will override the value of AGAVE_CLIENT_KEY in your environment. + -r, --refresh_token Access token + -s, --apisecret Consumer secret + -k, --apikey Consumer Key -S, --storetoken Store the token for later use so you can work without reauthenticating on every command. This is the default behavior -D, --displayonly Display the fetched auth credentials, but do not save. The local auth cache @@ -61,41 +61,26 @@ source "$DIR/auth-common.sh" main() { #echo -n #set -x - - if [[ -z "$apikey" ]] || [[ -z "$apisecret" ]]; then - - error_no_client - - elif [[ -z "$refresh_token" ]]; then - - err 'No refresh token found. Please provide a refresh token using the -r/--refresh_token option -or reauthenticate to get fresh auth and refresh tokens using the auth-tokens-create command. - - auth-tokens-create --apiusername $AGAVE_USERNAME --apipassword $AGAVE_PASSWORD --storeclient -' - else - - hosturl=${hosturl}/token - - - local post_options="grant_type=refresh_token&refresh_token=${refresh_token}&scope=PRODUCTION" - - cmd="curl -sku \"$apikey:XXXXXX\" -X POST -d \"${post_options}\" -H \"Content-Type:application/x-www-form-urlencoded\" '$hosturl'" - - if ((veryverbose)); then - [ "$piped" -eq 0 ] && log "Calling $cmd" - fi - - response=`curl -sku "$apikey:$apisecret" -X POST -d "${post_options}" -H "Content-Type:application/x-www-form-urlencoded" "$hosturl"` - - if [[ $(jsonquery "$response" "token_type") = 'bearer' ]]; then - result=$(format_api_json "$response") - #format_api_json "$response" - success "$result" - else - err "$response" - fi - fi + hosturl=${hosturl}/token + export refresh_token + local post_options='-d grant_type=refresh_token -d refresh_token=$refresh_token -d scope=PRODUCTION' + + cmd="agave-curl -sku \"$apikey:XXXXXX\" -X POST ${post_options} -H \"Content-Type:application/x-www-form-urlencoded\" '$hosturl'" + + if ((veryverbose)); then + [ "$piped" -eq 0 ] && log "Calling $cmd" + fi + + export apisecret + response=`agave-curl -s -ku "$apikey:"'$apisecret' -X POST ${post_options} -H "Content-Type:application/x-www-form-urlencoded" "$hosturl"` + + if [[ $(jsonquery "$response" "token_type") = 'bearer' ]]; then + result=$(format_api_json "$response") + #format_api_json "$response" + success "$result" + else + err "$response" + fi } format_api_json() { @@ -103,8 +88,6 @@ format_api_json() { if ((storetoken)); then jsonval username "$(kvget current)" "username" - jsonval client_name "$(kvget current)" "client_name" - jsonval access_token "$1" "access_token" jsonval refresh_token "$1" "refresh_token" jsonval expires_in "$1" "expires_in" @@ -115,7 +98,7 @@ format_api_json() { expires_at=`date -r $(expr $created_at + $expires_in)` fi - kvset current "{\"tenantid\":\"$tenantid\",\"baseurl\":\"$baseurl\",\"devurl\":\"$devurl\",\"apisecret\":\"$apisecret\",\"apikey\":\"$apikey\",\"username\":\"$username\",\"access_token\":\"$access_token\",\"refresh_token\":\"$refresh_token\",\"created_at\":\"$created_at\",\"expires_in\":\"$expires_in\",\"expires_at\":\"$expires_at\",\"client_name\":\"$client_name\"}" + kvset current "{\"tenantid\":\"$tenantid\",\"baseurl\":\"$baseurl\",\"devurl\":\"$devurl\",\"apisecret\":\"$apisecret\",\"apikey\":\"$apikey\",\"username\":\"$username\",\"access_token\":\"$access_token\",\"refresh_token\":\"$refresh_token\",\"created_at\":\"$created_at\",\"expires_in\":\"$expires_in\",\"expires_at\":\"$expires_at\"}" echo "Token for ${tenantid}:${username} successfully refreshed and cached for ${expires_in} seconds"; diff --git a/bin/auth-tokens-revoke b/bin/auth-tokens-revoke index 593f0ea..b846185 100755 --- a/bin/auth-tokens-revoke +++ b/bin/auth-tokens-revoke @@ -39,8 +39,8 @@ Note that you must use the same client key and secret that was used to obtain the auth token to revoke it. Options: - -s, --apisecret Client api secret. This will override the value of AGAVE_CLIENT_SECRET in your environment. - -k, --apikey Client api key. This will override the value of AGAVE_CLIENT_KEY in your environment. + -s, --apisecret Consumer secret + -k, --apikey Consumer Key -S, --storetoken Removes the revoked credential from the local cache -D, --displayonly Display the fetched auth credentials, but do not save. The local auth cache will not be updated @@ -67,54 +67,45 @@ source "$DIR/auth-common.sh" main() { #echo -n - if [[ -z "$apikey" ]] || [[ -z "$apisecret" ]]; then - - error_no_client - - else - - hosturl=${hosturl%/}/revoke - - # invalidate the access token given as an argument - # if present, otherwise use the token from the - # user's auth cache. - if [[ -z "$args" ]]; then - token_to_revoke="$access_token" - else - token_to_revoke="$args" - fi - - - if [[ -z "$token_to_revoke" ]]; then - err "No token found in the current environment cache. Please provide a valid access token to revoke" - fi - - cmd="curl -sku \"$apikey:$apisecret\" -X POST -d 'token=$token_to_revoke' '$hosturl'" - - if ((veryverbose)); then - [ "$piped" -eq 0 ] && log "Calling $cmd" - fi - - response=`curl -sku "$apikey:$apisecret" -X POST -d "token=$token_to_revoke" "$hosturl"` - - if [[ -n "$response" ]]; then - response=$(json_prettyify "$response") - err "{\"status\":\"error\",\"message\":\"$(jsonquery "$response" "error_description")\",\"result\": null}" - else - response="{\"status\":\"success\",\"message\":\"\",\"result\": null}" - result=$(format_api_json "$response") - success "$result" - fi - fi + hosturl=${hosturl%/}/revoke + + # invalidate the access token given as an argument + # if present, otherwise use the token from the + # user's auth cache. + if [[ -z "$args" ]]; then + token_to_revoke="$access_token" + else + token_to_revoke="$args" + fi + + + if [[ -z "$token_to_revoke" ]]; then + err "No token found in the current environment cache. Please provide a valid access token to revoke" + fi + + cmd="agave-curl -sku \"$apikey:$apisecret\" -X POST -d 'token=$token_to_revoke' '$hosturl'" + + if ((veryverbose)); then + [ "$piped" -eq 0 ] && log "Calling $cmd" + fi + + response=`agave-curl -sku "$apikey:$apisecret" -X POST -d "token=$token_to_revoke" "$hosturl"` + + if [[ -n "$response" ]]; then + response=$(json_prettyify "$response") + err "{\"status\":\"error\",\"message\":\"$(jsonquery "$response" "error_description")\",\"result\": null}" + else + response="{\"status\":\"success\",\"message\":\"\",\"result\": null}" + result=$(format_api_json "$response") + success "$result" + fi } format_api_json() { if ((storetoken)) || [ "$token_to_revoke" == "$access_token" ]; then - - jsonval client_name "$(kvget current)" "client_name" - - kvset current "{\"tenantid\":\"$tenantid\",\"baseurl\":\"$baseurl\",\"devurl\":\"$devurl\",\"apisecret\":\"$apisecret\",\"apikey\":\"$apikey\",\"username\":\"$username\",\"access_token\":\"\",\"refresh_token\":\"\",\"created_at\":\"\",\"expires_in\":\"\",\"expires_at\":\"\",\"client_name\":\"$client_name\"}" + + kvset current "{\"tenantid\":\"$tenantid\",\"baseurl\":\"$baseurl\",\"devurl\":\"$devurl\",\"apisecret\":\"$apisecret\",\"apikey\":\"$apikey\",\"username\":\"$username\",\"access_token\":\"\",\"refresh_token\":\"\",\"created_at\":\"\",\"expires_in\":\"\",\"expires_at\":\"\"}" fi diff --git a/bin/clients-create b/bin/clients-create index 36cc1ae..67e1a87 100755 --- a/bin/clients-create +++ b/bin/clients-create @@ -17,7 +17,7 @@ interactive=1 # A list of all variables to prompt in interactive mode. These variables HAVE # to be named exactly as the longname option definition in usage(). -interactive_opts=(apiusername apipassword) +interactive_opts=(client_name apiusername apipassword) # Print usage usage() { @@ -26,12 +26,12 @@ usage() { Creates a new API client application and generates a set of API keys for the user. Options: - -u, --apiusername Agave tenant username. This will override the value of AGAVE_USERNAME in your environment. - -p, --apipassword Agave tenant password. This will override the value of AGAVE_PASSWORD in your environment. - -N, --client_name The name of the client application. Defaults to ${apiusername}_cli_client. + -u, --apiusername API username + -p, --apipassword API password + -N, --client_name The name of the client application -T, --tier The subscription tier -D, --description A short description of the client application for which these keys - are being generated. Defaults to: Autogenerated cli client for ${apiusername} + are being generated -C, --callbackUrl The callback url for the OAuth auth grant -S, --storeclient Store the new api keys for later use so you do not have to manually reenter them when obtaining an auth token. Default behavior is to @@ -60,35 +60,27 @@ main() { #echo -n #set -x - if [ -z "$client_name" ] || [ $force -eq 1 ] ; then - if [[ -n "$callbackUrl" ]]; then - client_name="${apiusername}_web_client" - else - client_name="${apiusername}_cli_client" + if [ -z "$client_name" ]; then + client_name="$(uname -n)_cli_client" + + if [ -z "$description" ]; then + description="Autogenerated cli client for $(uname -n)" fi + + #err "Please specify a valid name for the new client" fi - - if [ -z "$description" ]; then - if [[ -n "$callbackUrl" ]]; then - client_type="client web application" - else - client_type="cli client application" - fi - - description="Autogenerated ${client_type} generated by ${apiusername} on $(date)" - fi - + if [ -z "$tier" ]; then tier='Unlimited' fi - cmd="curl -sku \"${apiusername}:XXXXX\" -X POST -d "clientName=${client_name}" -d \"tier=${tier}\" -d \"description=${description}\" -d \"callbackUrl=${callbackUrl}\" '${hosturl}${args}?pretty=true'" + cmd="agave-curl -sku \"${apiusername}:XXXXX\" -X POST -d "clientName=${client_name}" -d \"tier=${tier}\" -d \"description=${description}\" -d \"callbackUrl=${callbackUrl}\" '${hosturl}${args}?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sku "${apiusername}:${apipassword}" -X POST -d "clientName=${client_name}" -d "tier=${tier}" -d "description=${description}" -d "callbackUrl=${callbackUrl}" "${hosturl}${args}?pretty=true"` + response=`agave-curl -sku "${apiusername}:${apipassword}" -X POST -d "clientName=${client_name}" -d "tier=${tier}" -d "description=${description}" -d "callbackUrl=${callbackUrl}" "${hosturl}${args}?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") @@ -106,7 +98,7 @@ format_api_json() { formatted_response=`json_prettyify "${1}"` client_secret=$(jsonquery "$formatted_response" "result.consumerSecret") client_key=$(jsonquery "$formatted_response" "result.consumerKey") - + currentcache=$(kvget current) jsonval created_at "$currentcache" "created_at" jsonval expires_at "$currentcache" "expires_at" @@ -114,7 +106,7 @@ format_api_json() { jsonval access_token "$currentcache" "access_token" jsonval refresh_token "$currentcache" "refresh_token" - kvset current "{\"tenantid\":\"$tenantid\",\"baseurl\":\"$baseurl\",\"devurl\":\"$devurl\",\"apisecret\":\"$client_secret\",\"apikey\":\"$client_key\",\"username\":\"$apiusername\",\"access_token\":\"$access_token\",\"refresh_token\":\"$refresh_token\",\"created_at\":\"$created_at\",\"expires_in\":\"$expires_in\",\"expires_at\":\"$expires_at\",\"client_name\":\"$client_name\"}" + kvset current "{\"tenantid\":\"$tenantid\",\"baseurl\":\"$baseurl\",\"devurl\":\"$devurl\",\"apisecret\":\"$client_secret\",\"apikey\":\"$client_key\",\"username\":\"$apiusername\",\"access_token\":\"$access_token\",\"refresh_token\":\"$refresh_token\",\"created_at\":\"$created_at\",\"expires_in\":\"$expires_in\",\"expires_at\":\"$expires_at\"}" fi if ((veryverbose)); then @@ -172,15 +164,6 @@ while [[ $1 = -?* ]]; do shift done -if [[ -z "$apiusername" ]] && [[ -n "$AGAVE_USERNAME" ]]; then - apiusername="$AGAVE_USERNAME" -fi - -if [[ -z "$apipassword" ]] && [[ -n "$AGAVE_PASSWORD" ]]; then - apipassword="$AGAVE_PASSWORD" -fi - - # Store the remaining part as arguments. args+=("$@") diff --git a/bin/clients-delete b/bin/clients-delete index a46659c..8377f48 100755 --- a/bin/clients-delete +++ b/bin/clients-delete @@ -29,8 +29,8 @@ usage() { Deletes a client application and associated API keys. Options: - -u, --apiusername Agave tenant username. This will override the value of AGAVE_USERNAME in your environment. - -p, --apipassword Agave tenant password. This will override the value of AGAVE_PASSWORD in your environment. + -u, --apiusername API apiusername + -p, --apipassword API apipassword -H, --hosturl URL of the service -d, --development Run in dev mode using default dev server -f, --force Skip all user interaction @@ -54,26 +54,18 @@ source "$DIR/clients-common.sh" main() { #echo -n #set -x - - # get current client for use after success - jsonval cached_client "$(kvget current)" "client_name" - - client_name="$args" - if [ -z "$client_name" ]; then - client_name="${cached_client}" - fi - - if [ -z "$client_name" ]; then + + if [ -z "$args" ]; then err "Please specify a valid client to delete" else - cmd="curl -sku \"${apiusername}:xxxx\" -X DELETE '${hosturl}${client_name}?pretty=true'" + cmd="agave-curl -sku \"${apiusername}:xxxx\" -X DELETE '$hosturl$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sku "${apiusername}:${apipassword}" -X DELETE "${hosturl}${client_name}?pretty=true"` + response=`agave-curl -sku "${apiusername}:${apipassword}" -X DELETE "$hosturl$args?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") @@ -87,13 +79,6 @@ main() { format_api_json() { - # remove the deleted client from the local cache if the name matches - # as it is no longer valid or useful for anything. The current auth - # and refresh token may or may not be valid, so we leave them there. - if [[ "$client_name" == "$cached_client" ]]; then - auth-switch -s "" -k "" -S 2>&1 >> /dev/null - fi - if ((veryverbose)); then json_prettyify "${1}" elif [[ $verbose -eq 1 ]]; then diff --git a/bin/clients-list b/bin/clients-list index ead2184..db2be06 100755 --- a/bin/clients-list +++ b/bin/clients-list @@ -27,8 +27,8 @@ $(basename $0) [OPTION]... [CLIENT_NAME] List all API clients registered to the authenticated user. Options: - -u, --apiusername Agave tenant username. This will override the value of AGAVE_USERNAME in your environment. - -p, --apipassword Agave tenant password. This will override the value of AGAVE_PASSWORD in your environment. + -u, --apiusername API apiusername + -p, --apipassword API apipassword -l, --limit Maximum number of results to return -o, --offset Number of results to skip from the start -H, --hosturl URL of the service @@ -62,13 +62,13 @@ main() { clientsurl="${hosturl}?pretty=true$(pagination)" fi - cmd="curl -sku \"${apiusername}:xxxx\" '${clientsurl}'" + cmd="agave-curl -sku \"${apiusername}:xxxx\" '${clientsurl}'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sku "${apiusername}:${apipassword}" "${clientsurl}"` + response=`agave-curl -sku "${apiusername}:${apipassword}" "${clientsurl}"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/clients-subscriptions-list b/bin/clients-subscriptions-list index 8af71cf..880fb97 100755 --- a/bin/clients-subscriptions-list +++ b/bin/clients-subscriptions-list @@ -26,8 +26,8 @@ usage() { List all APIs to which the client is subscribed. Options: - -u, --apiusername Agave tenant username. This will override the value of AGAVE_USERNAME in your environment. - -p, --apipassword Agave tenant password. This will override the value of AGAVE_PASSWORD in your environment. + -u, --apiusername API apiusername + -p, --apipassword API apipassword -l, --limit Maximum number of results to return -o, --offset Number of results to skip from the start -H, --hosturl URL of the service @@ -53,25 +53,17 @@ source "$DIR/clients-common.sh" main() { #echo -n #set -x - - # get current client for use after success - jsonval cached_client "$(kvget current)" "client_name" - - client_name="$args" - if [ -z "$client_name" ]; then - client_name="${cached_client}" - fi - - if [ -z "$client_name" ]; then + + if [ -z "$args" ]; then err "Please specify a valid client for which to list subscriptions" else - cmd="curl -sku \"${apiusername}:${apipassword}\" '${hosturl}${client_name}/subscriptions?pretty=true$(pagination)'" + cmd="agave-curl -sku \"${apiusername}:${apipassword}\" '${hosturl}${args}/subscriptions?pretty=true$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sku "${apiusername}:${apipassword}" "${hosturl}${client_name}/subscriptions?pretty=true$(pagination)"` + response=`agave-curl -sku "${apiusername}:${apipassword}" "${hosturl}${args}/subscriptions?pretty=true$(pagination)"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/clients-subscriptions-update b/bin/clients-subscriptions-update index 7e42afc..e01706a 100755 --- a/bin/clients-subscriptions-update +++ b/bin/clients-subscriptions-update @@ -26,8 +26,8 @@ usage() { Subscribe a client to one or all apis. Options: - -u, --apiusername Agave tenant username. This will override the value of AGAVE_USERNAME in your environment. - -p, --apipassword Agave tenant password. This will override the value of AGAVE_PASSWORD in your environment. + -u, --apiusername API username + -p, --apipassword API password -N, --apiName The name of the API to subscribe the client application to. Use a wildcard to subscribe to all APIs -T, --tier The subscription tier @@ -57,12 +57,7 @@ main() { #echo -n #set -x - client_name="$args" - if [ -z "$client_name" ]; then - client_name="${cached_client}" - fi - - if [ -z "$client_name" ]; then + if [ -z "$args" ]; then err "Please specify a valid client name" else @@ -74,13 +69,13 @@ main() { tier='Unlimited' fi - cmd="curl -sku \"${apiusername}:xxxx\" -X POST -d \"apiName=${apiName}&tier=${tier}&apiVersion=${apiVersion}&apiProvider=${apiProvider}\" '${hosturl}${client_name}/subscriptions?pretty=true'" + cmd="agave-curl -sku \"${apiusername}:xxxx\" -X POST -d \"apiName=${apiName}&tier=${tier}&apiVersion=${apiVersion}&apiProvider=${apiProvider}\" '${hosturl}${args}/subscriptions?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sku "${apiusername}:${apipassword}" -X POST -d "apiName=${apiName}&tier=${tier}&apiVersion=${apiVersion}&apiProvider=${apiProvider}" "${hosturl}${client_name}/subscriptions?pretty=true"` + response=`agave-curl -sku "${apiusername}:${apipassword}" -X POST -d "apiName=${apiName}&tier=${tier}&apiVersion=${apiVersion}&apiProvider=${apiProvider}" "${hosturl}${args}/subscriptions?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/common.sh b/bin/common.sh index 2805918..0d0b7a9 100755 --- a/bin/common.sh +++ b/bin/common.sh @@ -36,7 +36,7 @@ fi # versioning info version="v2" -release="2.2.11" +release="2.1.10" revision="" if [ -e "$DIR/../.git" ]; then @@ -99,7 +99,7 @@ function out() { if (( pipe )); then echo "$@" else - printf "%b\n" "$message"; + printf '%b\n' "$message"; fi } function die() { out "$@"; exit 1; } >&2 @@ -111,7 +111,7 @@ function err() { response=$(get_xml_message "$1") response=`json_prettyify $(to_json_error_message "$response")` else - response="$@" + response=$@ fi if (($verbose)); then @@ -140,7 +140,7 @@ function success() { } function version() { - out "Agave Platform ${release} + out "iPlant Agave API ${release} Agave CLI (revision ${revision}) " } @@ -177,7 +177,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } function disclaimer() { - out "Documentation on the Agave Platform, client libaries, and developer tools are + out "Documentation on the Agave API, client libaries, and developer tools is available online from the Agave Website, http://developer.agaveapi.co. For localized help of the various CLI commands, run any command with the -h or --help option. @@ -190,20 +190,6 @@ function log() { (($verbose)) && out "$@"; } # Notify on function success function notify() { [[ $? == 0 ]] && success "$@" || err "$@"; } -# prints warning informing client keys are missing -function error_no_client() { - err 'No client keys found. You may provide your client keys in one of 3 ways: - - 1. Add your client key and client secret to your session cache using the auth-switch command. - 2. Add them as arguments to this command using the -k/--apikey and -s/--apisecret options. - 3. Define them in your environment as AGAVE_CLIENT_KEY and AGAVE_CLIENT_SECRET. - -If you have not yet generated a set of client keys, you can do so using the clients-create command. - - clients-create --apiusername $AGAVE_USERNAME --apipassword $AGAVE_PASSWORD --storeclient -' -} - # Escape a string function escape() { echo $@ | sed 's/\//\\\//g'; } @@ -222,7 +208,7 @@ function rollback() { } function getIpAddress() { - curl http://myip.dnsomatic.com + agave-curl http://myip.dnsomatic.com } function jsonval { @@ -287,10 +273,6 @@ function to_json_error_message() { } -function variable_with_name_exists_but_empty() { - [[ -z $$1 && ${$1+x} ]] && echo 1 -} - function trim() { local var="$*" var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters @@ -298,7 +280,7 @@ function trim() { echo -n "$var" } -# Adds the pagination params to each curl call by checking and formatting the url query +# Adds the pagination params to each agave-curl call by checking and formatting the url query # values associated with the $limit, $offset, and $filter variables common to all scripts. function pagination { @@ -438,6 +420,8 @@ function jsonquery { elif [[ 'python' == "$AGAVE_JSON_PARSER" ]]; then + echo "common/jsonquery/python" + [[ -z "$3" ]] && stripquotes='-s' echo "${1}" | python $DIR/python2/pydotjson.py -q ${2} $stripquotes @@ -540,29 +524,24 @@ function prompt_options() { [[ ! "$desc" ]] && continue #echo -n "$desc: " - + # In case this is a password field, hide the user input if [[ $val == "apikey" ]]; then - if [[ -n "$AGAVE_CLIENT_KEY" ]]; then - savedapikey="$AGAVE_CLIENT_KEY" - else - jsonval savedapikey "${tokenstore}" "apikey" - fi - - if [[ -n "$savedapikey" ]]; then - apikey=$savedapikey - else - - echo -n "API key [$savedapikey]: " - eval "read $val" - if [[ -z $apikey ]]; then - apikey=$savedapikey - fi - fi + jsonval savedapikey "${tokenstore}" "apikey" + if [[ -n "$force" ]]; then + apikey=$savedapikey + else + echo -n "API key [$savedapikey]: " + eval "read $val" + if [[ -z $apikey ]]; then + apikey=$savedapikey + fi + #stty -echo; read apikey; stty echo + #echo + fi elif [[ $val == "refresh_token" ]]; then - jsonval savedrefreshtoken "${tokenstore}" "refresh_token" - - if ((force)) || [[ -n "$savedrefreshtoken" ]]; then + jsonval savedrefreshtoken "${tokenstore}" "refresh_token" + if [[ -n "$force" ]]; then refresh_token=$savedrefreshtoken else echo -n "Refresh token [$savedrefreshtoken]: " @@ -574,13 +553,8 @@ function prompt_options() { #echo fi elif [[ $val == "apisecret" ]]; then - if [[ -n "$AGAVE_CLIENT_SECRET" ]]; then - savedapisecret="$AGAVE_CLIENT_SECRET" - else - jsonval savedapisecret "${tokenstore}" "apisecret" - fi - - if [[ -n "$savedapisecret" ]]; then + jsonval savedapisecret "${tokenstore}" "apisecret" + if [[ -n "$force" ]]; then apisecret=$savedapisecret else echo -n "API secret [$savedapisecret]: " @@ -590,81 +564,44 @@ function prompt_options() { fi fi elif [[ $val == "username" ]]; then - if [[ -n "$AGAVE_USERNAME" ]]; then - savedusername="$AGAVE_USERNAME" - else - jsonval savedusername "${tokenstore}" "username" - fi - - # username option is required, but not explicitly provided - # If it exists in the environment, use it and skip the prompt - # environment - if ((force)); then + jsonval savedusername "${tokenstore}" "username" + if [[ -n "$force" ]]; then username=$savedusername else echo -n "API username [$savedusername]: " eval "read $val" if [[ -z $username ]]; then - username=$savedusername + username=$savedusername fi fi - elif [[ $val == "apiusername" ]]; then - if [[ -n "$AGAVE_USERNAME" ]]; then - savedusername="$AGAVE_USERNAME" - else - jsonval savedusername "${tokenstore}" "username" - fi - - # api username option is required, but not explicitly provided - # If it exists in the environment, use it and skip the prompt - # environment - if [[ -n "$savedusername" ]]; then - apiusername=$savedusername - else - echo -n "API username [$savedusername]: " - eval "read $val" - if [[ -z $username ]]; then - apiusername=$savedusername - fi - fi elif [[ $val == "password" ]]; then - if ((force)) || [[ -n "$AGAVE_PASSWORD" ]]; then - password="$AGAVE_PASSWORD" - else - echo -n "API password: " - stty -echo; read "password"; stty echo - echo -n " + echo -n "API password: " + stty -echo; read "password"; stty echo + echo -n " "; - fi elif [[ $val == "apipassword" ]]; then - if ((force)) || [[ -n "$AGAVE_PASSWORD" ]]; then - apipassword="$AGAVE_PASSWORD" - else - echo -n "API password: " - stty -echo; read "apipassword"; stty echo - echo -n " + echo -n "API password: " + stty -echo; read "apipassword"; stty echo + echo -n " "; - fi # Otherwise just read the input else - echo -n "$desc: " - eval "read $val" + echo -n "$desc: " + eval "read $val" fi done } function get_auth_header() { + export bearer="Bearer $access_token" + export password if [[ "$development" -ne 1 ]]; then - if [[ -n "$AGAVE_ACCESS_TOKEN" ]]; then - echo "Authorization: Bearer $AGAVE_ACCESS_TOKEN" - else - echo "Authorization: Bearer $access_token" - fi - else + export authheader="Authorization:"'$bearer' + else if [[ -f "$DIR/auth-filter.sh" ]]; then - echo $(source $DIR/auth-filter.sh); + source $DIR/auth-filter.sh else - echo " -u \"${username}:${password}\" " + export authheader=" -u '${username}:${password}' " fi fi } @@ -746,6 +683,7 @@ function json_prettyify { if [[ 'python' == "$AGAVE_JSON_PARSER" ]]; then echo "$@" | python $DIR/python2/pydotjson.py + #echo -n "$@" | python -mjson.tool elif [[ 'jq' == "$AGAVE_JSON_PARSER" ]]; then @@ -758,7 +696,7 @@ function json_prettyify { # If all else fails, we can use the jsonparser api #elif [[ -z "$AGAVE_JSON_PARSER" -o 'json-mirror' == "$AGAVE_JSON_PARSER" ]]; then else - jsonparserresponse=$(echo "${1}" | curl -sk --globoff -X POST -H "Content-Type: application/json" --data-binary @- "https://agaveapi.co/json-mirror?pretty=true") + jsonparserresponse=$(echo "${1}" | agave-curl -sk --globoff -X POST -H "Content-Type: application/json" --data-binary @- "https://agaveapi.co/json-mirror?pretty=true") if [ $? ]; then echo -e "${jsonparserresponse}" @@ -768,14 +706,10 @@ function json_prettyify { fi } -# -# Refresh the current user token cached in $AGAVE_CACHE_DIR/current. This function can be -# enabled at any time by setting the $AGAVE_ENABLE_AUTO_REFRESH environment variable. -# Refresh will be skipped silently if the client key, secret, or refresh token are missing. -# -function auto_auth_refresh -{ - if [[ -z "$AGAVE_ACCESS_TOKEN" ]] && [[ -n "$AGAVE_ENABLE_AUTO_REFRESH" ]]; +function auto_auth_refresh { + + AGAVE_DISABLE_AUTO_REFRESH=1 + if [[ -z "$AGAVE_DISABLE_AUTO_REFRESH" ]]; then # ignore the refresh if the api keys or refresh token are not present in the cache. if [[ -n "$baseurl" ]] && [[ -n "$apikey" ]] && [[ -n "$apisecret" ]] && [[ -n "$refresh_token" ]]; @@ -785,9 +719,10 @@ function auto_auth_refresh __hosturl=${__hosturl}/token __post_options="grant_type=refresh_token&refresh_token=${refresh_token}&scope=PRODUCTION" - response=`curl -sku "$apikey:$apisecret" -X POST -d "${__post_options}" -H "Content-Type:application/x-www-form-urlencoded" "$__hosturl"` + export apisecret + response=`agave-curl -sku "$apikey:\$apisecret" -X POST -d "${__post_options}" -H "Content-Type:application/x-www-form-urlencoded" "$__hosturl"` - # check response code. if curl exited with a non 200 code, the operation failed + # check response code. if agave-curl exited with a non 200 code, the operation failed if [[ ! $? ]] && (($verbose)); then err "Unable to refresh token. If you do not update your token manually using the auth-tokens-refresh command, token refresh will be attempted again prior to your next request." @@ -860,17 +795,16 @@ function richify { oldIFS="$IFS" IFS=$'\n' - + # Cut down very long responses so they fit in a table + max_length="45" # the rest of the parameters in $@ are fields to parse for params in "${richargs[@]}"; do # save parameter names for table header - #return_string="$return_string $params\t| " return_string="$return_string $params | " # dynamically create table divider - #return_string_divider="$return_string_divider ${params//[A-Za-z0-9\[\]\.]/-}\t| " return_string_divider="$return_string_divider ${params//[A-Za-z0-9\[\]\.]/-} | " # grab array of values from json response @@ -888,7 +822,7 @@ function richify { # Parse times into something friendly if [[ "$results" != "null" ]]; then - if [[ "$params" == "lastModified" || "$params" == "lastUpdated" || "$params" == "created" || "$params" =~ /.*Time$/ || "$params" =~ /.*At$/ || "$params" =~ /.*Date$/ ]]; then + if [[ "$params" == "lastModified" || "$params" == "lastUpdated" || "$params" == "lastSuccess" || "$params" == "created" || "$params" == "expires" || "$params" =~ /.*Time$/ || "$params" =~ /.*At$/ || "$params" =~ /.*Date$/ ]]; then # break date formatting out to its own function so we can # consistently reuse it across the cli results[$i]=$(format_iso8601_date_and_time "${results[$i]}" 1) @@ -896,6 +830,11 @@ function richify { fi fi + if [[ "${#results[$i]}" -gt "$max_length" ]]; then + results[$i]=${results[$i]:0:${max_length}} + results[$i]="${results[$i]}..." + fi + array_of_values[$n]="${results[$i]}" n=$(expr $n + 1) done @@ -923,6 +862,11 @@ function richify { function columnize { + python $DIR/python2/richtext.py $@ + +} + +function columnize_old { # # Use awk to put rich text with pipe '|' separators into column format # (This replaces the bash 'column' command because 'column' is not @@ -944,6 +888,7 @@ function columnize { END { for (j=2; j<=numcol+1; j++) printf "%d%s", maxchar[j], " " + #printf "|%*-s", maxchar[j], $j }' ) ) # Printf each column with width based on maximum length @@ -1087,4 +1032,4 @@ function humanizeBytes() { } } {sub(/^[0-9]+/, readable($1)); print}' -} \ No newline at end of file +} diff --git a/bin/files-copy b/bin/files-copy index 21ae591..4a1b7c8 100755 --- a/bin/files-copy +++ b/bin/files-copy @@ -65,13 +65,13 @@ main() { filesurl="${hosturl}media/${args}?pretty=true" fi - cmd="curl -sk -H \"${authheader}\" -X PUT -d \"action=copy&path=${destination}\" '${filesurl}'" + cmd="agave-curl -sk -H \"${authheader}\" -X PUT -d \"action=copy&path=${destination}\" '${filesurl}'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X PUT -d "action=copy&path=${destination}" "${filesurl}"` + response=`agave-curl -sk -H "${authheader}" -X PUT -d "action=copy&path=${destination}" "${filesurl}"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/files-delete b/bin/files-delete index 6f37529..b04c0aa 100755 --- a/bin/files-delete +++ b/bin/files-delete @@ -64,13 +64,13 @@ main() { filesurl="${hosturl}media/${args}?pretty=true" fi - cmd="curl -sk -H \"${authheader}\" -X DELETE '${filesurl}'" + cmd="agave-curl -sk -H \"${authheader}\" -X DELETE '${filesurl}'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X DELETE "${filesurl}"` + response=`agave-curl -sk -H "${authheader}" -X DELETE "${filesurl}"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/files-get b/bin/files-get index 476a07e..4376a43 100755 --- a/bin/files-get +++ b/bin/files-get @@ -105,7 +105,7 @@ main() { fileslistingurl="${hosturl}listings/${args}" fi - response=`curl -sk -H "${authheader}" "${fileslistingurl%/}"` + response=`agave-curl -sk -H "${authheader}" "${fileslistingurl%/}"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then @@ -202,7 +202,7 @@ main() { else # set -x - cmd="curl -k -H \"${authheader}\" ${filerange} ${outputarg} '${filesurl}'" + cmd="agave-curl -k -H \"${authheader}\" ${filerange} ${outputarg} '${filesurl}'" if ((veryverbose)); then @@ -220,7 +220,7 @@ main() { [ "$piped" -eq 0 ] && out "Downloading $args ..." fi - curl -# -k -H "${authheader}" ${filerange} ${outputarg} "${filesurl}" + agave-curl -# -k -H "${authheader}" ${filerange} ${outputarg} "${filesurl}" if [ "$?" -eq 0 ] && [ ! -f "$filename" ]; then if ((verbose)); then diff --git a/bin/files-history b/bin/files-history index 935f5a1..68ca5be 100755 --- a/bin/files-history +++ b/bin/files-history @@ -63,14 +63,14 @@ main() { hosturl="${hosturl}history/${args}?pretty=true$(pagination)" fi - cmd="curl -sk -H \"${authheader}\" '${hosturl}'" + cmd="agave-curl -sk -H \"${authheader}\" '${hosturl}'" if ((veryverbose)); then version; [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "${hosturl}"` + response=`agave-curl -sk -H "${authheader}" "${hosturl}"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/files-import b/bin/files-import index 1a673d3..67b23a1 100755 --- a/bin/files-import +++ b/bin/files-import @@ -87,13 +87,13 @@ main() { hosturl="${hosturl}media/" fi - cmd="curl -sk -H \"${authheader}\" -X POST --data-urlencode \"urlToIngest=${urltoingest}\" --data-urlencode \"notifications=${webhook}\" --data-urlencode \"fileType=${filetype}\" --data-urlencode \"fileName=${filename}\" '$hosturl$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X POST --data-urlencode \"urlToIngest=${urltoingest}\" --data-urlencode \"notifications=${webhook}\" --data-urlencode \"fileType=${filetype}\" --data-urlencode \"fileName=${filename}\" '$hosturl$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X POST --data-urlencode "urlToIngest=${urltoingest}" --data-urlencode "notifications=${webhook}" --data-urlencode "fileName=${filename}" --data-urlencode "fileType=${filetype}" --data-urlencode "fileName=${filename}" "$hosturl$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X POST --data-urlencode "urlToIngest=${urltoingest}" --data-urlencode "notifications=${webhook}" --data-urlencode "fileName=${filename}" --data-urlencode "fileType=${filetype}" --data-urlencode "fileName=${filename}" "$hosturl$args?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/files-index b/bin/files-index index 3956fbe..d19c5be 100755 --- a/bin/files-index +++ b/bin/files-index @@ -68,13 +68,13 @@ main() { hosturl="${hosturl}index/" fi - cmd="curl -sk -H \"${authheader}\" '${hosturl}${args}?pretty=true$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" '${hosturl}${args}?pretty=true$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "${hosturl}${args}?pretty=true$(pagination)"` + response=`agave-curl -sk -H "${authheader}" "${hosturl}${args}?pretty=true$(pagination)"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/files-list b/bin/files-list index 97adfca..7921a59 100755 --- a/bin/files-list +++ b/bin/files-list @@ -65,13 +65,13 @@ main() { hosturl="${hosturl}listings/${args}" fi - cmd="curl -sk -H \"${authheader}\" '${hosturl}?pretty=true$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" '${hosturl}?pretty=true$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "${hosturl}?pretty=true$(pagination)"` + response=`agave-curl -sk -H "${authheader}" "${hosturl}?pretty=true$(pagination)"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/files-mkdir b/bin/files-mkdir index 513b4dd..018c645 100755 --- a/bin/files-mkdir +++ b/bin/files-mkdir @@ -61,13 +61,13 @@ main() { hosturl="${hosturl}media/" fi - cmd="curl -sk -H \"${authheader}\" -X PUT -d \"action=mkdir&path=${name}\" '${hosturl}${args}?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X PUT -d \"action=mkdir&path=${name}\" '${hosturl}${args}?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X PUT -d "action=mkdir&path=${name}" "${hosturl}${args}?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X PUT -d "action=mkdir&path=${name}" "${hosturl}${args}?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/files-move b/bin/files-move index 9f5d8b5..934fe61 100755 --- a/bin/files-move +++ b/bin/files-move @@ -67,13 +67,13 @@ main() { hosturl="${hosturl}media/" fi - cmd="curl -sk -H \"${authheader}\" -X PUT -d \"action=move&path=${destination}\" '${hosturl}${args}?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X PUT -d \"action=move&path=${destination}\" '${hosturl}${args}?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X PUT -d "action=move&path=${destination}" "${hosturl}${args}?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X PUT -d "action=move&path=${destination}" "${hosturl}${args}?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/files-pems-delete b/bin/files-pems-delete index 6599ce3..aee1df9 100755 --- a/bin/files-pems-delete +++ b/bin/files-pems-delete @@ -69,13 +69,13 @@ main() { hosturl="${hosturl}pems/" fi - cmd="curl -sk -H \"${authheader}\" -X DELETE '${hosturl}${args}?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X DELETE '${hosturl}${args}?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X DELETE "${hosturl}${args}?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X DELETE "${hosturl}${args}?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/files-pems-list b/bin/files-pems-list index 057a6f8..3ebf443 100755 --- a/bin/files-pems-list +++ b/bin/files-pems-list @@ -72,13 +72,13 @@ main() { searchterms="${searchterms}&permission.eq=$permission" fi - cmd="curl -sk -H \"${authheader}\" '${hosturl}${args}?pretty=true${searchterms}$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" '${hosturl}${args}?pretty=true${searchterms}$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "${hosturl}${args}?pretty=true${searchterms}$(pagination)"` + response=`agave-curl -sk -H "${authheader}" "${hosturl}${args}?pretty=true${searchterms}$(pagination)"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then format_api_json "$response" diff --git a/bin/files-pems-update b/bin/files-pems-update index bd813c2..c007aa9 100755 --- a/bin/files-pems-update +++ b/bin/files-pems-update @@ -81,13 +81,13 @@ main() { recursive="false"; fi - cmd="curl -sk -H \"${authheader}\" -X POST -d \"username=${pemusername}&permission=${permission}&recursive=${recursive}\" '${hosturl}${args}?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X POST -d \"username=${pemusername}&permission=${permission}&recursive=${recursive}\" '${hosturl}${args}?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X POST -d "username=${pemusername}&permission=${permission}&recursive=${recursive}" "${hosturl}${args}?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X POST -d "username=${pemusername}&permission=${permission}&recursive=${recursive}" "${hosturl}${args}?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/files-rename b/bin/files-rename index 3d6be74..8f04188 100755 --- a/bin/files-rename +++ b/bin/files-rename @@ -65,13 +65,13 @@ main() { hosturl="${hosturl}media/" fi - cmd="curl -sk -H \"${authheader}\" -X PUT -d \"action=rename&path=${name}\" '$hosturl${args}?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X PUT -d \"action=rename&path=${name}\" '$hosturl${args}?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X PUT -d "action=rename&path=${name}" "${hosturl}${args}?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X PUT -d "action=rename&path=${name}" "${hosturl}${args}?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/files-upload b/bin/files-upload index f50d037..e14b9dd 100755 --- a/bin/files-upload +++ b/bin/files-upload @@ -107,26 +107,26 @@ main() { post_options=${post_options%&} - cmd="curl $quietarg -k -H \"${authheader}\" -X POST -F \"fileToUpload=@$filetoupload\" -F \"${post_options}\" '$hosturl$args?pretty=true'" + cmd="agave-curl $quietarg -k -H \"${authheader}\" -X POST -F \"fileToUpload=@$filetoupload\" -F \"${post_options}\" '$hosturl$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi #response='{"status":"success","response":{},"message":null}' - response=`curl $quietarg -k -H "${authheader}" -X POST -F "fileToUpload=@$filetoupload" -F "${post_options}" "$hosturl$args?pretty=true"` + response=`agave-curl $quietarg -k -H "${authheader}" -X POST -F "fileToUpload=@$filetoupload" -F "${post_options}" "$hosturl$args?pretty=true"` else - cmd="curl $quietarg -k -H \"${authheader}\" -X POST -F \"fileToUpload=@$filetoupload\" '$hosturl$args?pretty=true'" + cmd="agave-curl $quietarg -k -H \"${authheader}\" -X POST -F \"fileToUpload=@$filetoupload\" '$hosturl$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi #response='{"status":"success","response":{},"message":null}' - response=`curl $quietarg -k -H "${authheader}" -X POST -F "fileToUpload=@$filetoupload" "$hosturl$args?pretty=true"` + response=`agave-curl $quietarg -k -H "${authheader}" -X POST -F "fileToUpload=@$filetoupload" "$hosturl$args?pretty=true"` fi - # if the file is coming from stdin, verify we have a filename and feed it to curl + # if the file is coming from stdin, verify we have a filename and feed it to agave-curl elif [[ "$filetoupload" == "-" ]]; then if [[ -z "$filename" ]]; then @@ -140,23 +140,23 @@ main() { post_options=${post_options%&} - cmd="curl $quietarg -k -H \"${authheader}\" -X POST -F \"fileToUpload=@-\" -F \"${post_options}\" '$hosturl$args?pretty=true'" + cmd="agave-curl $quietarg -k -H \"${authheader}\" -X POST -F \"fileToUpload=@-\" -F \"${post_options}\" '$hosturl$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi #response='{"status":"success","response":{},"message":null}' - response=`curl $quietarg -k -H "${authheader}" -X POST -F "fileToUpload=@-" -F "${post_options}" "$hosturl$args?pretty=true"` + response=`agave-curl $quietarg -k -H "${authheader}" -X POST -F "fileToUpload=@-" -F "${post_options}" "$hosturl$args?pretty=true"` else - cmd="curl $quietarg -k -H \"${authheader}\" -X POST -F \"fileToUpload=@-\" '$hosturl$args?pretty=true'" + cmd="agave-curl $quietarg -k -H \"${authheader}\" -X POST -F \"fileToUpload=@-\" '$hosturl$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi #response='{"status":"success","response":{},"message":null}' - response=`curl $quietarg -k -H "${authheader}" -X POST -F "fileToUpload=@-" "$hosturl$args?pretty=true"` + response=`agave-curl $quietarg -k -H "${authheader}" -X POST -F "fileToUpload=@-" "$hosturl$args?pretty=true"` fi @@ -233,8 +233,8 @@ main() { else hosturl="${baseurl}listings/${newdirpath}" fi - #echo "Calling curl -sk -H ${authheader} \"${hosturl%/}?pretty=true\"" - response=`curl -sk -H "${authheader}" "${hosturl%/}?pretty=true"` + #echo "Calling agave-curl -sk -H ${authheader} \"${hosturl%/}?pretty=true\"" + response=`agave-curl -sk -H "${authheader}" "${hosturl%/}?pretty=true"` fi if [[ $(jsonquery "$response" "status") = 'success' ]]; then diff --git a/bin/headers-check b/bin/headers-check index 457e3fe..3ea44a3 100755 --- a/bin/headers-check +++ b/bin/headers-check @@ -27,7 +27,7 @@ Prints the headers that would be passed to a protected API by the Agave auth ser when presented the current auth token. Options: - -z, --access_token Access token. This will override the value of AGAVE_ACCESS_TOKEN + -z, --access_token Access token --filter Comma separated list of fields to return in the response -H, --hosturl URL of the service -d, --development Run in dev mode using default dev server @@ -57,14 +57,14 @@ main() { else - cmd="curl -sk -H \"${authheader}\" '${hosturl%%/}" + cmd="agave-curl -sk -H \"${authheader}\" '${hosturl%%/}" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi # make sure we specify content type as application/json - response=`curl -sk -H "${authheader}" "${hosturl%%/}"` + response=`agave-curl -sk -H "${authheader}" "${hosturl%%/}"` fi diff --git a/bin/jobs-delete b/bin/jobs-delete index ace589f..45d3c60 100755 --- a/bin/jobs-delete +++ b/bin/jobs-delete @@ -54,13 +54,13 @@ main() { err "Please specify a valid app id to delete" else - cmd="curl -sk -H \"${authheader}\" -X DELETE '$hosturl$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X DELETE '$hosturl$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X DELETE "$hosturl$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X DELETE "$hosturl$args?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/jobs-history b/bin/jobs-history index ea65576..1864118 100755 --- a/bin/jobs-history +++ b/bin/jobs-history @@ -67,13 +67,13 @@ main() { err "Please specify a job for which to fetch the history" else - cmd="curl -sk -H \"${authheader}\" '$hosturl$args/history?pretty=true$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" '$hosturl$args/history?pretty=true$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "${hosturl}${args}/history?pretty=true$(pagination)"` + response=`agave-curl -sk -H "${authheader}" "${hosturl}${args}/history?pretty=true$(pagination)"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then diff --git a/bin/jobs-history-search b/bin/jobs-history-search index 76af2d7..e222010 100755 --- a/bin/jobs-history-search +++ b/bin/jobs-history-search @@ -91,7 +91,7 @@ main() { # pop it off the argument array args=("${args[@]:1}") - # build the curl query arguments from the argument array, properly urlencoding them + # build the agave-curl query arguments from the argument array, properly urlencoding them querystring="" if [ -n "$args" ]; then @@ -101,13 +101,13 @@ main() { done fi - cmd="curl -G -sk -H \"${authheader}\" '${hosturl}${jobid}/history?pretty=true$(pagination)' ${querystring}" + cmd="agave-curl -G -sk -H \"${authheader}\" '${hosturl}${jobid}/history?pretty=true$(pagination)' ${querystring}" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -G -sk -H "${authheader}" ${hosturl}${jobid}/history?pretty=true$(pagination) $querystring` + response=`agave-curl -G -sk -H "${authheader}" ${hosturl}${jobid}/history?pretty=true$(pagination) $querystring` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/jobs-kick b/bin/jobs-kick index 71a8821..ac528ad 100755 --- a/bin/jobs-kick +++ b/bin/jobs-kick @@ -63,13 +63,13 @@ main() { for jobid in "${args[@]}" do - cmd="curl -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X POST --data-binary '{\"action\": \"reset\"}' '$hosturl/$jobid?pretty=true$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X POST --data-binary '{\"action\": \"reset\"}' '$hosturl/$jobid?pretty=true$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -H "Content-Type: application/json" -X POST --data-binary '{"action":"reset"}' "$hosturl/$jobid?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -H "Content-Type: application/json" -X POST --data-binary '{"action":"reset"}' "$hosturl/$jobid?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/jobs-list b/bin/jobs-list index 4021e74..c622382 100755 --- a/bin/jobs-list +++ b/bin/jobs-list @@ -75,13 +75,13 @@ main() { querystring="${querystring}&status=$status" fi - cmd="curl -sk -H \"${authheader}\" '$jobsurl?${querystring}$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" '$jobsurl?${querystring}$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "$jobsurl?${querystring}$(pagination)"` + response=`agave-curl -sk -H "${authheader}" "$jobsurl?${querystring}$(pagination)"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/jobs-output-get b/bin/jobs-output-get index a718480..3c1e6c7 100755 --- a/bin/jobs-output-get +++ b/bin/jobs-output-get @@ -109,7 +109,7 @@ main() { fileslistingurl="$hosturl${jobid}/outputs/listings/${path}" - response=`curl -sk -H "${authheader}" "${fileslistingurl}"` + response=`agave-curl -sk -H "${authheader}" "${fileslistingurl}"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then @@ -235,7 +235,7 @@ main() { else - cmd="curl -k -H \"${authheader}\" ${filerange} ${outputarg} '${filesurl}'" + cmd="agave-curl -k -H \"${authheader}\" ${filerange} ${outputarg} '${filesurl}'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" @@ -249,7 +249,7 @@ main() { [ "$piped" -eq 0 ] && out "Downloading ${path} ..." fi - curl -# -k -H "${authheader}" ${filerange} ${outputarg} "${filesurl}" + agave-curl -# -k -H "${authheader}" ${filerange} ${outputarg} "${filesurl}" #touch $filename if [ "$?" -eq 0 ] && [ ! -f "$filename" ]; then diff --git a/bin/jobs-output-list b/bin/jobs-output-list index 4a1b52d..b495d92 100755 --- a/bin/jobs-output-list +++ b/bin/jobs-output-list @@ -65,13 +65,13 @@ main() { jobid=${args[0]} path=${args[1]} - cmd="curl -sk -H \"${authheader}\" '${hosturl}${jobid}/outputs/listings/${path}?pretty=true$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" '${hosturl}${jobid}/outputs/listings/${path}?pretty=true$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "${hosturl}${jobid}/outputs/listings/${path}?pretty=true$(pagination)"` + response=`agave-curl -sk -H "${authheader}" "${hosturl}${jobid}/outputs/listings/${path}?pretty=true$(pagination)"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/jobs-pems-list b/bin/jobs-pems-list index e5ffcf7..34f8ed9 100755 --- a/bin/jobs-pems-list +++ b/bin/jobs-pems-list @@ -59,13 +59,13 @@ main() { err "Please specify a valid app id for which to retrieve permissions" else - cmd="curl -sk -H \"${authheader}\" '$hosturl$args/pems/$apiusername?pretty=true$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" '$hosturl$args/pems/$apiusername?pretty=true$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "$hosturl$args/pems/$apiusername?pretty=true$(pagination)"` + response=`agave-curl -sk -H "${authheader}" "$hosturl$args/pems/$apiusername?pretty=true$(pagination)"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/jobs-pems-update b/bin/jobs-pems-update index cc649ea..265134d 100755 --- a/bin/jobs-pems-update +++ b/bin/jobs-pems-update @@ -59,13 +59,13 @@ main() { if [ -z "$args" ]; then err "Please specify a job for which to set the permissions" else - cmd="curl -sk -H \"${authheader}\" -X POST -d \"permission=$permission\" '$hosturl$args/pems/$apiusername?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X POST -d \"permission=$permission\" '$hosturl$args/pems/$apiusername?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X POST -d "permission=$permission" "$hosturl$args/pems/$apiusername?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X POST -d "permission=$permission" "$hosturl$args/pems/$apiusername?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/jobs-restore b/bin/jobs-restore index 76f4bf6..b8a1d2d 100755 --- a/bin/jobs-restore +++ b/bin/jobs-restore @@ -59,13 +59,13 @@ main() { for jobid in "${args[@]}" do - cmd="curl -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X POST --data-binary '{\"action\": \"restore\"}' '$hosturl/$jobid?pretty=true$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X POST --data-binary '{\"action\": \"restore\"}' '$hosturl/$jobid?pretty=true$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -H "Content-Type: application/json" -X POST --data-binary '{"action":"restore"}' "$hosturl/$jobid?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -H "Content-Type: application/json" -X POST --data-binary '{"action":"restore"}' "$hosturl/$jobid?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/jobs-resubmit b/bin/jobs-resubmit index 4ef5253..3b6a28f 100755 --- a/bin/jobs-resubmit +++ b/bin/jobs-resubmit @@ -77,13 +77,13 @@ main() { strictparams='false' fi - cmd="curl -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X POST --data-binary '{ \"action\": \"resubmit\", \"ignoreInputConflicts\": $strictinputs, \"ignoreParameterConflicts\": $strictparams }' '$hosturl$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X POST --data-binary '{ \"action\": \"resubmit\", \"ignoreInputConflicts\": $strictinputs, \"ignoreParameterConflicts\": $strictparams }' '$hosturl$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -H "Content-Type: application/json" -X POST --data-binary '{"action": "resubmit", "ignoreInputConflicts": '$strictinputs', "ignoreParameterConflicts": '$strictparams' }' "$hosturl$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -H "Content-Type: application/json" -X POST --data-binary '{"action": "resubmit", "ignoreInputConflicts": '$strictinputs', "ignoreParameterConflicts": '$strictparams' }' "$hosturl$args?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then diff --git a/bin/jobs-run-this b/bin/jobs-run-this index c2e8037..380b38e 100755 --- a/bin/jobs-run-this +++ b/bin/jobs-run-this @@ -166,7 +166,7 @@ main() { fi # Now fetch the file - dockerfile_response=$(curl --write-out %{http_code} -sk -o "${workdir}/Dockerfile.download" "$dockerfile") + dockerfile_response=$(agave-curl --write-out %{http_code} -sk -o "${workdir}/Dockerfile.download" "$dockerfile") if [ "$dockerfile_response" -ne 200 ]; then err "Download failed. Job submission aborted." @@ -190,7 +190,7 @@ main() { if [ -n "$dockerimage" ]; then # verify the docker image exists out "Verifying Docker image $dockerimage exists..." - imagecheck_response=$(curl -sk "https://index.docker.io/v1/search?q=${dockerimage}") + imagecheck_response=$(agave-curl -sk "https://index.docker.io/v1/search?q=${dockerimage}") if [ $? ]; then image_results=$(jsonquery "$imagecheck_response" "num_results"); @@ -289,10 +289,10 @@ main() { # Create a job description and submit the job out "Submitting job..." if ((veryverbose)); then - log "curl -sk -H \"${authheader}\" -H \"Content-type: application/json\" -X POST --data \"{ \"appId\":\"cloud-runner-0.1.0u1\", \"name\": \"$name\",\"inputs\": { \"appBundle\":\"$appbundleparam\" }, \"parameters\": { \"unpackInputs\": true$dockerimageparam, \"command\":\"$command\", \"commandArgs\":\"${args[@]}\" }${notifications}${archiveparam}}\" $hosturl?pretty=true" + log "agave-curl -sk -H \"${authheader}\" -H \"Content-type: application/json\" -X POST --data \"{ \"appId\":\"cloud-runner-0.1.0u1\", \"name\": \"$name\",\"inputs\": { \"appBundle\":\"$appbundleparam\" }, \"parameters\": { \"unpackInputs\": true$dockerimageparam, \"command\":\"$command\", \"commandArgs\":\"${args[@]}\" }${notifications}${archiveparam}}\" $hosturl?pretty=true" fi - response=`curl -sk -H "${authheader}" -H "Content-type: application/json" -X POST --data "{ \"appId\":\"cloud-runner-0.1.0u1\", \"name\": \"$name\",\"inputs\": { \"appBundle\":\"$appbundleparam\" }, \"parameters\": { \"unpackInputs\": true$dockerimageparam, \"command\":\"$command\", \"commandArgs\":\"${args[@]}\" }${notifications}${archiveparam}}" "$hosturl?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -H "Content-type: application/json" -X POST --data "{ \"appId\":\"cloud-runner-0.1.0u1\", \"name\": \"$name\",\"inputs\": { \"appBundle\":\"$appbundleparam\" }, \"parameters\": { \"unpackInputs\": true$dockerimageparam, \"command\":\"$command\", \"commandArgs\":\"${args[@]}\" }${notifications}${archiveparam}}" "$hosturl?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then diff --git a/bin/jobs-search b/bin/jobs-search index c226297..6295d07 100755 --- a/bin/jobs-search +++ b/bin/jobs-search @@ -118,13 +118,13 @@ main() { done fi - cmd="curl -G -sk -H \"${authheader}\" '$jobsurl?pretty=true$(pagination)' ${querystring}" + cmd="agave-curl -G -sk -H \"${authheader}\" '$jobsurl?pretty=true$(pagination)' ${querystring}" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -G -sk -H "${authheader}" $jobsurl?pretty=true$(pagination) $querystring` + response=`agave-curl -G -sk -H "${authheader}" $jobsurl?pretty=true$(pagination) $querystring` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/jobs-status b/bin/jobs-status index 8222e55..fd841b9 100755 --- a/bin/jobs-status +++ b/bin/jobs-status @@ -63,13 +63,13 @@ main() { hosturl="$hosturl/$args/status" - cmd="curl -sk -H \"${authheader}\" '$hosturl?pretty=true$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" '$hosturl?pretty=true$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "$hosturl?pretty=true$(pagination)"` + response=`agave-curl -sk -H "${authheader}" "$hosturl?pretty=true$(pagination)"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/jobs-stop b/bin/jobs-stop index 3dcc643..6b340e7 100755 --- a/bin/jobs-stop +++ b/bin/jobs-stop @@ -54,13 +54,13 @@ main() { if [ -z "$args" ]; then err "Please specify a job id to stop" else - cmd="curl -sk -H \"${authheader}\" -X POST -d \"action=stop\" '$hosturl$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X POST -d \"action=stop\" '$hosturl$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X POST -d "action=stop" "$hosturl$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X POST -d "action=stop" "$hosturl$args?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/jobs-submit b/bin/jobs-submit index 5a6d182..b4c1e62 100755 --- a/bin/jobs-submit +++ b/bin/jobs-submit @@ -75,25 +75,25 @@ main() { # reading from stdin if [[ "$filetoupload" == "-" ]]; then - cmd="curl -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X POST --data-binary @- '$hosturl?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X POST --data-binary @- '$hosturl?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi # make sure we specify content type as application/json - response=`curl -sk -H "${authheader}" -H "Content-Type: application/json" -X POST --data-binary @- "$hosturl?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -H "Content-Type: application/json" -X POST --data-binary @- "$hosturl?pretty=true"` # standard file upload else - cmd="curl -sk -H \"${authheader}\" -X POST -d \"fileToUpload=@$filetoupload\" '$hosturl?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X POST -d \"fileToUpload=@$filetoupload\" '$hosturl?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X POST -F "fileToUpload=@$filetoupload" "$hosturl?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X POST -F "fileToUpload=@$filetoupload" "$hosturl?pretty=true"` fi diff --git a/bin/jobs-tail b/bin/jobs-tail index 135eec7..4f177c2 100755 --- a/bin/jobs-tail +++ b/bin/jobs-tail @@ -64,13 +64,13 @@ main() if [[ $rich -eq 1 ]]; then for jobid in "${args[@]}" do - cmd="curl -sk -H \"${authheader}\" '${hosturl}/${jobid}/history?limit=1&filter=progress&order=desc&status.in=ARCHIVING,STAGING_INPUTS'" + cmd="agave-curl -sk -H \"${authheader}\" '${hosturl}/${jobid}/history?limit=1&filter=progress&order=desc&status.in=ARCHIVING,STAGING_INPUTS'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - singleresponse=`curl -sk -H "${authheader}" "${hosturl}/${jobid}/history?limit=1&filter=progress&order=desc&status.in=ARCHIVING,STAGING_INPUTS"` + singleresponse=`agave-curl -sk -H "${authheader}" "${hosturl}/${jobid}/history?limit=1&filter=progress&order=desc&status.in=ARCHIVING,STAGING_INPUTS"` done if [[ $(jsonquery "$response" "status") = 'success' ]]; then @@ -84,13 +84,13 @@ main() for jobid in "${args[@]}" do - cmd="curl -sk -H \"${authheader}\" '${hosturl}/${jobid}/history?pretty=true&limit=1&filter=progress&order=desc&status.in=ARCHIVING,STAGING_INPUTS'" + cmd="agave-curl -sk -H \"${authheader}\" '${hosturl}/${jobid}/history?pretty=true&limit=1&filter=progress&order=desc&status.in=ARCHIVING,STAGING_INPUTS'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "${hosturl}/${jobid}/history?pretty=true&limit=1&filter=progress&order=desc&status.in=ARCHIVING,STAGING_INPUTS"` + response=`agave-curl -sk -H "${authheader}" "${hosturl}/${jobid}/history?pretty=true&limit=1&filter=progress&order=desc&status.in=ARCHIVING,STAGING_INPUTS"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/json-mirror.sh b/bin/json-mirror.sh index 404878e..ba6595d 100755 --- a/bin/json-mirror.sh +++ b/bin/json-mirror.sh @@ -7,7 +7,7 @@ # Bash client to the Agave json-mirror api. # @see https://bitbucket.org/taccaci/agave-json-mirror # -response=$(echo "${1}" | curl -sk --globoff -X POST -H "Content-Type: application/json" --data-binary @- "https://agaveapi.co/json-mirror?q=${2}") +response=$(echo "${1}" | agave-curl -sk --globoff -X POST -H "Content-Type: application/json" --data-binary @- "https://agaveapi.co/json-mirror?q=${2}") if [[ -n "$3" ]]; then #echo "${response}" | sed 's/^[ \t]*//g' | sed 's/\"//g' diff --git a/bin/metadata-addupdate b/bin/metadata-addupdate index abb8088..f593149 100755 --- a/bin/metadata-addupdate +++ b/bin/metadata-addupdate @@ -76,25 +76,25 @@ main() { # reading from stdin if [[ "$filetoupload" == "-" ]]; then - cmd="curl -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X POST --data-binary @- '${hosturl}data/${args}?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X POST --data-binary @- '${hosturl}data/${args}?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi # make sure we specify content type as application/json - response=`curl -sk -H "${authheader}" -H "Content-Type: application/json" -X POST --data-binary @- "${hosturl}data/${args}?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -H "Content-Type: application/json" -X POST --data-binary @- "${hosturl}data/${args}?pretty=true"` # standard file upload else - cmd="curl -sk -H \"${authheader}\" -X POST -F \"fileToUpload=@${filetoupload}\" '${hosturl}data/${args}?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X POST -F \"fileToUpload=@${filetoupload}\" '${hosturl}data/${args}?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X POST -F "fileToUpload=@${filetoupload}" "${hosturl}data/${args}?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X POST -F "fileToUpload=@${filetoupload}" "${hosturl}data/${args}?pretty=true"` fi diff --git a/bin/metadata-delete b/bin/metadata-delete index c9fc5b6..d4a5ed5 100755 --- a/bin/metadata-delete +++ b/bin/metadata-delete @@ -56,13 +56,13 @@ main() { err "Please specify a valid metadata object id to delete" else - cmd="curl -sk -H \"${authheader}\" -X DELETE '${hosturl}data/${args}?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X DELETE '${hosturl}data/${args}?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X DELETE "${hosturl}data/${args}?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X DELETE "${hosturl}data/${args}?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/metadata-list b/bin/metadata-list index d622c93..9aa3289 100755 --- a/bin/metadata-list +++ b/bin/metadata-list @@ -77,13 +77,13 @@ main() { metaurl="$metaurl&privileged=false" fi - cmd="curl -sk -H \"${authheader}\" '$metaurl$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" '$metaurl$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "$metaurl$(pagination)"` + response=`agave-curl -sk -H "${authheader}" "$metaurl$(pagination)"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/metadata-pems-addupdate b/bin/metadata-pems-addupdate index c297d48..797e70a 100755 --- a/bin/metadata-pems-addupdate +++ b/bin/metadata-pems-addupdate @@ -60,13 +60,13 @@ main() { err "Please specify an metadata id for which to set the permissions" else hosturl=${hosturl%/} - cmd="curl -sk -H \"${authheader}\" -X POST -d \"permission=$permission\" '${hosturl}/data/$args/pems/$pemusername?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X POST -d \"permission=$permission\" '${hosturl}/data/$args/pems/$pemusername?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X POST -d "permission=$permission" "${hosturl}/data/$args/pems/$pemusername?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X POST -d "permission=$permission" "${hosturl}/data/$args/pems/$pemusername?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/metadata-pems-list b/bin/metadata-pems-list index 9ddf923..904e966 100755 --- a/bin/metadata-pems-list +++ b/bin/metadata-pems-list @@ -61,13 +61,13 @@ main() { else hosturl=${hosturl%/} - cmd="curl -sk -H \"${authheader}\" '${hosturl}/data/$args/pems/$pemusername?pretty=true$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" '${hosturl}/data/$args/pems/$pemusername?pretty=true$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "${hosturl}/data/$args/pems/$pemusername?pretty=true$(pagination)"` + response=`agave-curl -sk -H "${authheader}" "${hosturl}/data/$args/pems/$pemusername?pretty=true$(pagination)"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/metadata-schema-addupdate b/bin/metadata-schema-addupdate index 9cd2366..5f09581 100755 --- a/bin/metadata-schema-addupdate +++ b/bin/metadata-schema-addupdate @@ -56,13 +56,13 @@ main() { #echo -n #set -x - cmd="curl -sk -H \"${authheader}\" -X POST -F \"fileToUpload=@$filetoupload\" '${hosturl}schemas/${args}?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X POST -F \"fileToUpload=@$filetoupload\" '${hosturl}schemas/${args}?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X POST -F "fileToUpload=@${filetoupload}" "${hosturl}schemas/${args}?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X POST -F "fileToUpload=@${filetoupload}" "${hosturl}schemas/${args}?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/metadata-schema-delete b/bin/metadata-schema-delete index 984324e..2ba0e6f 100755 --- a/bin/metadata-schema-delete +++ b/bin/metadata-schema-delete @@ -57,13 +57,13 @@ main() { err "Please specify a valid metadata object id to delete" else - cmd="curl -sk -H \"${authheader}\" -X DELETE '${hosturl}schemas/${args}?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X DELETE '${hosturl}schemas/${args}?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X DELETE "${hosturl}schemas/${args}?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X DELETE "${hosturl}schemas/${args}?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/metadata-schema-list b/bin/metadata-schema-list index 824db8a..4c6229f 100755 --- a/bin/metadata-schema-list +++ b/bin/metadata-schema-list @@ -72,13 +72,13 @@ main() { metaurl="$hosturl/schemas/?pretty=true" fi - cmd="curl -sk -H \"${authheader}\" '$metaurl$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" '$metaurl$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "$metaurl$(pagination)"` + response=`agave-curl -sk -H "${authheader}" "$metaurl$(pagination)"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/metadata-schema-pems-addupdate b/bin/metadata-schema-pems-addupdate index 8a67cc8..35214c9 100755 --- a/bin/metadata-schema-pems-addupdate +++ b/bin/metadata-schema-pems-addupdate @@ -62,13 +62,13 @@ main() { else hosturl=${hosturl%/} - cmd="curl -sk -H \"${authheader}\" -X POST -d \"permission=$permission\" '${hosturl}/schemas/$args/pems/$pemusername?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X POST -d \"permission=$permission\" '${hosturl}/schemas/$args/pems/$pemusername?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X POST -d "permission=$permission" "${hosturl}/schemas/$args/pems/$pemusername?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X POST -d "permission=$permission" "${hosturl}/schemas/$args/pems/$pemusername?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/metadata-schema-pems-list b/bin/metadata-schema-pems-list index 3523301..c5db34f 100755 --- a/bin/metadata-schema-pems-list +++ b/bin/metadata-schema-pems-list @@ -59,13 +59,13 @@ main() { else hosturl=${hosturl%/} - cmd="curl -sk -H \"${authheader}\" '${hosturl}/schemas/$args/pems/$pemusername?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" '${hosturl}/schemas/$args/pems/$pemusername?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "${hosturl}/schemas/$args/pems/$pemusername?pretty=true"` + response=`agave-curl -sk -H "${authheader}" "${hosturl}/schemas/$args/pems/$pemusername?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/monitors-addupdate b/bin/monitors-addupdate index 8820a5e..dd377c9 100755 --- a/bin/monitors-addupdate +++ b/bin/monitors-addupdate @@ -95,25 +95,25 @@ main() { active="true" fi - cmd="curl -sk -H \"${authheader}\" -X POST -d \"frequency=${frequency}&active=${active}&updateSystemStatus=${updateSystemStatus}&target=${systemId}\" '${hosturl}$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X POST -d \"frequency=${frequency}&active=${active}&updateSystemStatus=${updateSystemStatus}&target=${systemId}\" '${hosturl}$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X POST -d "frequency=${frequency}&active=${active}&updateSystemStatus=${updateSystemStatus}&target=${systemId}" "${hosturl}$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X POST -d "frequency=${frequency}&active=${active}&updateSystemStatus=${updateSystemStatus}&target=${systemId}" "${hosturl}$args?pretty=true"` # reading from stdin elif [[ "$filetoupload" == "-" ]]; then - cmd="curl -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X POST --data-binary @- '${hosturl}${args}?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X POST --data-binary @- '${hosturl}${args}?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi # make sure we specify content type as application/json - response=`curl -sk -H "${authheader}" -H "Content-Type: application/json" -X POST --data-binary @- "${hosturl}${args}?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -H "Content-Type: application/json" -X POST --data-binary @- "${hosturl}${args}?pretty=true"` # check file exists elif [[ ! -e "$filetoupload" ]]; then @@ -124,13 +124,13 @@ main() { # standard file upload else - cmd="curl -sk -H \"${authheader}\" -X POST -F \"fileToUpload=@$filetoupload\" '${hosturl}$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X POST -F \"fileToUpload=@$filetoupload\" '${hosturl}$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X POST -F "fileToUpload=@$filetoupload" "${hosturl}$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X POST -F "fileToUpload=@$filetoupload" "${hosturl}$args?pretty=true"` fi diff --git a/bin/monitors-checks-list b/bin/monitors-checks-list index 83cbb85..8a40476 100755 --- a/bin/monitors-checks-list +++ b/bin/monitors-checks-list @@ -99,13 +99,13 @@ main() { else - cmd="curl -sk -H \"${authheader}\" '${monitorurl}$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" '${monitorurl}$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "${monitorurl}$(pagination)"` + response=`agave-curl -sk -H "${authheader}" "${monitorurl}$(pagination)"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/monitors-delete b/bin/monitors-delete index c8b1b34..a9c8094 100755 --- a/bin/monitors-delete +++ b/bin/monitors-delete @@ -55,13 +55,13 @@ main() { err "Please specify a valid monitor id to delete" else - cmd="curl -sk -H \"${authheader}\" -X DELETE '${hosturl}${args}?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X DELETE '${hosturl}${args}?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X DELETE "${hosturl}${args}?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X DELETE "${hosturl}${args}?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/monitors-disable b/bin/monitors-disable index 5108f24..6d64562 100755 --- a/bin/monitors-disable +++ b/bin/monitors-disable @@ -55,13 +55,13 @@ main() { err "Please specify a valid monitor id to enable" else - cmd="curl -sk -H \"${authheader}\" -H "Content-Type: application/json" -X PUT -d '{\"action\":\"disable\"}' '$hosturl$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -H 'Content-Type: application/json' -X PUT --data-binary '{\"action\":\"disable\"}' '$hosturl$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -H "Content-Type: application/json" -X PUT --date-binary '{"action":"disable"}' "$hosturl$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -H 'Content-Type: application/json' -X PUT --data-binary '{"action":"disable"}' "$hosturl$args?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/monitors-enable b/bin/monitors-enable index df23bf9..de3edf1 100755 --- a/bin/monitors-enable +++ b/bin/monitors-enable @@ -55,13 +55,13 @@ main() { err "Please specify a valid monitor id to enable" else - cmd="curl -sk -H \"${authheader}\" -H "Content-Type: application/json" -X PUT -d '{\"action\":\"enable\"}' '$hosturl$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -H 'Content-Type: application/json' -X PUT --data-binary '{\"action\":\"enable\"}' '$hosturl$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -H "Content-Type: application/json" -X PUT --date-binary '{"action":"disable"}' "$hosturl$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -H 'Content-Type: application/json' -X PUT --data-binary '{"action":"disable"}' "$hosturl$args?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/monitors-fire b/bin/monitors-fire index d425e51..70f3b3c 100755 --- a/bin/monitors-fire +++ b/bin/monitors-fire @@ -59,13 +59,13 @@ main() { err "Please provide a monitor id." fi - cmd="curl -sk -H \"${authheader}\" -XPOST -d \"foo=bar\" '${hosturl}'" + cmd="agave-curl -sk -H \"${authheader}\" -XPOST -d \"foo=bar\" '${hosturl}'" if ((veryverbose)); then log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X POST -d "foo=bar" "${hosturl}"` + response=`agave-curl -sk -H "${authheader}" -X POST -d "foo=bar" "${hosturl}"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/monitors-history b/bin/monitors-history index 2edede1..258b0e2 100755 --- a/bin/monitors-history +++ b/bin/monitors-history @@ -60,13 +60,13 @@ main() { err "Please specify a monitor for which to fetch the history" else - cmd="curl -sk -H \"${authheader}\" '$hosturl$args/history?pretty=true$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" '$hosturl$args/history?pretty=true$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "${hosturl}${args}/history?pretty=true$(pagination)"` + response=`agave-curl -sk -H "${authheader}" "${hosturl}${args}/history?pretty=true$(pagination)"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then diff --git a/bin/monitors-list b/bin/monitors-list index aa3d250..df3e5dd 100755 --- a/bin/monitors-list +++ b/bin/monitors-list @@ -86,13 +86,13 @@ main() { fi - cmd="curl -sk -H \"${authheader}\" '${monitorurl}'" + cmd="agave-curl -sk -H \"${authheader}\" '${monitorurl}'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "${monitorurl}"` + response=`agave-curl -sk -H "${authheader}" "${monitorurl}"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/monitors-search b/bin/monitors-search index eebe579..08577e5 100755 --- a/bin/monitors-search +++ b/bin/monitors-search @@ -96,13 +96,13 @@ main() { done fi - cmd="curl -G -sk -H \"${authheader}\" '$hosturl?pretty=true$(pagination)' ${querystring}" + cmd="agave-curl -G -sk -H \"${authheader}\" '$hosturl?pretty=true$(pagination)' ${querystring}" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "${hosturl}?pretty=true$(pagination)" ${querystring}` + response=`agave-curl -sk -H "${authheader}" "${hosturl}?pretty=true$(pagination)" ${querystring}` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/notifications-addupdate b/bin/notifications-addupdate index cf527f4..c1916a7 100755 --- a/bin/notifications-addupdate +++ b/bin/notifications-addupdate @@ -140,36 +140,36 @@ main() { retryrate="5" fi - cmd="curl -sk -H \"${authheader}\" -X POST -H 'Content-Type: application/json' --data-binary '{\"event\":\"${event}\",\"persistent\": ${persistent},\"associatedUuid\":\"${associatedUuid}\", \"url\":\"${url}\",\"policy\":{\"retryStrategy\":\"$retrystrategy\",\"retryLimit\":$retrylimit,\"retryRate\":$retryrate,\"retryDelay\":$retrydelay,\"saveOnFailure\":$saveonfailure}}' '${hosturl}$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X POST -H 'Content-Type: application/json' --data-binary '{\"event\":\"${event}\",\"persistent\": ${persistent},\"associatedUuid\":\"${associatedUuid}\", \"url\":\"${url}\",\"policy\":{\"retryStrategy\":\"$retrystrategy\",\"retryLimit\":$retrylimit,\"retryRate\":$retryrate,\"retryDelay\":$retrydelay,\"saveOnFailure\":$saveonfailure}}' '${hosturl}$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X POST -H 'Content-Type: application/json' --data-binary "{\"event\":\"${event}\",\"persistent\": $persistent,\"associatedUuid\":\"${associatedUuid}\", \"url\":\"${url}\",\"policy\":{\"retryStrategy\":\"$retrystrategy\",\"retryLimit\":$retrylimit,\"retryRate\":$retryrate,\"retryDelay\":$retrydelay,\"saveOnFailure\": $saveonfailure}}" "${hosturl}$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X POST -H 'Content-Type: application/json' --data-binary "{\"event\":\"${event}\",\"persistent\": $persistent,\"associatedUuid\":\"${associatedUuid}\", \"url\":\"${url}\",\"policy\":{\"retryStrategy\":\"$retrystrategy\",\"retryLimit\":$retrylimit,\"retryRate\":$retryrate,\"retryDelay\":$retrydelay,\"saveOnFailure\": $saveonfailure}}" "${hosturl}$args?pretty=true"` # reading from stdin elif [[ "$filetoupload" == "-" ]]; then - cmd="curl -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X POST --data-binary @- '${hosturl}${args}?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X POST --data-binary @- '${hosturl}${args}?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi # make sure we specify content type as application/json - response=`curl -sk -H "${authheader}" -H "Content-Type: application/json" -X POST --data-binary @- "${hosturl}${args}?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -H "Content-Type: application/json" -X POST --data-binary @- "${hosturl}${args}?pretty=true"` # standard file upload elif [[ -f "$filetoupload" ]]; then - cmd="curl -sk -H \"${authheader}\" -X POST -F \"fileToUpload=@$filetoupload\" '${hosturl}$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X POST -F \"fileToUpload=@$filetoupload\" '${hosturl}$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X POST -F "fileToUpload=@$filetoupload" "${hosturl}$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X POST -F "fileToUpload=@$filetoupload" "${hosturl}$args?pretty=true"` fi diff --git a/bin/notifications-delete b/bin/notifications-delete index 231bfa9..d23124d 100755 --- a/bin/notifications-delete +++ b/bin/notifications-delete @@ -54,13 +54,13 @@ main() { err "Please specify a valid notification object id to delete" else - cmd="curl -sk -H \"${authheader}\" -X DELETE '${hosturl}${args}?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X DELETE '${hosturl}${args}?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X DELETE "${hosturl}${args}?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X DELETE "${hosturl}${args}?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/notifications-fire b/bin/notifications-fire index 4dd3b30..ece8ff8 100755 --- a/bin/notifications-fire +++ b/bin/notifications-fire @@ -51,13 +51,13 @@ main() { #echo -n #set -x - cmd="curl -sk -H \"${authheader}\" -X POST -d \"foo=bar\" '${hosturl}$args/attempts?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X POST -d \"foo=bar\" '${hosturl}$args/attempts?pretty=true'" if ((veryverbose)); then log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X POST -d "foo=bar" "${hosturl}$args/attempts?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X POST -d "foo=bar" "${hosturl}$args/attempts?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/notifications-list b/bin/notifications-list index ac037a6..94a2157 100755 --- a/bin/notifications-list +++ b/bin/notifications-list @@ -64,13 +64,13 @@ main() { hosturl="${hosturl}?pretty=true" fi - cmd="curl -sk -H \"${authheader}\" '${hosturl}$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" '${hosturl}$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "${hosturl}$(pagination)"` + response=`agave-curl -sk -H "${authheader}" "${hosturl}$(pagination)"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/notifications-list-failures b/bin/notifications-list-failures index fef1a09..67f79d7 100755 --- a/bin/notifications-list-failures +++ b/bin/notifications-list-failures @@ -59,13 +59,13 @@ main() { err "Please specify a valid notification object id to query for failures" else - cmd="curl -sk -H \"${authheader}\" '${hosturl}${args}/attempts?pretty=true$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" '${hosturl}${args}/attempts?pretty=true$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "${hosturl}${args}/attempts?pretty=true$(pagination)"` + response=`agave-curl -sk -H "${authheader}" "${hosturl}${args}/attempts?pretty=true$(pagination)"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/notifications-search b/bin/notifications-search index 20ff930..71c9a01 100755 --- a/bin/notifications-search +++ b/bin/notifications-search @@ -92,13 +92,13 @@ main() { done fi - cmd="curl -G -sk -H \"${authheader}\" '$hosturl?pretty=true$(pagination)' ${querystring}" + cmd="agave-curl -G -sk -H \"${authheader}\" '$hosturl?pretty=true$(pagination)' ${querystring}" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "${hosturl}?pretty=true$(pagination)" ${querystring}` + response=`agave-curl -sk -H "${authheader}" "${hosturl}?pretty=true$(pagination)" ${querystring}` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/postits-create b/bin/postits-create index 6ac626d..8a8bd2a 100755 --- a/bin/postits-create +++ b/bin/postits-create @@ -100,13 +100,13 @@ main() { post_options="noauth=$noauth&$post_options" fi - cmd="curl -sk -H \"${authheader}\" -X POST -d \"$post_options\" -d \"url=${args}\" '${hosturl}?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X POST -d \"$post_options\" -d \"url=${args}\" '${hosturl}?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X POST -d "${post_options}" -d "url=${args}" "${hosturl}?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X POST -d "${post_options}" -d "url=${args}" "${hosturl}?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/postits-delete b/bin/postits-delete index 1e8189c..fd92ccd 100755 --- a/bin/postits-delete +++ b/bin/postits-delete @@ -58,13 +58,13 @@ main() { die fi - cmd="curl -sk -H \"${authheader}\" -X DELETE '${hosturl}${args}?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X DELETE '${hosturl}${args}?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X DELETE "${hosturl}${args}?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X DELETE "${hosturl}${args}?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/postits-list b/bin/postits-list index a1aa894..9600459 100755 --- a/bin/postits-list +++ b/bin/postits-list @@ -59,13 +59,13 @@ main() { hosturl="${hosturl}/${args}" fi - cmd="curl -sk -H \"${authheader}\" '${hosturl}?pretty=true$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" '${hosturl}?pretty=true$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "${hosturl}?pretty=true$(pagination)"` + response=`agave-curl -sk -H "${authheader}" "${hosturl}?pretty=true$(pagination)"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/profiles-addupdate b/bin/profiles-addupdate index 93511f9..72adc4c 100755 --- a/bin/profiles-addupdate +++ b/bin/profiles-addupdate @@ -139,36 +139,36 @@ main() query=${query%&} - cmd="curl -sk -H \"${authheader}\" -X ${http_method} -d \"${query}\" '${hosturl}$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X ${http_method} -d \"${query}\" '${hosturl}$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X ${http_method} -d "${query}" "${hosturl}$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X ${http_method} -d "${query}" "${hosturl}$args?pretty=true"` # reading from stdin elif [[ "$filetoupload" == "-" ]]; then - cmd="curl -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X ${http_method} --data-binary @- '${hosturl}${args}?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X ${http_method} --data-binary @- '${hosturl}${args}?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi # make sure we specify content type as application/json - response=`curl -sk -H "${authheader}" -H "Content-Type: application/json" -X ${http_method} --data-binary @- "${hosturl}${args}?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -H "Content-Type: application/json" -X ${http_method} --data-binary @- "${hosturl}${args}?pretty=true"` # standard file upload elif [[ -f "$filetoupload" ]]; then - cmd="curl -sk -H \"${authheader}\" -X ${http_method} -F \"fileToUpload=@$filetoupload\" '${hosturl}$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X ${http_method} -F \"fileToUpload=@$filetoupload\" '${hosturl}$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X ${http_method} -F "fileToUpload=@$filetoupload" "${hosturl}$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X ${http_method} -F "fileToUpload=@$filetoupload" "${hosturl}$args?pretty=true"` fi @@ -191,7 +191,7 @@ format_api_json() { else if [ -z "$args" ]; then internal_username=$(jsonquery "$1" "result.username") - echo "Successfully added user $internal_username." + echo "Successfully added user $username." else echo "Successfully updated user $account_username" fi diff --git a/bin/profiles-delete b/bin/profiles-delete index 257c30c..1112892 100755 --- a/bin/profiles-delete +++ b/bin/profiles-delete @@ -56,13 +56,13 @@ main() { err "Please specify a valid account username to delete" else - cmd="curl -sk -H \"${authheader}\" -X DELETE '$hosturl$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X DELETE '$hosturl$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X DELETE "$hosturl$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X DELETE "$hosturl$args?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") @@ -76,6 +76,8 @@ main() { format_api_json() { + jsonval storedtoken "${tokenstore}" "apikey" + if ((veryverbose)); then echo "$1" elif [[ $verbose -eq 1 ]]; then diff --git a/bin/profiles-list b/bin/profiles-list index f134861..599a882 100755 --- a/bin/profiles-list +++ b/bin/profiles-list @@ -79,13 +79,13 @@ main() { hosturl="$hosturl?pretty=true" fi - cmd="curl -sk -H \"${authheader}\" '$hosturl$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" '$hosturl$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "${hosturl}$(pagination)"` + response=`agave-curl -sk -H "${authheader}" "${hosturl}$(pagination)"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/profiles-search b/bin/profiles-search index 5193b0c..998c98d 100755 --- a/bin/profiles-search +++ b/bin/profiles-search @@ -79,14 +79,14 @@ main() { done fi - cmd="curl -G -sk -H \"${authheader}\" '$profilesurl?pretty=true$(pagination)' ${querystring}" + cmd="agave-curl -G -sk -H \"${authheader}\" '$profilesurl?pretty=true$(pagination)' ${querystring}" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -G -sk -H "${authheader}" $profilesurl?pretty=true$(pagination) $querystring` + response=`agave-curl -G -sk -H "${authheader}" $profilesurl?pretty=true$(pagination) $querystring` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/profiles-users-addupdate b/bin/profiles-users-addupdate index ea24c2f..2736682 100755 --- a/bin/profiles-users-addupdate +++ b/bin/profiles-users-addupdate @@ -59,13 +59,13 @@ main() { #echo -n #set -x - cmd="curl -sk -H \"${authheader}\" -X POST -F \"fileToUpload=@$filetoupload\" '$hosturl$username/users/$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X POST -F \"fileToUpload=@$filetoupload\" '$hosturl$username/users/$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X POST -F "fileToUpload=@$filetoupload" "$hosturl$username/users/$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X POST -F "fileToUpload=@$filetoupload" "$hosturl$username/users/$args?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/profiles-users-delete b/bin/profiles-users-delete index c858644..e131abb 100755 --- a/bin/profiles-users-delete +++ b/bin/profiles-users-delete @@ -52,13 +52,13 @@ main() { #echo -n #set -x - cmd="curl -sk -H \"${authheader}\" -X DELETE '$hosturl$username/users/$internalusername?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X DELETE '$hosturl$username/users/$internalusername?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X DELETE $hosturl$username/users/$internalusername?pretty=true` + response=`agave-curl -sk -H "${authheader}" -X DELETE $hosturl$username/users/$internalusername?pretty=true` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/profiles-users-list b/bin/profiles-users-list index ec1ec6a..d5ff901 100755 --- a/bin/profiles-users-list +++ b/bin/profiles-users-list @@ -76,13 +76,13 @@ main() { profileurl="${hosturl}$username/users?pretty=true" fi - cmd="curl -sk -H \"${authheader}\" '$profileurl$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" '$profileurl$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" $profileurl$(pagination)` + response=`agave-curl -sk -H "${authheader}" $profileurl$(pagination)` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/requestbin-create b/bin/requestbin-create index 03c3bbc..3889a3c 100755 --- a/bin/requestbin-create +++ b/bin/requestbin-create @@ -50,13 +50,13 @@ main() { #echo -n #set -x - cmd="curl -sk -X POST '${hosturl}api/v1/bins'" + cmd="agave-curl -sk -X POST '${hosturl}api/v1/bins'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -X POST ${hosturl}api/v1/bins` + response=`agave-curl -sk -X POST ${hosturl}api/v1/bins` if [[ -n $(jsonquery "$response" "name") ]]; then result=$(format_api_json "$response") diff --git a/bin/requestbin-requests-list b/bin/requestbin-requests-list index 45bdd4c..06fca44 100755 --- a/bin/requestbin-requests-list +++ b/bin/requestbin-requests-list @@ -52,13 +52,13 @@ main() { if [ -z "$args" ]; then err "Please specify a valid system id for which to retrieve the credentials" else - cmd="curl -sk '${hosturl}api/v1/bins/${args}/requests'" + cmd="agave-curl -sk '${hosturl}api/v1/bins/${args}/requests'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk ${hosturl}api/v1/bins/${args}/requests` + response=`agave-curl -sk ${hosturl}api/v1/bins/${args}/requests` if [[ -n $(jsonquery "$response" "[].id") ]]; then result=$(format_api_json "$response") diff --git a/bin/richtext b/bin/richtext index c99b717..c76311e 100644 --- a/bin/richtext +++ b/bin/richtext @@ -8,23 +8,31 @@ apps-history: status createdBy created description apps-list: id executionSystem revision isPublic lastModified apps-search: id executionSystem revision isPublic lastModified -#apps-search: id name version revision isPublic lastModified + +### auth commands ### +auth-tokens-create: access_token refresh_token expires_in ### clients commands ### -clients-list: name consumerKey +clients-list: name consumerKey callbackUrl +clients-create: name consumerKey callbackUrl + +clients-subscriptions-list: apiName apiVersion apiStatus tier apiProvider apiContext +clients-subscriptions-update: apiName apiVersion apiStatus tier apiProvider apiContext ### files commands ### files-history: status created description files-list: name length permissions type lastModified + ### jobs commands ### jobs-history: status created description jobs-list: name created startTime endTime status -#jobs-list: id name owner executionSystem appId status jobs-output-list: name length permission type lastModified jobs-search: id name owner executionSystem appId status -#jobs-search: name created startTime endTime jobs-tail: id averageRate totalBytes totalBytesTransferred +jobs-submit: id name owner executionSystem appId status +jobs-resubmit: id name owner executionSystem appId status +jobs-status: id status ### metadata commands ### metadata-list: uuid owner name created lastUpdated @@ -36,12 +44,17 @@ profiles-list: firstName lastName username email institution ### systems commands ### systems-history: status createdBy created description systems-list: id type status public default lastUpdated -#systems-list: id name systems-queues-list: name maxJobs maxNodes maxProcessorsPerNode maxMemoryPerNode maxRequestedTime -#systems-queues-list: name load.running load.pending load.queued systems-roles-list: username role systems-search: id type status public default lastUpdated -#systems-search: id name ### tenants commands ### -tenants-list: name baseUrl contact.[].name contact.[].email +tenants-list: tenantCode name baseUrl contact.[].name contact.[].email + +### notifications commands ### +notifications-list: id event persistent status url +notifications-search: id event persistent status url + +### tenants commands ### +monitors-list: id target updateSystemStatus active frequency lastSuccess lastUpdated +monitors-checks-list: id target updateSystemStatus active frequency lastSuccess lastUpdated diff --git a/bin/runner.sh b/bin/runner.sh index c11ac2b..051581b 100755 --- a/bin/runner.sh +++ b/bin/runner.sh @@ -72,7 +72,7 @@ hosturl=${hosturl%/} hosturl="$hosturl/" # Delegate logic from the `main` function -authheader=$(get_auth_header) +get_auth_header main # This has to be run last not to rollback changes we've made. diff --git a/bin/systems-addupdate b/bin/systems-addupdate index 8100969..4ec622e 100755 --- a/bin/systems-addupdate +++ b/bin/systems-addupdate @@ -78,25 +78,25 @@ main() { # reading from stdin if [[ "$filetoupload" == "-" ]]; then - cmd="curl -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X POST --data-binary @- '${hosturl}${args}?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X POST --data-binary @- '${hosturl}${args}?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi # make sure we specify content type as application/json - response=`curl -sk -H "${authheader}" -H "Content-Type: application/json" -X POST --data-binary @- "${hosturl}${args}?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -H "Content-Type: application/json" -X POST --data-binary @- "${hosturl}${args}?pretty=true"` # standard file upload else - cmd="curl -sk -H \"${authheader}\" -X POST -F \"fileToUpload=@$filetoupload\" '${hosturl}${args}?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X POST -F \"fileToUpload=@$filetoupload\" '${hosturl}${args}?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X POST -F "fileToUpload=@$filetoupload" "${hosturl}${args}?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X POST -F "fileToUpload=@$filetoupload" "${hosturl}${args}?pretty=true"` fi diff --git a/bin/systems-clone b/bin/systems-clone index 4c7f34d..19cfea5 100755 --- a/bin/systems-clone +++ b/bin/systems-clone @@ -62,13 +62,13 @@ main() { new_system_id="&id=$id" fi - cmd="curl -sk -H \"${authheader}\" -X PUT -d \"action=clone$new_system_id\" '$hosturl$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X PUT -d \"action=clone$new_system_id\" '$hosturl$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X PUT -d "action=clone$new_system_id" "$hosturl$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X PUT -d "action=clone$new_system_id" "$hosturl$args?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/systems-credentials-addupdate b/bin/systems-credentials-addupdate index 990f001..3f0977e 100755 --- a/bin/systems-credentials-addupdate +++ b/bin/systems-credentials-addupdate @@ -60,13 +60,13 @@ main() { err "Please specify a valid system id containing credentials to delete" else - cmd="curl -sk -H \"${authheader}\" -X POST -F \"fileToUpload=@$filetoupload\" '$hosturl$args/credentials/$internalusername?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X POST -F \"fileToUpload=@$filetoupload\" '$hosturl$args/credentials/$internalusername?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X POST -F "fileToUpload=@$filetoupload" "$hosturl$args/credentials/$internalusername?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X POST -F "fileToUpload=@$filetoupload" "$hosturl$args/credentials/$internalusername?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/systems-credentials-delete b/bin/systems-credentials-delete index 89e7990..bc95f31 100755 --- a/bin/systems-credentials-delete +++ b/bin/systems-credentials-delete @@ -69,13 +69,13 @@ main() { err "Please specify a valid system id containing credentials to delete" else - cmd="curl -sk -H \"${authheader}\" -X DELETE '$hosturl$args/credentials/$username?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X DELETE '$hosturl$args/credentials/$username?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X DELETE "$hosturl$args/credentials/$username?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X DELETE "$hosturl$args/credentials/$username?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/systems-credentials-list b/bin/systems-credentials-list index 8126346..2877fac 100755 --- a/bin/systems-credentials-list +++ b/bin/systems-credentials-list @@ -72,13 +72,13 @@ main() { internaluser="/$internalusername" fi - cmd="curl -sk -H \"${authheader}\" '$hosturl$args/credentials$internaluser$credentialtype?pretty=true$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" '$hosturl$args/credentials$internaluser$credentialtype?pretty=true$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "$hosturl$args/credentials/$internalusername?pretty=true$(pagination)"` + response=`agave-curl -sk -H "${authheader}" "$hosturl$args/credentials/$internalusername?pretty=true$(pagination)"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/systems-delete b/bin/systems-delete index 2d7aa90..2c44aa7 100755 --- a/bin/systems-delete +++ b/bin/systems-delete @@ -61,13 +61,13 @@ main() { err "Please specify a valid system id to delete" else - cmd="curl -sk -H \"${authheader}\" -X DELETE '$hosturl$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X DELETE '$hosturl$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X DELETE "$hosturl$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X DELETE "$hosturl$args?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") @@ -81,6 +81,8 @@ main() { format_api_json() { + jsonval storedtoken "${tokenstore}" "apikey" + if ((veryverbose)); then echo "$1" elif [[ $verbose -eq 1 ]]; then diff --git a/bin/systems-disable b/bin/systems-disable index ada6408..76ff68f 100755 --- a/bin/systems-disable +++ b/bin/systems-disable @@ -56,13 +56,13 @@ main() { else action="disable" - cmd="curl -sk -H \"${authheader}\" -X PUT -d \"action=${action}\" '$hosturl$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X PUT -d \"action=${action}\" '$hosturl$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X PUT -d "action=${action}" "$hosturl$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X PUT -d "action=${action}" "$hosturl$args?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/systems-enable b/bin/systems-enable index cc717dd..79b9ec1 100755 --- a/bin/systems-enable +++ b/bin/systems-enable @@ -56,13 +56,13 @@ main() { else action="enable" - cmd="curl -sk -H \"${authheader}\" -X PUT -d \"action=${action}\" '$hosturl$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X PUT -d \"action=${action}\" '$hosturl$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X PUT -d "action=${action}" "$hosturl$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X PUT -d "action=${action}" "$hosturl$args?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/systems-erase b/bin/systems-erase index ea18596..d9cf3c3 100755 --- a/bin/systems-erase +++ b/bin/systems-erase @@ -59,13 +59,13 @@ main() { err "Please specify a valid system id to erase" else - cmd="curl -sk -H \"${authheader}\" -X PUT -d \"action=erase\" '$hosturl$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X PUT -d \"action=erase\" '$hosturl$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X PUT -d "action=erase" "$hosturl$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X PUT -d "action=erase" "$hosturl$args?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/systems-history b/bin/systems-history index 2cf0994..1939f72 100755 --- a/bin/systems-history +++ b/bin/systems-history @@ -62,13 +62,13 @@ main() { err "Please specify a system for which to fetch the history" else - cmd="curl -sk -H \"${authheader}\" '$hosturl$args/history?pretty=true$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" '$hosturl$args/history?pretty=true$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "${hosturl}${args}/history?pretty=true$(pagination)"` + response=`agave-curl -sk -H "${authheader}" "${hosturl}${args}/history?pretty=true$(pagination)"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then diff --git a/bin/systems-list b/bin/systems-list index 0a403a8..51a1750 100755 --- a/bin/systems-list +++ b/bin/systems-list @@ -87,13 +87,13 @@ main() { systemsurl="${hosturl}?${querystring}" fi - cmd="curl -sk -H \"${authheader}\" '${systemsurl}'" + cmd="agave-curl -sk -H \"${authheader}\" '${systemsurl}'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "${systemsurl}"` + response=`agave-curl -sk -H "${authheader}" "${systemsurl}"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/systems-publish b/bin/systems-publish index e3af59c..9ccd5b3 100755 --- a/bin/systems-publish +++ b/bin/systems-publish @@ -57,13 +57,13 @@ main() { err "Please specify a valid system id to publish" else - cmd="curl -sk -H \"${authheader}\" -X PUT -d \"action=publish\" '$hosturl$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X PUT -d \"action=publish\" '$hosturl$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X PUT -d "action=publish" "$hosturl$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X PUT -d "action=publish" "$hosturl$args?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/systems-queues-addupdate b/bin/systems-queues-addupdate index b5fe225..00923ea 100755 --- a/bin/systems-queues-addupdate +++ b/bin/systems-queues-addupdate @@ -78,25 +78,25 @@ main() { # reading from stdin if [[ "$filetoupload" == "-" ]]; then - cmd="curl -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X POST --data-binary @- '${hosturl}${args}/queues/$queuename?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X POST --data-binary @- '${hosturl}${args}/queues/$queuename?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi # make sure we specify content type as application/json - response=`curl -sk -H "${authheader}" -H "Content-Type: application/json" -X POST --data-binary @- "${hosturl}${args}/queues/$queuename?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -H "Content-Type: application/json" -X POST --data-binary @- "${hosturl}${args}/queues/$queuename?pretty=true"` # standard file upload else - cmd="curl -sk -H \"${authheader}\" -X POST -F \"fileToUpload=@$filetoupload\" '${hosturl}${args}/queues/$queuename?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X POST -F \"fileToUpload=@$filetoupload\" '${hosturl}${args}/queues/$queuename?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X POST -F "fileToUpload=@$filetoupload" "${hosturl}${args}/queues/$queuename?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X POST -F "fileToUpload=@$filetoupload" "${hosturl}${args}/queues/$queuename?pretty=true"` fi diff --git a/bin/systems-queues-delete b/bin/systems-queues-delete index 7855596..b724b36 100755 --- a/bin/systems-queues-delete +++ b/bin/systems-queues-delete @@ -55,13 +55,13 @@ main() { err "Please specify a valid system id for which to delete the batch queues" else - cmd="curl -sk -H \"${authheader}\" -X DELETE '$hosturl$args/queues/$queuename?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X DELETE '$hosturl$args/queues/$queuename?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X DELETE "$hosturl$args/queues/$queuename?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X DELETE "$hosturl$args/queues/$queuename?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/systems-queues-list b/bin/systems-queues-list index 7a70bcd..7561c05 100755 --- a/bin/systems-queues-list +++ b/bin/systems-queues-list @@ -67,13 +67,13 @@ main() { hosturl="$hosturl/$queuename" fi - cmd="curl -sk -H \"${authheader}\" '$hosturl?pretty=true$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" '$hosturl?pretty=true$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "$hosturl?pretty=true$(pagination)"` + response=`agave-curl -sk -H "${authheader}" "$hosturl?pretty=true$(pagination)"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/systems-roles-addupdate b/bin/systems-roles-addupdate index ab22256..a34efed 100755 --- a/bin/systems-roles-addupdate +++ b/bin/systems-roles-addupdate @@ -67,13 +67,13 @@ main() { err "Please specify a valid username to whom the granted role should apply" fi - cmd="curl -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X POST --data-binary '{\"role\":\"$role\"}' '$hosturl$args/roles/$roleusername?pretty=true$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X POST --data-binary '{\"role\":\"$role\"}' '$hosturl$args/roles/$roleusername?pretty=true$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -H "Content-Type: application/json" -X POST --data-binary "{\"role\":\"$role\"}" "$hosturl$args/roles/$roleusername?pretty=true$(pagination)"` + response=`agave-curl -sk -H "${authheader}" -H "Content-Type: application/json" -X POST --data-binary "{\"role\":\"$role\"}" "$hosturl$args/roles/$roleusername?pretty=true$(pagination)"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/systems-roles-delete b/bin/systems-roles-delete index d853705..d7d9211 100755 --- a/bin/systems-roles-delete +++ b/bin/systems-roles-delete @@ -55,13 +55,13 @@ main() { if [ -z "$args" ]; then err "Please specify a valid system id for which to retrieve the user roles" else - cmd="curl -sk -H \"${authheader}\" -X DELETE '$hosturl$args/roles/$roleusername?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X DELETE '$hosturl$args/roles/$roleusername?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X DELETE "$hosturl$args/roles/$roleusername?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X DELETE "$hosturl$args/roles/$roleusername?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/systems-roles-list b/bin/systems-roles-list index 0d180ab..ba11137 100755 --- a/bin/systems-roles-list +++ b/bin/systems-roles-list @@ -59,13 +59,13 @@ main() { err "Please specify a valid system id for which to retrieve permissions" else - cmd="curl -sk -H \"${authheader}\" '$hosturl$args/roles/$roleusername?pretty=true$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" '$hosturl$args/roles/$roleusername?pretty=true$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "$hosturl$args/roles/$roleusername?pretty=true$(pagination)"` + response=`agave-curl -sk -H "${authheader}" "$hosturl$args/roles/$roleusername?pretty=true$(pagination)"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/systems-search b/bin/systems-search index e1eb3f4..0479233 100755 --- a/bin/systems-search +++ b/bin/systems-search @@ -134,14 +134,14 @@ main() { done fi - cmd="curl -G -sk -H \"${authheader}\" '$systemsurl?pretty=true$(pagination)' ${querystring}" + cmd="agave-curl -G -sk -H \"${authheader}\" '$systemsurl?pretty=true$(pagination)' ${querystring}" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -G -sk -H "${authheader}" $systemsurl?pretty=true$(pagination) $querystring` + response=`agave-curl -G -sk -H "${authheader}" $systemsurl?pretty=true$(pagination) $querystring` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/systems-setdefault b/bin/systems-setdefault index a395e19..c0c869e 100755 --- a/bin/systems-setdefault +++ b/bin/systems-setdefault @@ -66,13 +66,13 @@ main() { action="setDefault"; fi - cmd="curl -sk -H \"${authheader}\" -X PUT -d \"action=${action}\" '$hosturl$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X PUT -d \"action=${action}\" '$hosturl$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X PUT -d "action=${action}" "$hosturl$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X PUT -d "action=${action}" "$hosturl$args?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/systems-unpublish b/bin/systems-unpublish index 24ace25..ae1a3a3 100755 --- a/bin/systems-unpublish +++ b/bin/systems-unpublish @@ -57,13 +57,13 @@ main() { err "Please specify a valid system id to publish" else - cmd="curl -sk -H \"${authheader}\" -X PUT -d \"action=unpublish\" '$hosturl$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X PUT -d \"action=unpublish\" '$hosturl$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X PUT -d "action=unpublish" "$hosturl$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X PUT -d "action=unpublish" "$hosturl$args?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/systems-unsetdefault b/bin/systems-unsetdefault index 1c02a57..8198e3e 100755 --- a/bin/systems-unsetdefault +++ b/bin/systems-unsetdefault @@ -70,13 +70,13 @@ main() { action="unsetDefault"; fi - cmd="curl -sk -H \"${authheader}\" -X PUT -d \"action=${action}\" '$hosturl$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X PUT -d \"action=${action}\" '$hosturl$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X PUT -d "action=${action}" "$hosturl$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X PUT -d "action=${action}" "$hosturl$args?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/tags-addupdate b/bin/tags-addupdate index d4669cb..a5ea26b 100755 --- a/bin/tags-addupdate +++ b/bin/tags-addupdate @@ -72,37 +72,37 @@ main() { #uuids=$(echo "${uuids}" | sed -e 's/ /","/g') - cmd="curl -sk -H \"${authheader}\" -X POST -H 'Content-Type: application/json' --data-binary '{\"name\":\"${name}\",\"associationIds\": [\"${uuids}\"]}' '${hosturl}$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X POST -H 'Content-Type: application/json' --data-binary '{\"name\":\"${name}\",\"associationIds\": [\"${uuids}\"]}' '${hosturl}$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X POST -H 'Content-Type: application/json' --data-binary "{\"name\":\"${name}\", \"associationIds\":[\"${uuids}\"]}" "${hosturl}$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X POST -H 'Content-Type: application/json' --data-binary "{\"name\":\"${name}\", \"associationIds\":[\"${uuids}\"]}" "${hosturl}$args?pretty=true"` # reading from stdin elif [[ "$filetoupload" == "-" ]]; then - cmd="curl -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X POST --data-binary @- '${hosturl}$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X POST --data-binary @- '${hosturl}$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi # make sure we specify content type as application/json - response=`curl -sk -H "${authheader}" -H "Content-Type: application/json" -X POST --data-binary @- "${hosturl}$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -H "Content-Type: application/json" -X POST --data-binary @- "${hosturl}$args?pretty=true"` # standard file upload elif [[ -f "$filetoupload" ]]; then - cmd="curl -sk -H \"${authheader}\" -X POST -F \"fileToUpload=@$filetoupload\" '${hosturl}$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X POST -F \"fileToUpload=@$filetoupload\" '${hosturl}$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X POST -F "fileToUpload=@$filetoupload" "${hosturl}$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X POST -F "fileToUpload=@$filetoupload" "${hosturl}$args?pretty=true"` fi diff --git a/bin/tags-associations-addupdate b/bin/tags-associations-addupdate index 1dd56d1..5c285c4 100755 --- a/bin/tags-associations-addupdate +++ b/bin/tags-associations-addupdate @@ -68,13 +68,13 @@ main() { uuids=$(echo "${args}" | sed -e 's/ /","/g') - cmd="curl -sk -H \"${authheader}\" -X POST -H 'Content-Type: application/json' --data-binary '[\"${uuids}\"]' '${hosturl}$tag_id/associations?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X POST -H 'Content-Type: application/json' --data-binary '[\"${uuids}\"]' '${hosturl}$tag_id/associations?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X POST -H 'Content-Type: application/json' --data-binary "[\"${uuids}\"]" "${hosturl}$tag_id/associations?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X POST -H 'Content-Type: application/json' --data-binary "[\"${uuids}\"]" "${hosturl}$tag_id/associations?pretty=true"` # reading from stdin elif [[ "$filetoupload" == "-" ]]; then @@ -82,14 +82,14 @@ main() { # tag id is first positional argument tag_id="${args[0]}" - cmd="curl -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X POST --data-binary @- '${hosturl}$tag_id/associations?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -H \"Content-Type: application/json\" -X POST --data-binary @- '${hosturl}$tag_id/associations?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi # make sure we specify content type as application/json - response=`curl -sk -H "${authheader}" -H "Content-Type: application/json" -X POST --data-binary @- "${hosturl}$tag_id/associations?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -H "Content-Type: application/json" -X POST --data-binary @- "${hosturl}$tag_id/associations?pretty=true"` # standard file upload elif [[ -f "$filetoupload" ]]; then @@ -97,13 +97,13 @@ main() { # tag id is first positional argument tag_id="${args[0]}" - cmd="curl -sk -H \"${authheader}\" -X POST -F \"fileToUpload=@$filetoupload\" '${hosturl}$tag_id/associations?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X POST -F \"fileToUpload=@$filetoupload\" '${hosturl}$tag_id/associations?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X POST -F "fileToUpload=@$filetoupload" "${hosturl}$tag_id/associations?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X POST -F "fileToUpload=@$filetoupload" "${hosturl}$tag_id/associations?pretty=true"` fi diff --git a/bin/tags-associations-delete b/bin/tags-associations-delete index 270f758..4411a43 100755 --- a/bin/tags-associations-delete +++ b/bin/tags-associations-delete @@ -73,13 +73,13 @@ main() { uuid=$1 - cmd="curl -sk -H \"${authheader}\" -X DELETE '${hosturl}$tag_id/associations/$uuid?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X DELETE '${hosturl}$tag_id/associations/$uuid?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X DELETE "${hosturl}$tag_id/associations/$uuid?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X DELETE "${hosturl}$tag_id/associations/$uuid?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/tags-delete b/bin/tags-delete index 3a9e80d..d48c137 100755 --- a/bin/tags-delete +++ b/bin/tags-delete @@ -56,13 +56,13 @@ main() { err "Please specify a valid tag id to delete" else - cmd="curl -sk -H \"${authheader}\" -X DELETE '$hosturl$args?pretty=true'" + cmd="agave-curl -sk -H \"${authheader}\" -X DELETE '$hosturl$args?pretty=true'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" -X DELETE "$hosturl$args?pretty=true"` + response=`agave-curl -sk -H "${authheader}" -X DELETE "$hosturl$args?pretty=true"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") @@ -76,6 +76,8 @@ main() { format_api_json() { + jsonval storedtoken "${tokenstore}" "apikey" + if ((veryverbose)); then echo "$1" elif [[ $verbose -eq 1 ]]; then diff --git a/bin/tags-list b/bin/tags-list index ac9b3c2..18e6d8f 100755 --- a/bin/tags-list +++ b/bin/tags-list @@ -62,13 +62,13 @@ main() { tagsurl="${hosturl}?${querystring}" fi - cmd="curl -sk -H \"${authheader}\" '${tagsurl}'" + cmd="agave-curl -sk -H \"${authheader}\" '${tagsurl}'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "${tagsurl}"` + response=`agave-curl -sk -H "${authheader}" "${tagsurl}"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/tags-search b/bin/tags-search index 0ee4a0d..ff6f0e6 100755 --- a/bin/tags-search +++ b/bin/tags-search @@ -78,14 +78,14 @@ main() { done fi - cmd="curl -G -sk -H \"${authheader}\" '$tagsurl?pretty=true$(pagination)' ${querystring}" + cmd="agave-curl -G -sk -H \"${authheader}\" '$tagsurl?pretty=true$(pagination)' ${querystring}" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -G -v -sk -H "${authheader}" $tagsurl?pretty=true$(pagination) $querystring` + response=`agave-curl -G -v -sk -H "${authheader}" $tagsurl?pretty=true$(pagination) $querystring` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/tenants-init b/bin/tenants-init index 120aef2..bf4f459 100755 --- a/bin/tenants-init +++ b/bin/tenants-init @@ -30,18 +30,16 @@ Configure the context of the cli by selecting the tenant and setting the base url. Options: - -t, --tenant The tenant id to use, ex agave.prod. This will overridden the - value of AGAVE_TENANT in your environment. + -t, --tenant The tenant id to use, ex iplantc.org -b, --backup Backup the previous config before setting the new one. The current config will be stored as $AGAVE_CACHE_DIR/backup -r, --restore Sets the backed up config as current config and deletes the backup -s, --swap Swaps the current and backup configs, preserving both - -d, --developmenturl The development tenant, ex https://sandbox.example.com + -d, --developmenturl The development tenant, ex https://agave-dev.iplantc.org -f, --force Skip all user interaction -i, --interactive Prompt for values -q, --quiet Quiet (no output) - -v, --verbose Verbose output - -V, --veryverbose Very verbose output + -v, --verbose Verbose output -h, --help Display this help and exit --version Output version information and exit " @@ -95,25 +93,9 @@ main() { exit else - - # fetch tenant list from discovery service - cmd="curl -sk ${hosturl%/}?pretty=true&limit=1000" - - if ((veryverbose)); then - [ "$piped" -eq 0 ] && log "Calling $cmd" - fi - tenantresponse=`curl -sk "${hosturl%/}?pretty=true&limit=1000"` - - if ((veryverbose)); then - echo "$tenantresponse" - elif ((verbose)); then - echo $(jsonquery "$tenantresponse" "result.[].code") - fi - - # set default tenant in case none is present in the environment - DEFAULT_TENANT_ID=agave.prod - + tenantresponse=$(agave-curl -sk ${hosturl%/}/) + oldIFS="$IFS" #tenantids=$(jsonquery "${tenantresponse}" "result.[].tenantId") IFS=' @@ -122,40 +104,34 @@ main() { tenantids=( $(jsonquery "${tenantresponse}" "result.[].code") ) tenanturls=( $(jsonquery "${tenantresponse}" "result.[].baseUrl") ) IFS="$oldIFS" - - re='^[0-9]+$' - + + #tenanturls=$(jsonquery "${tenantresponse}" "result.[].baseUrl") + #IFS=', ' read -a tenanturls <<< ${tenanturls[@]} + if [ -z "$tenant" ]; then - - if ((force)); then - if [[ -n "$DEFAULT_TENANT_ID" ]]; then - tenant="$DEFAULT_TENANT_ID" - fi - else - echo "Please select a tenant from the following list:" - for i in "${!tenantids[@]}" - do - echo "[$i] ${tenantids[$i]}" - if [[ "${tenantids[$i]}" == "$DEFAULT_TENANT_ID" ]]; then - tenantid=$i - fi - done - - - echo -n "Your choice [$tenantid]: " - eval "read tenant" - - # use the default tenant id - if [[ -z "$tenant" ]]; then - tenant="$DEFAULT_TENANT_ID" + + echo "Please select a tenant from the following list:" + for i in "${!tenantids[@]}" + do + echo "[$i] ${tenantids[$i]}" + if [[ "${tenantids[$i]}" == 'iplantc.org' ]]; then + tenantid=$i fi + done + + echo -n "Your choice [$tenantid]: " + eval "read tenant" + + # use the default tenant id + if [[ -z "$tenant" ]]; then + tenant="iplantc.org" fi - fi + re='^[0-9]+$' if [[ "$tenant" =~ $re ]] ; then if [ $tenant -ge ${#tenantids[@]} ]; then - err "Invalid choice. Please select a valid number from 1-${#tenantids[@]} or provide a valid tenant id (ie. "$DEFAULT_TENANT_ID")"; + err "Invalid choice. Please select a valid number from 1-${#tenantids[@]} or provide a valid tenant id (ie. iplantc.org)"; exit else tenant="${tenantids[$tenant]}" @@ -174,7 +150,7 @@ main() { done if [ -z "$tenantid" ]; then - err "Unknown tenant id $tenant. Please provide a valid tenant id to initialize the cli." + err "Unknown tenant id. Please provide a valid tenant id to initialize the cli." exit fi @@ -231,7 +207,6 @@ while [[ $1 = -?* ]]; do -s|--swap) swap=1 ;; -d|--developmenturl) shift; developmenturl=$1 ;; -v|--verbose) verbose=1 ;; - -V|--veryverbose) veryverbose=1; verbose=1 ;; -q|--quiet) quiet=1 ;; -i|--interactive) interactive=1 ;; -f|--force) force=1 ;; @@ -241,10 +216,6 @@ while [[ $1 = -?* ]]; do shift done -if [[ -z "$tenant" ]] && [[ -n "$AGAVE_TENANT" ]]; then - tenant="$AGAVE_TENANT" -fi - # Store the remaining part as arguments. args+=("$@") diff --git a/bin/tenants-list b/bin/tenants-list index ef5cd87..14e186b 100755 --- a/bin/tenants-list +++ b/bin/tenants-list @@ -52,13 +52,13 @@ main() { #echo -n #set -x - cmd="curl -sk ${hosturl%/}/${args}?pretty=true$(pagination)" + cmd="agave-curl -sk ${hosturl%/}/${args}?pretty=true$(pagination)" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk "${hosturl%/}/${args}?pretty=true$(pagination)"` + response=`agave-curl -sk "${hosturl%/}/${args}?pretty=true$(pagination)"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/transforms-list b/bin/transforms-list index 7dd2eab..78b921e 100755 --- a/bin/transforms-list +++ b/bin/transforms-list @@ -61,13 +61,13 @@ main() { transformsurl="$hosturl" fi - cmd="curl -sk -H \"${authheader}\" '${transformsurl}?pretty=true$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" '${transformsurl}?pretty=true$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "${transformsurl}?pretty=true$(pagination)"` + response=`agave-curl -sk -H "${authheader}" "${transformsurl}?pretty=true$(pagination)"` if [[ $(jsonquery "$response" "status") = 'success' ]]; then result=$(format_api_json "$response") diff --git a/bin/uuid-lookup b/bin/uuid-lookup index 07db856..5a0898d 100755 --- a/bin/uuid-lookup +++ b/bin/uuid-lookup @@ -63,13 +63,13 @@ main() { hosturl="$baseuuidurl/$args" - cmd="curl -sk -H \"${authheader}\" '${hosturl}?expand=$expand&pretty=true$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" '${hosturl}?expand=$expand&pretty=true$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "${hosturl}?expand=$expand&pretty=true$(pagination)"` + response=`agave-curl -sk -H "${authheader}" "${hosturl}?expand=$expand&pretty=true$(pagination)"` # resolve the uuid. if successful, parse it if [[ $(jsonquery "$response" "status") = 'success' ]]; then @@ -85,13 +85,13 @@ main() { # convert them to a comma separated list uuids=$(echo "${args[@]}" | sed -e 's/ /,/g') - cmd="curl -sk -H \"${authheader}\" '${hosturl}?uuids=$uuids&expand=$expand&pretty=true$(pagination)'" + cmd="agave-curl -sk -H \"${authheader}\" '${hosturl}?uuids=$uuids&expand=$expand&pretty=true$(pagination)'" if ((veryverbose)); then [ "$piped" -eq 0 ] && log "Calling $cmd" fi - response=`curl -sk -H "${authheader}" "${hosturl}?uuids=$uuids&expand=$expand&pretty=true$(pagination)"` + response=`agave-curl -sk -H "${authheader}" "${hosturl}?uuids=$uuids&expand=$expand&pretty=true$(pagination)"` # resolve the uuid. if successful, parse it if [[ $(jsonquery "$response" "status") = 'success' ]]; then