├── VERSION ├── http ├── log │ └── .gitkeep ├── bin │ ├── HttpMirror │ ├── ngrokup.sh │ ├── tunneldown.sh │ └── tunnelup.sh └── src │ └── HttpMirror.go ├── .dockerignore ├── test ├── bin │ └── tenants-list.bat └── README.md ├── bin ├── tags-common.sh ├── apps-common.sh ├── jobs-common.sh ├── uuid-common.sh ├── files-common.sh ├── clients-common.sh ├── headers-common.sh ├── metadata-common.sh ├── monitors-common.sh ├── postits-common.sh ├── systems-common.sh ├── auth-common.sh ├── profiles-common.sh ├── transforms-common.sh ├── notifications-common.sh ├── requestbin-common.sh ├── json-mirror.sh ├── urldecode ├── tenants-common.sh ├── urlencode ├── options.sh ├── runner.sh ├── richtext ├── python2 │ ├── embedcurl.py │ └── easydict │ │ └── __init__.py ├── jsonpki ├── requestbin-create ├── jobs-delete ├── notifications-fire ├── notifications-delete ├── postits-delete ├── jobs-stop ├── monitors-delete ├── metadata-delete ├── apps-delete ├── tags-delete ├── profiles-delete ├── tenants-list ├── metadata-schema-delete ├── systems-enable ├── monitors-disable ├── monitors-enable ├── systems-disable ├── clients-delete ├── monitors-fire ├── profiles-users-delete ├── postits-list ├── systems-publish ├── apps-erase ├── systems-queues-delete ├── systems-roles-delete ├── systems-unpublish ├── systems-erase ├── apps-disable ├── apps-enable ├── metadata-schema-addupdate ├── requestbin-requests-list ├── clients-subscriptions-list ├── apps-pems-delete ├── systems-delete ├── files-delete ├── systems-clone ├── transforms-list ├── headers-check ├── files-mkdir ├── jobs-pems-update ├── auth-check └── files-rename ├── .gitignore ├── docker └── Dockerfile ├── COPYRIGHT ├── LICENSE └── completion └── README.md /VERSION: -------------------------------------------------------------------------------- 1 | 2.2.6 2 | -------------------------------------------------------------------------------- /http/log/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /http/bin/HttpMirror: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenrbrandt/agave-cli/master/http/bin/HttpMirror -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | /bin/transforms-apply 2 | auth-filter.sh 3 | playground 4 | 5 | auth-switch 6 | transfers-* 7 | bin/actors-* 8 | docker -------------------------------------------------------------------------------- /test/bin/tenants-list.bat: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | @test "tenants-list by id returns tenant id" { 4 | result="$(tenants-list agave.prod)" 5 | [ "$result" = "agave.prod" ] 6 | } 7 | 8 | @test "tenants-list returns multiple tenants" { 9 | result="$(tenants-list | wc -l)" 10 | [ "$result" -ge 1 ] 11 | } -------------------------------------------------------------------------------- /bin/tags-common.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # tags-common.sh 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # URL filter for tags services 8 | # 9 | 10 | filter_service_url() { 11 | if [[ -z $hosturl ]]; then 12 | if ((development)); then 13 | hosturl="$devurl/tags/" 14 | else 15 | hosturl="$baseurl/tags/$version/" 16 | fi 17 | fi 18 | } 19 | -------------------------------------------------------------------------------- /bin/apps-common.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # apps-common.sh 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # URL filter for apps services 8 | # 9 | 10 | filter_service_url() { 11 | if [[ -z $hosturl ]]; then 12 | if ((development)); then 13 | hosturl="$devurl/apps/" 14 | else 15 | hosturl="$baseurl/apps/$version/" 16 | fi 17 | fi 18 | } 19 | 20 | -------------------------------------------------------------------------------- /bin/jobs-common.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # jobs-common.sh 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # URL filter for jobs services 8 | # 9 | 10 | filter_service_url() { 11 | if [[ -z $hosturl ]]; then 12 | if ((development)); then 13 | hosturl="$devurl/jobs/" 14 | else 15 | hosturl="$baseurl/jobs/$version/" 16 | fi 17 | fi 18 | } 19 | 20 | -------------------------------------------------------------------------------- /bin/uuid-common.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # uuid-common.sh 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # URL filter for uuid lookup services 8 | # 9 | filter_service_url() { 10 | if [[ -z $hosturl ]]; then 11 | if ((development)); then 12 | hosturl="$devurl/uuids" 13 | else 14 | hosturl="$baseurl/uuids/$version/" 15 | fi 16 | fi 17 | } 18 | 19 | -------------------------------------------------------------------------------- /bin/files-common.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # files-common.sh 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # URL filter for file services 8 | # 9 | 10 | filter_service_url() { 11 | if [[ -z $hosturl ]]; then 12 | if ((development)); then 13 | hosturl="$devurl/files/" 14 | else 15 | hosturl="$baseurl/files/$version/" 16 | fi 17 | fi 18 | } 19 | 20 | -------------------------------------------------------------------------------- /bin/clients-common.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # clients-common.sh 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # URL filter for client registration services 8 | # 9 | 10 | filter_service_url() { 11 | if [[ -z $hosturl ]]; then 12 | if ((development)); then 13 | hosturl="$devurl/clients/v2" 14 | else 15 | hosturl="$baseurl/clients/v2" 16 | fi 17 | fi 18 | } 19 | -------------------------------------------------------------------------------- /bin/headers-common.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # headers-common.sh 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # URL filter for headers services 8 | # 9 | 10 | filter_service_url() { 11 | if [[ -z $hosturl ]]; then 12 | if ((development)); then 13 | hosturl="$devurl/headers/v0.1" 14 | else 15 | hosturl="$baseurl/headers/v0.1" 16 | fi 17 | fi 18 | } 19 | 20 | -------------------------------------------------------------------------------- /bin/metadata-common.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # metadata-common.sh 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # URL filter for metadata services 8 | # 9 | 10 | filter_service_url() { 11 | if [[ -z $hosturl ]]; then 12 | if ((development)); then 13 | hosturl="$devurl/meta/" 14 | else 15 | hosturl="$baseurl/meta/$version/" 16 | fi 17 | fi 18 | } 19 | 20 | -------------------------------------------------------------------------------- /bin/monitors-common.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # monitors-common.sh 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # URL filter for monitors services 8 | # 9 | 10 | filter_service_url() { 11 | if [[ -z $hosturl ]]; then 12 | if ((development)); then 13 | hosturl="$devurl/monitors/" 14 | else 15 | hosturl="$baseurl/monitors/$version/" 16 | fi 17 | fi 18 | } 19 | -------------------------------------------------------------------------------- /bin/postits-common.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # postits-common.sh 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # URL filter for profiles services 8 | # 9 | 10 | filter_service_url() { 11 | if [[ -z $hosturl ]]; then 12 | if ((development)); then 13 | hosturl="$devurl/postits/" 14 | else 15 | hosturl="$baseurl/postits/$version/" 16 | fi 17 | fi 18 | } 19 | 20 | -------------------------------------------------------------------------------- /bin/systems-common.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # systems-common.sh 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # URL filter for systems services 8 | # 9 | 10 | filter_service_url() { 11 | if [[ -z $hosturl ]]; then 12 | if ((development)); then 13 | hosturl="$devurl/systems" 14 | else 15 | hosturl="$baseurl/systems/$version/" 16 | fi 17 | fi 18 | } 19 | 20 | -------------------------------------------------------------------------------- /bin/auth-common.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # auth-common.sh 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # URL filter for auth services 8 | # 9 | 10 | filter_service_url() { 11 | if [[ -z $hosturl ]]; then 12 | if ((development)); then 13 | hosturl="${devurl}" 14 | else 15 | hosturl="${baseurl}" 16 | fi 17 | fi 18 | 19 | hosturl="${hosturl%/}" 20 | } 21 | 22 | -------------------------------------------------------------------------------- /bin/profiles-common.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # profiles-common.sh 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # URL filter for profiles services 8 | # 9 | 10 | filter_service_url() { 11 | if [[ -z $hosturl ]]; then 12 | if ((development)); then 13 | hosturl="$devurl/profiles/" 14 | else 15 | hosturl="$baseurl/profiles/$version/" 16 | fi 17 | fi 18 | } 19 | 20 | -------------------------------------------------------------------------------- /bin/transforms-common.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # transforms-common.sh 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # URL filter for transforms services 8 | # 9 | 10 | filter_service_url() { 11 | if [[ -z $hosturl ]]; then 12 | if ((development)); then 13 | hosturl="$devurl/transforms/" 14 | else 15 | hosturl="$baseurl/transforms/$version/" 16 | fi 17 | fi 18 | } 19 | 20 | -------------------------------------------------------------------------------- /bin/notifications-common.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # notifications-common.sh 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # URL filter for notifications services 8 | # 9 | 10 | filter_service_url() { 11 | if [[ -z $hosturl ]]; then 12 | if ((development)); then 13 | hosturl="$devurl/notifications/" 14 | else 15 | hosturl="$baseurl/notifications/$version/" 16 | fi 17 | fi 18 | } 19 | -------------------------------------------------------------------------------- /bin/requestbin-common.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # requestbin-common.sh 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # URL filter for requestbin services 8 | # 9 | 10 | filter_service_url() { 11 | if [[ -z $hosturl ]]; then 12 | if ((development)); then 13 | hosturl="https://requestbin.agaveapi.co/" 14 | else 15 | hosturl="https://requestbin.agaveapi.co/" 16 | fi 17 | fi 18 | } 19 | 20 | -------------------------------------------------------------------------------- /bin/json-mirror.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # json-mirror.sh 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # Bash client to the Agave json-mirror api. 8 | # @see https://bitbucket.org/taccaci/agave-json-mirror 9 | # 10 | response=$(echo "${1}" | curl -sk --globoff -X POST -H "Content-Type: application/json" --data-binary @- "https://agaveapi.co/json-mirror?q=${2}") 11 | 12 | if [[ -n "$3" ]]; then 13 | #echo "${response}" | sed 's/^[ \t]*//g' | sed 's/\"//g' 14 | echo "${response}" | sed 's/^[ \t]*//g' 15 | else 16 | echo "${response}" | sed 's/^\s+\"/"/g' | sed 's/\[//g' | sed 's/\]//g' | sed 's/\"//g' | sed 's/,$//g' | sed 's/ //g' 17 | fi 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binary targets 2 | target 3 | *~ 4 | 5 | # Intellij metadata files 6 | *.idea 7 | *.ids 8 | *.iml 9 | *.eml 10 | *.ids 11 | *.imp 12 | *.ipr 13 | *.iws 14 | 15 | # Eclipse metadata files 16 | .project 17 | .settings 18 | .classpath 19 | 20 | # Apple system files 21 | .DS_Store 22 | .AppleDouble 23 | .LSOverride 24 | Icon 25 | 26 | # Thumbnails 27 | ._* 28 | 29 | # Files that might appear on external disk 30 | .Spotlight-V100 31 | .Trashes 32 | 33 | # Dev scripts 34 | transforms-apply 35 | auth-filter.sh 36 | auth-switch-filter.sh 37 | playground 38 | actors-* 39 | transfers-* 40 | 41 | # test data 42 | test/data/* 43 | TestReport-case.xml 44 | *.pyc 45 | -------------------------------------------------------------------------------- /bin/urldecode: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # urldecode 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # Pure Bash urldecoding function 8 | # @see https://gist.github.com/cdown/1163649#file-gistfile1-sh-L4 9 | # 10 | 11 | _urldecode() { 12 | # urldecode 13 | 14 | local url_encoded="${1//+/ }" 15 | printf '%b' "${url_encoded//%/\\x}" 16 | } 17 | 18 | if [[ -n "$@" ]]; then 19 | _urldecode "$@" 20 | else 21 | oIFS="$IFS" 22 | IFS="[]" read decoded_string 23 | IFS="$oIFS" 24 | unset oIFS 25 | 26 | # return the decoded string from stdin or pipe 27 | # if no value, return nothing 28 | [ -n "$decoded_string" ] && _urldecode "$decoded_string" 29 | fi -------------------------------------------------------------------------------- /bin/tenants-common.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # tenants-common.sh 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # URL filter for tenants services 8 | # 9 | 10 | filter_service_url() { 11 | if [[ -z $hosturl ]]; then 12 | if (($development)); then 13 | if [[ -n "$AGAVE_DEV_TENANTS_API_BASEURL" ]]; then 14 | hosturl="$AGAVE_DEV_TENANTS_API_BASEURL/tenants" 15 | elif [[ -n "$devurl" ]]; then 16 | hosturl="${devurl}/tenants" 17 | else 18 | hosturl="https://agaveapi.co/tenants/" 19 | fi 20 | else 21 | if [[ -n "$AGAVE_TENANTS_API_BASEURL" ]]; then 22 | hosturl="$AGAVE_TENANTS_API_BASEURL" 23 | else 24 | hosturl="https://agaveapi.co/tenants/" 25 | fi 26 | fi 27 | fi 28 | 29 | #hosturl="${hosturl%&}" 30 | } 31 | -------------------------------------------------------------------------------- /bin/urlencode: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # urlencode 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # Pure Bash urlencoding function 8 | # @see https://gist.github.com/cdown/1163649#file-gistfile1-sh-L4 9 | # 10 | 11 | _urlencode() { 12 | # urlencode 13 | old_lc_collate=$LC_COLLATE 14 | local LC_COLLATE=C 15 | 16 | local length="${#1}" 17 | for (( i = 0; i < length; i++ )); do 18 | local c="${1:i:1}" 19 | case $c in 20 | [a-zA-Z0-9.~_-]) printf "$c" ;; 21 | *) printf '%%%02X' "'$c" ;; 22 | esac 23 | done 24 | 25 | LC_COLLATE=$old_lc_collate 26 | } 27 | 28 | if [[ -n "$@" ]]; then 29 | _urlencode "$@" 30 | else 31 | oIFS="$IFS" 32 | IFS="[]" read encoded_string 33 | IFS="$oIFS" 34 | unset oIFS 35 | 36 | # return the decoded string from stdin or pipe 37 | # if no value, return nothing 38 | [ -n "$encoded_string" ] && _urlencode "$encoded_string" 39 | fi -------------------------------------------------------------------------------- /http/bin/ngrokup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | #################################################### 4 | # Establish a tunnel outboud from the container so 5 | # external services can address it directly 6 | #################################################### 7 | 8 | if [ "$1" = "/bin/sh" ]; then 9 | shift 10 | fi 11 | 12 | if [ -n "$HTTPS_PORT" ]; then 13 | FWD="`echo $HTTPS_PORT | sed 's|^tcp://||'`" 14 | elif [ -n "$HTTP_PORT" ]; then 15 | FWD="`echo $HTTP_PORT | sed 's|^tcp://||'`" 16 | elif [ -n "$APP_PORT" ]; then 17 | FWD="`echo $APP_PORT | sed 's|^tcp://||'`" 18 | fi 19 | 20 | ARGS="" 21 | 22 | if [ -n "$NGROK_HEADER" ]; then 23 | ARGS="$ARGS -host-header=$NGROK_HEADER " 24 | fi 25 | 26 | PROTOCOL="http" 27 | 28 | if [ "$NGROK_PROTOCOL" == "TCP" ]; then 29 | PROTOCOL="tcp " 30 | fi 31 | 32 | ARGS="$PROTOCOL $ARGS -config /.ngrok2/ngrok.yml -log stdout $FWD" 33 | 34 | exec /bin/ngrok $ARGS 2>&1 > $AGAVE_CLI_HOME/http/log/ngrok.log 35 | -------------------------------------------------------------------------------- /http/src/HttpMirror.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "log" 7 | "net/http" 8 | "net/http/httputil" 9 | "os" 10 | ) 11 | 12 | var mirrorlogpath = flag.String("log", "httpmirror.log", "Enter location of request log") 13 | var port = flag.String("port", "3000", "Enter port for web server") 14 | 15 | func main() { 16 | // parse the global parameters from the command line 17 | flag.Parse() 18 | http.HandleFunc("/", httpmirror) 19 | 20 | fmt.Println("Server started on port: ", *port) 21 | fmt.Println("Server requests logged to: ", *mirrorlogpath) 22 | 23 | log.Fatal(http.ListenAndServe(":"+*port, nil)) 24 | } 25 | 26 | func httpmirror(w http.ResponseWriter, r *http.Request) { 27 | w.Write([]byte("Agave Webhook Mirror")) 28 | var dump, _ = httputil.DumpRequest(r, true) 29 | 30 | write(dump) 31 | w.Write(dump) 32 | } 33 | 34 | // func port() string { 35 | // // port := flag.String("port", "3000", "Enter port for web server") 36 | // flag.Parse() 37 | // return *port 38 | // } 39 | 40 | func write(s []byte) { 41 | 42 | f, err1 := os.OpenFile(*mirrorlogpath, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666) 43 | if err1 != nil { 44 | fmt.Println(err1.Error()) 45 | } 46 | defer f.Close() 47 | 48 | fmt.Println(string(s)) 49 | 50 | _, err2 := f.Write(s) 51 | if err2 != nil { 52 | log.Panic(err2) 53 | } 54 | 55 | f.Sync() 56 | } 57 | -------------------------------------------------------------------------------- /http/bin/tunneldown.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # get pwd of the script 4 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 | PID_DIR="$( cd "$DIR/.." && pwd );" 6 | SUCCESS=1 7 | 8 | #################################################### 9 | # Kill the HttpMirror process 10 | #################################################### 11 | 12 | MIRROR_PID=$(ps x | grep "HttpMirror" | grep -iv "grep" | awk '{ printf("%s\n", $1); }') 13 | if [[ -n "$MIRROR_PID" ]]; then 14 | echo "Stopping HttpMirror server $MIRROR_PID..." 15 | kill -9 $MIRROR_PID 16 | if [ ! $? ]; then 17 | echo "Failed to kill HttpMirror server!" > 2 18 | SUCCESS=0 19 | fi 20 | fi 21 | 22 | #################################################### 23 | # Kill the ngrok process 24 | #################################################### 25 | 26 | NGROK_PID=$(ps x | grep "ngrok" | grep -iv "grep" | awk '{ printf("%s\n", $1); }') 27 | if [[ -n "$NGROK_PID" ]]; then 28 | echo "Stopping ngrok client $NGROK_PID..." 29 | kill -9 $NGROK_PID 30 | if [ ! $? ]; then 31 | echo "Failed to kill ngrok client!" > 2 32 | SUCCESS=0 33 | fi 34 | fi 35 | 36 | # clean up pid files for both services 37 | rm -f "$PID_DIR/HttpMirror.pid" 38 | rm -f "$PID_DIR/ngrok.pid" 39 | 40 | # return proper exit code 41 | if (($SUCCESS)); then 42 | exit 0; 43 | else 44 | exit 1; 45 | fi -------------------------------------------------------------------------------- /bin/options.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # options.sh 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # Parses the command line options 8 | 9 | # Boilerplate {{{ 10 | 11 | # Iterate over options breaking -ab into -a -b when needed and --foo=bar into 12 | # --foo bar 13 | optstring=h 14 | unset options 15 | while (($#)); do 16 | case $1 in 17 | # If option is of type -ab 18 | -[!-]?*) 19 | # Loop over each character starting with the second 20 | for ((i=1; i < ${#1}; i++)); do 21 | c=${1:i:1} 22 | 23 | # Add current char to options 24 | options+=("-$c") 25 | 26 | # If option takes a required argument, and it's not the last char make 27 | # the rest of the string its argument 28 | if [[ $optstring = *"$c:"* && ${1:i+1} ]]; then 29 | options+=("${1:i+1}") 30 | break 31 | fi 32 | done 33 | ;; 34 | # If option is of type --foo=bar 35 | --?*=*) options+=("${1%%=*}" "${1#*=}") ;; 36 | # add --endopts for -- 37 | --) options+=(--endopts) ;; 38 | # Otherwise, nothing special 39 | *) options+=("$1") ;; 40 | esac 41 | shift 42 | done 43 | set -- "${options[@]}" 44 | unset options 45 | 46 | # Set our rollback function for unexpected exits. 47 | trap rollback INT TERM EXIT 48 | 49 | # A non-destructive exit for when the script exits naturally. 50 | safe_exit() { 51 | trap - INT TERM EXIT 52 | exit 53 | } 54 | 55 | # }}} 56 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | ###################################################### 2 | # 3 | # Agave CLI Image 4 | # Tag: agave-cli 5 | # 6 | # https://github.com/agaveplatform/agave-cli 7 | # 8 | # This container the Agave CLI and can be used for 9 | # parallel environment testing. 10 | # 11 | # docker run -it -v $HOME/.agave:/root/.agave agaveapi/cli bash 12 | # 13 | ###################################################### 14 | 15 | FROM ubuntu:trusty 16 | 17 | MAINTAINER Rion Dooley 18 | 19 | RUN apt-get update && \ 20 | apt-get install -y git vim.tiny curl jq && \ 21 | 22 | curl -L -sk -o /usr/local/bin/jq "https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64" && \ 23 | chmod a+x /usr/local/bin/jq 24 | 25 | 26 | # install the cli from git 27 | git clone https://github.com/agaveplatform/agave-cli /usr/local/agave-cli && \ 28 | chmod +x /usr/local/agave-cli/bin/* 29 | 30 | # set user's default env. This won't get sourced, but is helpful 31 | echo HOME=/root >> /root/.bashrc && \ 32 | echo PATH=/usr/local/agave-cli/bin:$PATH >> /root/.bashrc && \ 33 | echo AGAVE_CACHE_DIR=/root/.agave >> /root/.bashrc && \ 34 | echo AGAVE_CACHE_DIR=/root/.agave >> /root/.bashrc && \ 35 | 36 | echo export PS1=\""\[\e[32;4m\]agave-cli\[\e[0m\]:\u@\h:\w$ "\" >> /root/.bashrc 37 | 38 | /usr/local/agave-cli/bin/tenants-init -t agave.prod 39 | 40 | ENV ENV /root/.bashrc 41 | 42 | VOLUME /root/.agave 43 | 44 | # Runtime parameters. Start a shell by default 45 | CMD "/bin/bash" 46 | -------------------------------------------------------------------------------- /COPYRIGHT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, University of Texas at Austin 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the University of Texas at Austin nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Texas Advanced Computing Center 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the University of Texas at Austin nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /test/README.md: -------------------------------------------------------------------------------- 1 | ## Agave CLI Test Suite 2 | 3 | This is the test suite for the Agave CLI. It is a work in progress. Please consider contributing tests to help expand coverage. 4 | 5 | ### Requirements 6 | 7 | These test rely upon the [Bash Automated Testing System (Bats)](https://github.com/sstephenson/bats). Bats is a TAP-compliant testing framework for Bash. For more information on Bats, please see the project's [wiki page](https://github.com/sstephenson/bats/wiki). 8 | 9 | You can install Bats using your favorite package manager. Instructions are provided on the [Bats installation](https://github.com/sstephenson/bats/wiki/Install-Bats-Using-a-Package) page. 10 | 11 | ``` 12 | # Ubuntu/Debian 13 | sudo apt-get install bats 14 | 15 | # CentOS/RHEL 16 | sudo yum install bats 17 | 18 | # OSX 19 | brew install bats 20 | ``` 21 | 22 | ### Running 23 | 24 | To run the entire test suite, point Bats at the `test` folder. 25 | 26 | ``` 27 | bats test/bin/* 28 | ``` 29 | 30 | To run tests for individual commands, run the `.bat` file for the command you care about. 31 | 32 | ``` 33 | # run tests for just the tenants-list command 34 | bats test/tenants-list.bat 35 | 36 | # run tests for the apps-search and jobs-search commands 37 | bats test/apps-search.bat test/jobs-search.bat 38 | 39 | # run tests for all the jobs-* commands 40 | bats test/jobs-* 41 | ``` 42 | 43 | ### Test data 44 | 45 | Some tests require valid compute and data resources to properly run. In these situations, the CLI tests will attempt use your default compute and storage systems. If you do not have any default compute and storage systems defined, the tests will attempt to start up a docker container locally and use that as a sandbox system. You can override this behavior by defining your own system definitions in `test/data/storage.json` and `test/data/compute.json`. 46 | 47 | -------------------------------------------------------------------------------- /http/bin/tunnelup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | VERBOSE=1 4 | 5 | # get pwd of the script 6 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 7 | 8 | # HTTP_PORT defaults to 3000 9 | if [[ -z "$HTTP_PORT" ]]; then 10 | HTTP_PORT=3000 11 | fi 12 | 13 | 14 | #################################################### 15 | # Start a simple we server to listen for webhook 16 | # from Agave and log them to a file 17 | #################################################### 18 | 19 | # start the http mirror server. 20 | export WEBHOOK_LOG=$AGAVE_CLI_HOME/http/log/httpmirror.log 21 | if [[ ! -f "$WEBHOOK_LOG" ]]; then 22 | touch "$WEBHOOK_LOG" 23 | fi 24 | ((VERBOSE)) && printf "Starting an Agave HttpMirror server..." 25 | $DIR/HttpMirror -port $HTTP_PORT -log $WEBHOOK_LOG >> /dev/null & 26 | ((VERBOSE)) && echo "done" 27 | 28 | #################################################### 29 | # Start a ngrok client so external services can 30 | # access the webhook server from a public URL 31 | #################################################### 32 | 33 | ((VERBOSE)) && printf "Starting a ngrok client..." 34 | $DIR/ngrokup.sh & 35 | 36 | i=30 37 | while : ; do 38 | sleep 1 39 | ((VERBOSE)) && printf "." 40 | ((i=i-1)) 41 | tunnel=$(curl -s http://localhost:4040/api/tunnels | jq -r ".tunnels[0].public_url") 42 | [[ "$tunnel" = 'null' ]] && (( $i )) || break 43 | done 44 | ((VERBOSE)) && echo "done" 45 | 46 | WEBHOOK_URL="$tunnel" 47 | 48 | echo "#############################################################" 49 | echo "# A http mirror server has been started and published at: " 50 | echo "#" 51 | echo "# $WEBHOOK_URL " 52 | echo "#" 53 | echo "# All webhooks sent to that url will be logged at: " 54 | echo "#" 55 | echo "# $WEBHOOK_LOG " 56 | echo "#" 57 | echo "# Run these commands to configure your environment: " 58 | echo "#" 59 | echo "# export WEBHOOK_LOG=$WEBHOOK_LOG " 60 | echo "# export WEBHOOK_URL=$WEBHOOK_URL " 61 | echo "#############################################################" -------------------------------------------------------------------------------- /completion/README.md: -------------------------------------------------------------------------------- 1 | # Agave CLI Bash Completion 2 | 3 | This script provides completion of: 4 | - commands and their options 5 | - filepaths 6 | - search terms & operators 7 | 8 | ## Installation 9 | 10 | To enable the completions either: 11 | 12 | > place this file in `/etc/bash_completion.d` 13 | 14 | or 15 | 16 | > copy this file to e.g. ~/.agave-completion.sh and add the line below to your .bashrc after bash completion features are loaded `. ~/.agave-completion.sh` 17 | 18 | ## Configuration 19 | 20 | For several commands, the amount of completions can be configured by setting environment variables. This is generally helpful when calls to fetch remote directory listings slow down the responsiveness of the CLI. 21 | 22 | ``` 23 | AGAVE_CLI_COMPLETION_SHOW_FILE_PATHS 24 | AGAVE_CLI_COMPLETION_SHOW_FILE_IMPORTS 25 | AGAVE_CLI_COMPLETION_SHOW_JOB_OUTPUTS_PATHS 26 | "no" - Disable autocomplete (default) 27 | "yes" - Autocomplete file and folder names 28 | ``` 29 | 30 | You can also enable completion caching to speed up frequent interactions with the CLI. Completion caching is controlled on a service-by service basis through environment variables. Completion caching does not reflect the request/response from the actual CLI calls. Each service's completion cache is stored separately from the cli response cache and managed independently. 31 | 32 | ``` 33 | AGAVE_CLI_COMPLETION_CACHE_APPS 34 | AGAVE_CLI_COMPLETION_CACHE_CLIENTS 35 | AGAVE_CLI_COMPLETION_CACHE_FILES 36 | AGAVE_CLI_COMPLETION_CACHE_JOBS 37 | AGAVE_CLI_COMPLETION_CACHE_METADATA 38 | AGAVE_CLI_COMPLETION_CACHE_MONITORS 39 | AGAVE_CLI_COMPLETION_CACHE_NOTIFICATIONS 40 | AGAVE_CLI_COMPLETION_CACHE_POSTITS 41 | AGAVE_CLI_COMPLETION_CACHE_PROFILES 42 | AGAVE_CLI_COMPLETION_CACHE_SYSTEMS 43 | AGAVE_CLI_COMPLETION_CACHE_TAGS 44 | AGAVE_CLI_COMPLETION_CACHE_TENANTS 45 | AGAVE_CLI_COMPLETION_CACHE_TRANSFERS 46 | AGAVE_CLI_COMPLETION_CACHE_TRANFORMS 47 | "no" - Disable autocomplete (default) 48 | "yes" - Autocomplete file and folder names 49 | ``` 50 | 51 | You can configure the lifetime (seconds) of all caches globally using environment variables. 52 | 53 | ``` 54 | AGAVE_CLI_COMPLETION_CACHE_LIFETIME 55 | "" - No value, defaults to 60 (1 hour) 56 | 0 - Disables cache (default) 57 | > 0 - Number of minutes before cache invalidates 58 | ``` 59 | -------------------------------------------------------------------------------- /bin/runner.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # runner.sh 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # Main processing logic for the scripts 8 | #set -x 9 | # Run it {{{ 10 | 11 | # Uncomment this line if the script requires root privileges. 12 | # [[ $UID -ne 0 ]] && die "You need to be root to run this script" 13 | 14 | # If either credential is missing, force interactive login 15 | #if [ -n "$access_token" ]; then 16 | if [ -n "$apikey" ] || [ -n "$apisecret" ] || [ -n "$apisecret" ] || [ -n "$apisecret" ]; 17 | then 18 | #echo "apikey '$apikey' is not null" 19 | interactive=1 20 | #elif [ -n "$apisecret" ]; then 21 | #echo "apisecret '$apisecret' is not null" 22 | # interactive=1 23 | #elif [ -n "$username" ]; then 24 | #echo "username '$username' is not null" 25 | # interactive=1 26 | #elif [ -n "$password" ]; then 27 | #echo "password '$password' is not null" 28 | # interactive=1 29 | else 30 | #echo "Loooking for stored credentials" 31 | # Otherwise use the cached credentials if available 32 | if [ "$disable_cache" -ne 1 ]; then 33 | tokenstore=$(kvget current) 34 | if [ -n "$tokenstore" ]; then 35 | #echo "Found for stored credentials" 36 | jsonval apisecret "${tokenstore}" "apisecret" 37 | jsonval apikey "${tokenstore}" "apikey" 38 | jsonval username "${tokenstore}" "username" 39 | if [ -z "$access_token" ]; then 40 | jsonval access_token "${tokenstore}" "access_token" 41 | fi 42 | jsonval refresh_token "${tokenstore}" "refresh_token" 43 | 44 | # Mechanism to auto-refresh expired bearer tokens 45 | if [ -n "$refresh_token" ]; then 46 | jsonval created_at "${tokenstore}" "created_at" 47 | jsonval expires_in "${tokenstore}" "expires_in" 48 | if [ `date +%s` -gt $(expr $created_at + $expires_in) ]; then 49 | #echo "Token exists and is expired. Refreshing..." 50 | auto_auth_refresh 51 | jsonval access_token "$(kvget current)" "access_token" 52 | jsonval refresh_token "$(kvget current)" "refresh_token" 53 | fi 54 | fi 55 | fi 56 | fi 57 | 58 | if [ -z "$access_token" ]; then 59 | interactive=1 60 | fi 61 | fi 62 | 63 | if ((interactive)); then 64 | prompt_options 65 | fi 66 | 67 | # Adjust the service url for development 68 | filter_service_url 69 | 70 | # Force a trailing slash if they didn't specify one in the custom url 71 | hosturl=${hosturl%/} 72 | hosturl="$hosturl/" 73 | 74 | # Delegate logic from the `main` function 75 | authheader=$(get_auth_header) 76 | main 77 | 78 | # This has to be run last not to rollback changes we've made. 79 | safe_exit 80 | 81 | # }}} 82 | -------------------------------------------------------------------------------- /bin/richtext: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This is an accessory file currently used by the rich text engine. The rich flag 4 | # will grep out the first occurrence of the appropriate basename located in this file. 5 | # This makes it easy to modify which fields are shown in rich text format. 6 | 7 | ### apps commands ### 8 | apps-history: status createdBy created description 9 | apps-list: id executionSystem revision isPublic lastModified 10 | apps-search: id executionSystem revision isPublic lastModified 11 | 12 | ### auth commands ### 13 | auth-tokens-create: access_token refresh_token expires_in 14 | 15 | ### clients commands ### 16 | clients-list: name consumerKey callbackUrl 17 | clients-create: name consumerKey callbackUrl 18 | 19 | clients-subscriptions-list: apiName apiVersion apiStatus tier apiProvider apiContext 20 | clients-subscriptions-update: apiName apiVersion apiStatus tier apiProvider apiContext 21 | 22 | ### files commands ### 23 | files-history: status created description 24 | files-list: name length permissions type lastModified 25 | 26 | 27 | ### jobs commands ### 28 | jobs-history: status created description 29 | jobs-list: name created startTime endTime status 30 | jobs-output-list: name length permission type lastModified 31 | jobs-search: id name owner executionSystem appId status 32 | jobs-tail: id averageRate totalBytes totalBytesTransferred 33 | jobs-submit: id name owner executionSystem appId status 34 | jobs-resubmit: id name owner executionSystem appId status 35 | jobs-status: id status 36 | 37 | ### metadata commands ### 38 | metadata-list: uuid owner name created lastUpdated 39 | metadata-schema-list: uuid owner schema.title schema.type created lastUpdated 40 | 41 | ### profiles commands ### 42 | profiles-list: firstName lastName username email institution 43 | 44 | ### systems commands ### 45 | systems-history: status createdBy created description 46 | systems-list: id type status public default lastUpdated 47 | systems-queues-list: name maxJobs maxNodes maxProcessorsPerNode maxMemoryPerNode maxRequestedTime 48 | systems-roles-list: username role 49 | systems-search: id type status public default lastUpdated 50 | 51 | ### tenants commands ### 52 | tenants-list: tenantCode name baseUrl contact.[].name contact.[].email 53 | 54 | ### notifications commands ### 55 | notifications-list: id event persistent status url 56 | notifications-search: id event persistent status url 57 | 58 | ### tenants commands ### 59 | monitors-list: id target updateSystemStatus active frequency lastSuccess lastUpdated 60 | monitors-checks-list: id target updateSystemStatus active frequency lastSuccess lastUpdated 61 | -------------------------------------------------------------------------------- /bin/python2/embedcurl.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # embedcurl.py 3 | # 4 | # A Python 2.7 command line utility for exporting curl commands to 5 | # embedcurl.io and hurl.it references you can share 6 | # 7 | 8 | import json, sys, argparse, re, urllib, base64 9 | from operator import attrgetter 10 | 11 | debug = False 12 | 13 | def parse_args(): 14 | parser = argparse.ArgumentParser(prog="embedcurl.py", description="A command line utility for exporting curl commands to embedcurl.io and hurl.it references you can share .") 15 | 16 | parser.add_argument("-v", "--verbose", action='store_true', default=False, 17 | help="Show full embed code for the curl statement") 18 | parser.add_argument("-V", "--veryverbose", action='store_true', default=False, 19 | help="Show request and embed codes") 20 | parser.add_argument("-H", "--hurlit", action='store_true', default=True, 21 | help="Show only the hurl.it url to this curl command") 22 | parser.add_argument('input', nargs='?', type=argparse.FileType('r'), default=sys.stdin, 23 | help="The file containing the curl command to import or stdin if provided.") 24 | 25 | args = parser.parse_args() 26 | 27 | return args 28 | 29 | def encodeURIComponent(str): 30 | def replace(match): 31 | return "%" + hex( ord( match.group() ) )[2:].upper() 32 | return re.sub(r"([^0-9A-Za-z!'()*\-._~])", replace, str.encode('utf-8') ) 33 | def unescape(str): 34 | def replace(match): 35 | return unichr(int(match.group(1), 16)) 36 | return re.sub(r'%u([a-fA-F0-9]{4}|[a-fA-F0-9]{2})', replace, str) 37 | 38 | def main(): 39 | 40 | global debug 41 | 42 | args = parse_args() 43 | 44 | debug = args.debug 45 | 46 | response = '' 47 | curly = base64.b64encode(args.input.read()) 48 | curly = re.sub(r'o=$', '==', curly) 49 | 50 | remotequery = 'https://www.embedcurl.com/view?curl=' + curly 51 | 52 | if args.veryverbose: 53 | 54 | print "Calling " + remotequery + "\n" 55 | 56 | response = urllib.urlopen(remotequery).read() 57 | 58 | if args.hurlit or True: 59 | 60 | print 'Showing hurl.it url here' 61 | p = re.compile('') 62 | hurls = p.findall(response) 63 | 64 | if len(hurls) > 0: 65 | print hurls[0] 66 | else: 67 | raise Exception('No hurl.it url found') 68 | 69 | if args.verbose or args.veryverbose : 70 | 71 | print response + "\n" 72 | 73 | if __name__ == "__main__": 74 | try: 75 | main() 76 | except Exception as e: 77 | if debug: 78 | raise 79 | else: 80 | print e -------------------------------------------------------------------------------- /bin/python2/easydict/__init__.py: -------------------------------------------------------------------------------- 1 | class EasyDict(dict): 2 | """ 3 | Get attributes 4 | 5 | >>> d = EasyDict({'foo':3}) 6 | >>> d['foo'] 7 | 3 8 | >>> d.foo 9 | 3 10 | >>> d.bar 11 | Traceback (most recent call last): 12 | ... 13 | AttributeError: 'EasyDict' object has no attribute 'bar' 14 | 15 | Works recursively 16 | 17 | >>> d = EasyDict({'foo':3, 'bar':{'x':1, 'y':2}}) 18 | >>> isinstance(d.bar, dict) 19 | True 20 | >>> d.bar.x 21 | 1 22 | 23 | Bullet-proof 24 | 25 | >>> EasyDict({}) 26 | {} 27 | >>> EasyDict(d={}) 28 | {} 29 | >>> EasyDict(None) 30 | {} 31 | >>> d = {'a': 1} 32 | >>> EasyDict(**d) 33 | {'a': 1} 34 | 35 | Set attributes 36 | 37 | >>> d = EasyDict() 38 | >>> d.foo = 3 39 | >>> d.foo 40 | 3 41 | >>> d.bar = {'prop': 'value'} 42 | >>> d.bar.prop 43 | 'value' 44 | >>> d 45 | {'foo': 3, 'bar': {'prop': 'value'}} 46 | >>> d.bar.prop = 'newer' 47 | >>> d.bar.prop 48 | 'newer' 49 | 50 | 51 | Values extraction 52 | 53 | >>> d = EasyDict({'foo':0, 'bar':[{'x':1, 'y':2}, {'x':3, 'y':4}]}) 54 | >>> isinstance(d.bar, list) 55 | True 56 | >>> from operator import attrgetter 57 | >>> map(attrgetter('x'), d.bar) 58 | [1, 3] 59 | >>> map(attrgetter('y'), d.bar) 60 | [2, 4] 61 | >>> d = EasyDict() 62 | >>> d.keys() 63 | [] 64 | >>> d = EasyDict(foo=3, bar=dict(x=1, y=2)) 65 | >>> d.foo 66 | 3 67 | >>> d.bar.x 68 | 1 69 | 70 | Still like a dict though 71 | 72 | >>> o = EasyDict({'clean':True}) 73 | >>> o.items() 74 | [('clean', True)] 75 | 76 | And like a class 77 | 78 | >>> class Flower(EasyDict): 79 | ... power = 1 80 | ... 81 | >>> f = Flower() 82 | >>> f.power 83 | 1 84 | >>> f = Flower({'height': 12}) 85 | >>> f.height 86 | 12 87 | >>> f['power'] 88 | 1 89 | >>> sorted(f.keys()) 90 | ['height', 'power'] 91 | """ 92 | def __init__(self, d=None, **kwargs): 93 | if d is None: 94 | d = {} 95 | if kwargs: 96 | d.update(**kwargs) 97 | for k, v in d.items(): 98 | setattr(self, k, v) 99 | # Class attributes 100 | for k in self.__class__.__dict__.keys(): 101 | if not (k.startswith('__') and k.endswith('__')): 102 | setattr(self, k, getattr(self, k)) 103 | 104 | def __setattr__(self, name, value): 105 | if isinstance(value, (list, tuple)): 106 | value = [self.__class__(x) 107 | if isinstance(x, dict) else x for x in value] 108 | else: 109 | value = self.__class__(value) if isinstance(value, dict) else value 110 | super(EasyDict, self).__setattr__(name, value) 111 | super(EasyDict, self).__setitem__(name, value) 112 | 113 | __setitem__ = __setattr__ 114 | 115 | 116 | if __name__ == "__main__": 117 | import doctest 118 | doctest.testmod() 119 | -------------------------------------------------------------------------------- /bin/jsonpki: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Name: jsonpki.sh 4 | # 5 | # Author: Rion Dooley - deardooley 6 | # 7 | # Description: This is a utility script to serialize keys and passwords into 8 | # strings that can be included safely in json objects and sent to a remote 9 | # server. There are surely other ways to do this, but this seems to work well 10 | # in situations such as creating system descriptions for use in the Agave 11 | # platform. 12 | # 13 | 14 | usage() { 15 | echo -n "$(basename $0) [CMD] [OPTIONS] [PATH | -] 16 | 17 | This script serializes and delimits various kinds of credentials 18 | in JSON friendly way. Specify the credential type and either the 19 | path to the file you would like to serialize or a dash, '-', if 20 | providing the contents via stdin. You can also pipe directly into 21 | this script just specifying the command. 22 | 23 | Commands: 24 | --public Serialize a public key 25 | --private Serialize a private key (default) 26 | --password Serialize a password 27 | 28 | Options: 29 | -h This help message 30 | 31 | " 32 | } 33 | 34 | out() { 35 | echo $@ 36 | } 37 | 38 | die() { 39 | out "$@"; exit 1; 40 | } >&2 41 | 42 | err() { 43 | if ((piped)); then 44 | out "$@" 45 | else 46 | printf '%b\n' "\033[1;31m$@\033[0m" 47 | fi 48 | } >&2 49 | 50 | main() { 51 | 52 | if [[ "$#" -eq 2 ]]; then 53 | 54 | if [[ "$1" = "-h" ]]; then 55 | 56 | usage 57 | 58 | # make sure the input is valid 59 | elif [ ! -e "$2" -a "$2" != '-' ]; then 60 | 61 | err "Invalid input specified" 62 | 63 | # public keys are escaped one way 64 | elif [[ "$1" = "--public" ]]; then 65 | 66 | out $(cat $2 | sed -e 's/\\/\\\\/g' -e 's/\//\\\//g' -e 's/&/\\\&/g') 67 | #out $(cat $2 | sed -e 's/\\/\\\\/g' -e 's/&/\\\&/g') 68 | 69 | # passwords are escaped another 70 | elif [[ "$1" = "--password" ]]; then 71 | 72 | out $(cat $2 | sed -e 's/\\/\\\\/g' -e 's/\//\\\//g' -e 's/&/\\\&/g' -e 's/\$/\\\$/g') 73 | #out $(cat $2 | sed -e 's/\\/\\\\/g' -e 's/&/\\\&/g' -e 's/\$/\\\$/g') 74 | 75 | elif [[ "$1" = "--private" ]]; then 76 | 77 | # private keys are escaped yet one way 78 | out $(cat $2 | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/\\n/g' -e 's/\//\\\//g') 79 | #out $(cat - | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/\\\\n/g' ) 80 | 81 | else 82 | 83 | err "Invalid command specified" 84 | 85 | fi 86 | 87 | # if they are piping 88 | elif [[ -t 1 ]]; then 89 | 90 | if [[ "$1" = "-h" ]]; then 91 | 92 | usage 93 | 94 | elif [[ "$1" = "--public" ]]; then 95 | 96 | out $(cat - | sed -e 's/\\/\\\\/g' -e 's/\//\\\//g' -e 's/&/\\\&/g') 97 | #out $(cat - | sed -e 's/\\/\\\\/g' -e 's/&/\\\&/g') 98 | 99 | # passwords are escaped another 100 | elif [[ "$1" = "--password" ]]; then 101 | 102 | out $(cat - | sed -e 's/\\/\\\\/g' -e 's/\//\\\//g' -e 's/&/\\\&/g' -e 's/\$/\\\$/g') 103 | #out $(cat - | sed -e 's/\\/\\\\/g' -e 's/&/\\\&/g' -e 's/\$/\\\$/g') 104 | 105 | elif [[ "$1" = "--private" ]]; then 106 | 107 | # private keys are escaped yet one way 108 | out $(cat - | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/\\\\n/g' -e 's/\//\\\//g') 109 | #out $(cat - | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/\\\\n/g' ) 110 | 111 | else 112 | 113 | err "Invalid command specified" 114 | 115 | fi 116 | 117 | else 118 | 119 | usage; 120 | 121 | fi 122 | } 123 | 124 | # set -x 125 | main $@ 126 | -------------------------------------------------------------------------------- /bin/requestbin-create: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # requestbin-create 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It create an ephimeral requestbin using Agave's hosted service. 9 | # 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | source "$DIR/common.sh" 14 | 15 | # Script logic -- TOUCH THIS {{{ 16 | 17 | # A list of all variables to prompt in interactive mode. These variables HAVE 18 | # to be named exactly as the longname option definition in usage(). 19 | interactive_opts=() 20 | 21 | # Print usage 22 | usage() { 23 | echo -n "$(basename $0) [OPTION]... 24 | 25 | Creates a new RequestBin instance you can use as a callback 26 | for webhook testing. 27 | 28 | Options: 29 | -H, --hosturl URL of the service 30 | -d, --development Run in dev mode using default dev server 31 | -f, --force Skip all user interaction 32 | -i, --interactive Prompt for values 33 | -q, --quiet Quiet (no output) 34 | -v, --verbose Verbose output 35 | -V, --veryverbose Very verbose output 36 | -h, --help Display this help and exit 37 | --version Output version information and exit 38 | " 39 | } 40 | 41 | ################################################################## 42 | ################################################################## 43 | # Begin Script Logic # 44 | ################################################################## 45 | ################################################################## 46 | 47 | source "$DIR/requestbin-common.sh" 48 | 49 | main() { 50 | #echo -n 51 | #set -x 52 | 53 | cmd="curl -sk -X POST '${hosturl}api/v1/bins'" 54 | 55 | if ((veryverbose)); then 56 | [ "$piped" -eq 0 ] && log "Calling $cmd" 57 | fi 58 | 59 | response=`curl -sk -X POST ${hosturl}api/v1/bins` 60 | 61 | if [[ -n $(jsonquery "$response" "name") ]]; then 62 | result=$(format_api_json "$response") 63 | success "$result" 64 | else 65 | errorresponse=$(jsonquery "$response" "error") 66 | err "$errorresponse" 67 | fi 68 | 69 | 70 | } 71 | 72 | format_api_json() { 73 | 74 | if ((veryverbose)); then 75 | json_prettyify "${1}" 76 | elif (($verbose)); then 77 | json_prettyify "${1}" 78 | else 79 | binname=$(jsonquery "$1" "name") 80 | echo "${hosturl}${binname}" 81 | fi 82 | } 83 | 84 | ################################################################## 85 | ################################################################## 86 | # End Script Logic # 87 | ################################################################## 88 | ################################################################## 89 | 90 | # }}} 91 | 92 | # Parse command line options 93 | source "$DIR/options.sh" 94 | 95 | # Main loop {{{ 96 | 97 | # Print help if no arguments were passed. 98 | #[[ $# -eq 0 ]] && set -- "--help" 99 | 100 | # Read the options and set stuff 101 | while [[ $1 = -?* ]]; do 102 | case $1 in 103 | -h|--help) usage >&2; safe_exit ;; 104 | --version) version; copyright; disclaimer; safe_exit ;; 105 | -H|--hosturl) shift; hosturl=$1;; 106 | -d|--development) development=1 ;; 107 | -v|--verbose) verbose=1 ;; 108 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 109 | -q|--quiet) quiet=1 ;; 110 | -i|--interactive) interactive=1 ;; 111 | -f|--force) force=1 ;; 112 | --endopts) shift; break ;; 113 | *) die "invalid option: $1" ;; 114 | esac 115 | shift 116 | done 117 | 118 | # Store the remaining part as arguments. 119 | args+=("$@") 120 | 121 | # }}} 122 | 123 | # Run the script logic 124 | source "$DIR/runner.sh" 125 | -------------------------------------------------------------------------------- /bin/jobs-delete: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # jobs-delete 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It deletes a job. If running the job will be stopped. 9 | # 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | source "$DIR/common.sh" 14 | 15 | # Script logic -- TOUCH THIS {{{ 16 | 17 | # A list of all variables to prompt in interactive mode. These variables HAVE 18 | # to be named exactly as the longname option definition in usage(). 19 | interactive_opts=(apisecret apikey) 20 | 21 | # Print usage 22 | usage() { 23 | echo -n "$(basename $0) [OPTION]... [JOB_ID] 24 | 25 | Delete an existing job. If running, the job will be killed. 26 | 27 | Options: 28 | -z, --access_token Access token 29 | -H, --hosturl URL of the service 30 | -d, --development Run in dev mode using default dev server 31 | -f, --force Skip all user interaction 32 | -i, --interactive Prompt for values 33 | -q, --quiet Quiet (no output) 34 | -v, --verbose Verbose output 35 | -V, --veryverbose Very verbose output 36 | -h, --help Display this help and exit 37 | --version Output version information and exit 38 | " 39 | } 40 | 41 | ################################################################## 42 | ################################################################## 43 | # Begin Script Logic # 44 | ################################################################## 45 | ################################################################## 46 | 47 | source "$DIR/jobs-common.sh" 48 | 49 | main() { 50 | #echo -n 51 | #set -x 52 | 53 | if [ -z "$args" ]; then 54 | err "Please specify a valid app id to delete" 55 | else 56 | 57 | cmd="curl -sk -H \"${authheader}\" -X DELETE '$hosturl$args?pretty=true'" 58 | 59 | if ((veryverbose)); then 60 | [ "$piped" -eq 0 ] && log "Calling $cmd" 61 | fi 62 | 63 | response=`curl -sk -H "${authheader}" -X DELETE "$hosturl$args?pretty=true"` 64 | 65 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 66 | result=$(format_api_json "$response") 67 | success "$result" 68 | else 69 | errorresponse=$(jsonquery "$response" "message") 70 | err "$errorresponse" 71 | fi 72 | fi 73 | } 74 | 75 | format_api_json() { 76 | 77 | if ((veryverbose)); then 78 | echo "$1" 79 | elif [[ $verbose -eq 1 ]]; then 80 | result=$(jsonquery "$1" "result" 1) 81 | json_prettyify "${result}" 82 | else 83 | echo "Successfully deleted job $args" 84 | fi 85 | } 86 | 87 | ################################################################## 88 | ################################################################## 89 | # End Script Logic # 90 | ################################################################## 91 | ################################################################## 92 | 93 | # }}} 94 | 95 | # Parse command line options 96 | source "$DIR/options.sh" 97 | 98 | 99 | # Main loop {{{ 100 | 101 | # Print help if no arguments were passed. 102 | [[ $# -eq 0 ]] && set -- "-i" 103 | 104 | # Read the options and set stuff 105 | while [[ $1 = -?* ]]; do 106 | case $1 in 107 | -h|--help) usage >&2; safe_exit ;; 108 | --version) version; copyright; disclaimer; safe_exit ;; 109 | -z|--access_token) shift; access_token=$1 ;; 110 | -H|--hosturl) shift; hosturl=$1;; 111 | -d|--development) development=1 ;; 112 | -v|--verbose) verbose=1 ;; 113 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 114 | -q|--quiet) quiet=1 ;; 115 | -i|--interactive) interactive=1 ;; 116 | -f|--force) force=1 ;; 117 | --endopts) shift; break ;; 118 | *) die "invalid option: $1" ;; 119 | esac 120 | shift 121 | done 122 | 123 | # Store the remaining part as arguments. 124 | args+=("$@") 125 | 126 | # }}} 127 | 128 | # Run the script logic 129 | source "$DIR/runner.sh" 130 | -------------------------------------------------------------------------------- /bin/notifications-fire: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # notifications-fire 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It fires a notification. 9 | # 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | source "$DIR/common.sh" 14 | 15 | # Script logic -- TOUCH THIS {{{ 16 | 17 | # A list of all variables to prompt in interactive mode. These variables HAVE 18 | # to be named exactly as the longname option definition in usage(). 19 | interactive_opts=(apisecret apikey filetoupload) 20 | 21 | # Print usage 22 | usage() { 23 | echo -n "$(basename $0) [OPTION]... 24 | $(basename $0) [OPTION]... [NOTIFICATION_ID] 25 | 26 | Fire a notification manually. You must be an admin to use this 27 | 28 | Options: 29 | -z, --access_token Access token 30 | -H, --hosturl URL of the service 31 | -d, --development Run in dev mode using default dev server 32 | -f, --force Skip all user interaction 33 | -i, --interactive Prompt for values 34 | -q, --quiet Quiet (no output) 35 | -v, --verbose Verbose output 36 | -V, --veryverbose Very verbose output 37 | -h, --help Display this help and exit 38 | --version Output version information and exit 39 | " 40 | } 41 | 42 | ################################################################## 43 | ################################################################## 44 | # Begin Script Logic # 45 | ################################################################## 46 | ################################################################## 47 | 48 | source "$DIR/notifications-common.sh" 49 | 50 | main() { 51 | #echo -n 52 | #set -x 53 | 54 | cmd="curl -sk -H \"${authheader}\" -X POST -d \"foo=bar\" '${hosturl}$args/attempts?pretty=true'" 55 | 56 | if ((veryverbose)); then 57 | log "Calling $cmd" 58 | fi 59 | 60 | response=`curl -sk -H "${authheader}" -X POST -d "foo=bar" "${hosturl}$args/attempts?pretty=true"` 61 | 62 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 63 | result=$(format_api_json "$response") 64 | success "$result" 65 | else 66 | errorresponse=$(jsonquery "$response" "message") 67 | err "$errorresponse" 68 | fi 69 | } 70 | 71 | format_api_json() { 72 | 73 | if ((veryverbose)); then 74 | echo "$1" 75 | elif [[ $verbose -eq 1 ]]; then 76 | result=$(jsonquery "$1" "result" 1) 77 | json_prettyify "${result}" 78 | else 79 | jsonval oid "$i" "oid" 80 | success "Successfully fired notification $oid" 81 | fi 82 | } 83 | 84 | ################################################################## 85 | ################################################################## 86 | # End Script Logic # 87 | ################################################################## 88 | ################################################################## 89 | 90 | # }}} 91 | 92 | # Parse command line options 93 | source "$DIR/options.sh" 94 | 95 | 96 | # Main loop {{{ 97 | 98 | # Print help if no arguments were passed. 99 | [[ $# -eq 0 ]] && set -- "-i" 100 | 101 | # Read the options and set stuff 102 | while [[ $1 = -?* ]]; do 103 | case $1 in 104 | -h|--help) usage >&2; safe_exit ;; 105 | --version) version; copyright; disclaimer; safe_exit ;; 106 | -z|--access_token) shift; access_token=$1 ;; 107 | --filter) shift; responsefilter=$1 ;; 108 | -H|--hosturl) shift; hosturl=$1;; 109 | -d|--development) development=1 ;; 110 | -v|--verbose) verbose=1 ;; 111 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 112 | -q|--quiet) quiet=1 ;; 113 | -i|--interactive) interactive=1 ;; 114 | -f|--force) force=1 ;; 115 | --endopts) shift; break ;; 116 | *) die "invalid option: $1" ;; 117 | esac 118 | shift 119 | done 120 | 121 | # Store the remaining part as arguments. 122 | args+=("$@") 123 | 124 | # }}} 125 | 126 | # Run the script logic 127 | source "$DIR/runner.sh" 128 | -------------------------------------------------------------------------------- /bin/notifications-delete: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # notifications-delete 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It deletes a notification object. 9 | # 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | source "$DIR/common.sh" 14 | 15 | # Script logic -- TOUCH THIS {{{ 16 | 17 | # A list of all variables to prompt in interactive mode. These variables HAVE 18 | # to be named exactly as the longname option definition in usage(). 19 | interactive_opts=(apisecret apikey) 20 | 21 | # Print usage 22 | usage() { 23 | echo -n "$(basename $0) [OPTION]... [NOTIFICATION_ID] 24 | 25 | Delete a registered notification. The associated object will not be altered. 26 | 27 | Options: 28 | -z, --access_token Access token 29 | -H, --hosturl URL of the service 30 | -d, --development Run in dev mode using default dev server 31 | -f, --force Skip all user interaction 32 | -i, --interactive Prompt for values 33 | -q, --quiet Quiet (no output) 34 | -v, --verbose Verbose output 35 | -V, --veryverbose Very verbose output 36 | -h, --help Display this help and exit 37 | --version Output version information and exit 38 | " 39 | } 40 | 41 | ################################################################## 42 | ################################################################## 43 | # Begin Script Logic # 44 | ################################################################## 45 | ################################################################## 46 | 47 | source "$DIR/notifications-common.sh" 48 | 49 | main() { 50 | #echo -n 51 | #set -x 52 | 53 | if [ -z "$args" ]; then 54 | err "Please specify a valid notification object id to delete" 55 | else 56 | 57 | cmd="curl -sk -H \"${authheader}\" -X DELETE '${hosturl}${args}?pretty=true'" 58 | 59 | if ((veryverbose)); then 60 | [ "$piped" -eq 0 ] && log "Calling $cmd" 61 | fi 62 | 63 | response=`curl -sk -H "${authheader}" -X DELETE "${hosturl}${args}?pretty=true"` 64 | 65 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 66 | result=$(format_api_json "$response") 67 | success "$result" 68 | else 69 | errorresponse=$(jsonquery "$response" "message") 70 | err "$errorresponse" 71 | fi 72 | fi 73 | } 74 | 75 | format_api_json() { 76 | 77 | if ((veryverbose)); then 78 | echo "$1" 79 | elif [[ $verbose -eq 1 ]]; then 80 | result=$(jsonquery "$1" "result" 1) 81 | json_prettyify "${result}" 82 | else 83 | echo "Successfully deleted notification $args" 84 | fi 85 | } 86 | 87 | ################################################################## 88 | ################################################################## 89 | # End Script Logic # 90 | ################################################################## 91 | ################################################################## 92 | 93 | # }}} 94 | 95 | # Parse command line options 96 | source "$DIR/options.sh" 97 | 98 | 99 | # Main loop {{{ 100 | 101 | # Print help if no arguments were passed. 102 | [[ $# -eq 0 ]] && set -- "-i" 103 | 104 | # Read the options and set stuff 105 | while [[ $1 = -?* ]]; do 106 | case $1 in 107 | -h|--help) usage >&2; safe_exit ;; 108 | --version) version; copyright; disclaimer; safe_exit ;; 109 | -z|--access_token) shift; access_token=$1 ;; 110 | -H|--hosturl) shift; hosturl=$1;; 111 | -d|--development) development=1 ;; 112 | -v|--verbose) verbose=1 ;; 113 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 114 | -q|--quiet) quiet=1 ;; 115 | -i|--interactive) interactive=1 ;; 116 | -f|--force) force=1 ;; 117 | --endopts) shift; break ;; 118 | *) die "invalid option: $1" ;; 119 | esac 120 | shift 121 | done 122 | 123 | # Store the remaining part as arguments. 124 | args+=("$@") 125 | 126 | # }}} 127 | 128 | # Run the script logic 129 | source "$DIR/runner.sh" 130 | -------------------------------------------------------------------------------- /bin/postits-delete: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # postit-create 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It creates a pre-authenticated shortened URL which can be used 9 | # in leu of the original endpoint to share with others. 10 | # 11 | 12 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 13 | 14 | source "$DIR/common.sh" 15 | 16 | # Script logic -- TOUCH THIS {{{ 17 | 18 | # A list of all variables to prompt in interactive mode. These variables HAVE 19 | # to be named exactly as the longname option definition in usage(). 20 | interactive_opts=(apisecret apikey) 21 | 22 | # Print usage 23 | usage() { 24 | echo -n "$(basename $0) [OPTION]... [POSTIT_NONCE] 25 | 26 | Immediately expires an existing PostIt. 27 | 28 | Options: 29 | -z, --access_token Access token 30 | -H, --hosturl URL of the service 31 | -d, --development Run in dev mode using default dev server 32 | -f, --force Skip all user interaction 33 | -i, --interactive Prompt for values 34 | -q, --quiet Quiet (no output) 35 | -v, --verbose Verbose output 36 | -V, --veryverbose Very verbose output 37 | -h, --help Display this help and exit 38 | --version Output version information and exit 39 | " 40 | } 41 | 42 | ################################################################## 43 | ################################################################## 44 | # Begin Script Logic # 45 | ################################################################## 46 | ################################################################## 47 | 48 | source "$DIR/postits-common.sh" 49 | 50 | main() { 51 | #echo -n 52 | #set -x 53 | 54 | local post_options=''; 55 | 56 | if [ -z "$args" ]; then 57 | err "A valid postit nonce must be specified" 58 | die 59 | fi 60 | 61 | cmd="curl -sk -H \"${authheader}\" -X DELETE '${hosturl}${args}?pretty=true'" 62 | 63 | if ((veryverbose)); then 64 | [ "$piped" -eq 0 ] && log "Calling $cmd" 65 | fi 66 | 67 | response=`curl -sk -H "${authheader}" -X DELETE "${hosturl}${args}?pretty=true"` 68 | 69 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 70 | result=$(format_api_json "$response") 71 | success "$result" 72 | else 73 | errorresponse=$(jsonquery "$response" "message") 74 | err "$errorresponse" 75 | fi 76 | } 77 | 78 | format_api_json() { 79 | 80 | if ((veryverbose)); then 81 | echo "$1" 82 | elif [[ $verbose -eq 1 ]]; then 83 | result=$(jsonquery "$1" "result" 1) 84 | json_prettyify "${result}" 85 | else 86 | echo "Successfully deleted postit ${args}" 87 | fi 88 | } 89 | 90 | ################################################################## 91 | ################################################################## 92 | # End Script Logic # 93 | ################################################################## 94 | ################################################################## 95 | 96 | # }}} 97 | 98 | # Parse command line options 99 | source "$DIR/options.sh" 100 | 101 | 102 | # Main loop {{{ 103 | 104 | # Print help if no arguments were passed. 105 | [[ $# -eq 0 ]] && set -- "-i" 106 | 107 | # Read the options and set stuff 108 | while [[ $1 = -?* ]]; do 109 | case $1 in 110 | -h|--help) usage >&2; safe_exit ;; 111 | --version) version; copyright; disclaimer; safe_exit ;; 112 | -z|--access_token) shift; access_token=$1 ;; 113 | -H|--hosturl) shift; hosturl=$1;; 114 | -d|--development) development=1 ;; 115 | -v|--verbose) verbose=1 ;; 116 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 117 | -q|--quiet) quiet=1 ;; 118 | -i|--interactive) interactive=1 ;; 119 | -f|--force) force=1 ;; 120 | --endopts) shift; break ;; 121 | *) die "invalid option: $1" ;; 122 | esac 123 | shift 124 | done 125 | 126 | # Store the remaining part as arguments. 127 | args+=("$@") 128 | 129 | # }}} 130 | 131 | # Run the script logic 132 | source "$DIR/runner.sh" 133 | -------------------------------------------------------------------------------- /bin/jobs-stop: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # jobs-stop 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It kill a running or queued job. 9 | # 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | source "$DIR/common.sh" 14 | 15 | # Script logic -- TOUCH THIS {{{ 16 | 17 | # A list of all variables to prompt in interactive mode. These variables HAVE 18 | # to be named exactly as the longname option definition in usage(). 19 | interactive_opts=(apisecret apikey) 20 | 21 | # Print usage 22 | usage() { 23 | echo -n "$(basename $0) [OPTION]... [JOB_ID] 24 | 25 | Stop a running or queued job. 26 | 27 | Options: 28 | -z, --access_token Access token 29 | --filter Comma separated list of fields to return in the response 30 | -H, --hosturl URL of the service 31 | -d, --development Run in dev mode using default dev server 32 | -f, --force Skip all user interaction 33 | -i, --interactive Prompt for values 34 | -q, --quiet Quiet (no output) 35 | -v, --verbose Verbose output 36 | -V, --veryverbose Very verbose output 37 | -h, --help Display this help and exit 38 | --version Output version information and exit 39 | " 40 | } 41 | 42 | ################################################################## 43 | ################################################################## 44 | # Begin Script Logic # 45 | ################################################################## 46 | ################################################################## 47 | 48 | source "$DIR/jobs-common.sh" 49 | 50 | main() { 51 | #echo -n 52 | #set -x 53 | 54 | if [ -z "$args" ]; then 55 | err "Please specify a job id to stop" 56 | else 57 | cmd="curl -sk -H \"${authheader}\" -X POST -d \"action=stop\" '$hosturl$args?pretty=true'" 58 | 59 | if ((veryverbose)); then 60 | [ "$piped" -eq 0 ] && log "Calling $cmd" 61 | fi 62 | 63 | response=`curl -sk -H "${authheader}" -X POST -d "action=stop" "$hosturl$args?pretty=true"` 64 | 65 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 66 | result=$(format_api_json "$response") 67 | success "$result" 68 | else 69 | errorresponse=$(jsonquery "$response" "message") 70 | err "$errorresponse" 71 | fi 72 | fi 73 | } 74 | 75 | format_api_json() { 76 | 77 | if ((veryverbose)); then 78 | json_prettyify "${1}" 79 | elif [[ $verbose -eq 1 ]]; then 80 | result=$(jsonquery "$1" "result" 1) 81 | json_prettyify "${result}" 82 | else 83 | echo "Successfully stopped job $args" 84 | fi 85 | } 86 | 87 | ################################################################## 88 | ################################################################## 89 | # End Script Logic # 90 | ################################################################## 91 | ################################################################## 92 | 93 | # }}} 94 | 95 | # Parse command line options 96 | source "$DIR/options.sh" 97 | 98 | 99 | # Main loop {{{ 100 | 101 | # Print help if no arguments were passed. 102 | [[ $# -eq 0 ]] && set -- "-i" 103 | 104 | # Read the options and set stuff 105 | while [[ $1 = -?* ]]; do 106 | case $1 in 107 | -h|--help) usage >&2; safe_exit ;; 108 | --version) version; copyright; disclaimer; safe_exit ;; 109 | -z|--access_token) shift; access_token=$1 ;; 110 | --filter) shift; responsefilter=$1 ;; 111 | -H|--hosturl) shift; hosturl=$1;; 112 | -d|--development) development=1 ;; 113 | -v|--verbose) verbose=1 ;; 114 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 115 | -q|--quiet) quiet=1 ;; 116 | -i|--interactive) interactive=1 ;; 117 | -f|--force) force=1 ;; 118 | --endopts) shift; break ;; 119 | *) die "invalid option: $1" ;; 120 | esac 121 | shift 122 | done 123 | 124 | # Store the remaining part as arguments. 125 | args+=("$@") 126 | 127 | # }}} 128 | 129 | # Run the script logic 130 | source "$DIR/runner.sh" 131 | -------------------------------------------------------------------------------- /bin/monitors-delete: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # monitors-delete 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It deletes a notification object. 9 | # 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | source "$DIR/common.sh" 14 | 15 | # Script logic -- TOUCH THIS {{{ 16 | 17 | # A list of all variables to prompt in interactive mode. These variables HAVE 18 | # to be named exactly as the longname option definition in usage(). 19 | interactive_opts=(apisecret apikey) 20 | 21 | # Print usage 22 | usage() { 23 | echo -n "$(basename $0) [OPTION]... [MONITOR_ID] 24 | 25 | Delete a registered monitor. This will delete the monitor history as well. If 26 | you simply want to pause the monitor, consider deactivating it instead. 27 | 28 | Options: 29 | -z, --access_token Access token 30 | -H, --hosturl URL of the service 31 | -d, --development Run in dev mode using default dev server 32 | -f, --force Skip all user interaction 33 | -i, --interactive Prompt for values 34 | -q, --quiet Quiet (no output) 35 | -v, --verbose Verbose output 36 | -V, --veryverbose Very verbose output 37 | -h, --help Display this help and exit 38 | --version Output version information and exit 39 | " 40 | } 41 | 42 | ################################################################## 43 | ################################################################## 44 | # Begin Script Logic # 45 | ################################################################## 46 | ################################################################## 47 | 48 | source "$DIR/monitors-common.sh" 49 | 50 | main() { 51 | #echo -n 52 | #set -x 53 | 54 | if [ -z "$args" ]; then 55 | err "Please specify a valid monitor id to delete" 56 | else 57 | 58 | cmd="curl -sk -H \"${authheader}\" -X DELETE '${hosturl}${args}?pretty=true'" 59 | 60 | if ((veryverbose)); then 61 | [ "$piped" -eq 0 ] && log "Calling $cmd" 62 | fi 63 | 64 | response=`curl -sk -H "${authheader}" -X DELETE "${hosturl}${args}?pretty=true"` 65 | 66 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 67 | result=$(format_api_json "$response") 68 | success "$result" 69 | else 70 | errorresponse=$(jsonquery "$response" "message") 71 | err "$errorresponse" 72 | fi 73 | fi 74 | } 75 | 76 | format_api_json() { 77 | 78 | if ((veryverbose)); then 79 | echo "$1" 80 | elif [[ $verbose -eq 1 ]]; then 81 | result=$(jsonquery "$1" "result" 1) 82 | json_prettyify "${result}" 83 | else 84 | echo "Successfully deleted monitor $args" 85 | fi 86 | } 87 | 88 | ################################################################## 89 | ################################################################## 90 | # End Script Logic # 91 | ################################################################## 92 | ################################################################## 93 | 94 | # }}} 95 | 96 | # Parse command line options 97 | source "$DIR/options.sh" 98 | 99 | 100 | # Main loop {{{ 101 | 102 | # Print help if no arguments were passed. 103 | [[ $# -eq 0 ]] && set -- "-i" 104 | 105 | # Read the options and set stuff 106 | while [[ $1 = -?* ]]; do 107 | case $1 in 108 | -h|--help) usage >&2; safe_exit ;; 109 | --version) version; copyright; disclaimer; safe_exit ;; 110 | -z|--access_token) shift; access_token=$1 ;; 111 | -H|--hosturl) shift; hosturl=$1;; 112 | -d|--development) development=1 ;; 113 | -v|--verbose) verbose=1 ;; 114 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 115 | -q|--quiet) quiet=1 ;; 116 | -i|--interactive) interactive=1 ;; 117 | -f|--force) force=1 ;; 118 | --endopts) shift; break ;; 119 | *) die "invalid option: $1" ;; 120 | esac 121 | shift 122 | done 123 | 124 | # Store the remaining part as arguments. 125 | args+=("$@") 126 | 127 | # }}} 128 | 129 | # Run the script logic 130 | source "$DIR/runner.sh" 131 | -------------------------------------------------------------------------------- /bin/metadata-delete: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # metadata-delete 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It deletes a metadata object. All associated metadata will be 9 | # deleted as well. 10 | # 11 | 12 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 13 | 14 | source "$DIR/common.sh" 15 | 16 | # Script logic -- TOUCH THIS {{{ 17 | 18 | # A list of all variables to prompt in interactive mode. These variables HAVE 19 | # to be named exactly as the longname option definition in usage(). 20 | interactive_opts=(apisecret apikey) 21 | 22 | # Print usage 23 | usage() { 24 | echo -n "$(basename $0) [OPTION]... [METADATA_ID] 25 | 26 | Delete a metadata object. All associated metadata objects will be 27 | deleted as well. Schema will remain unchanged. 28 | 29 | Options: 30 | -z, --access_token Access token 31 | -H, --hosturl URL of the service 32 | -d, --development Run in dev mode using default dev server 33 | -f, --force Skip all user interaction 34 | -i, --interactive Prompt for values 35 | -q, --quiet Quiet (no output) 36 | -v, --verbose Verbose output 37 | -V, --veryverbose Very verbose output 38 | -h, --help Display this help and exit 39 | --version Output version information and exit 40 | " 41 | } 42 | 43 | ################################################################## 44 | ################################################################## 45 | # Begin Script Logic # 46 | ################################################################## 47 | ################################################################## 48 | 49 | source "$DIR/metadata-common.sh" 50 | 51 | main() { 52 | #echo -n 53 | #set -x 54 | 55 | if [ -z "$args" ]; then 56 | err "Please specify a valid metadata object id to delete" 57 | else 58 | 59 | cmd="curl -sk -H \"${authheader}\" -X DELETE '${hosturl}data/${args}?pretty=true'" 60 | 61 | if ((veryverbose)); then 62 | [ "$piped" -eq 0 ] && log "Calling $cmd" 63 | fi 64 | 65 | response=`curl -sk -H "${authheader}" -X DELETE "${hosturl}data/${args}?pretty=true"` 66 | 67 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 68 | result=$(format_api_json "$response") 69 | success "$result" 70 | else 71 | errorresponse=$(jsonquery "$response" "message") 72 | err "$errorresponse" 73 | fi 74 | fi 75 | } 76 | 77 | format_api_json() { 78 | 79 | if ((veryverbose)); then 80 | echo "$1" 81 | elif [[ $verbose -eq 1 ]]; then 82 | result=$(jsonquery "$1" "result" 1) 83 | json_prettyify "${result}" 84 | else 85 | echo "Successfully deleted metatada object $arg" 86 | fi 87 | } 88 | 89 | ################################################################## 90 | ################################################################## 91 | # End Script Logic # 92 | ################################################################## 93 | ################################################################## 94 | 95 | # }}} 96 | 97 | # Parse command line options 98 | source "$DIR/options.sh" 99 | 100 | 101 | # Main loop {{{ 102 | 103 | # Print help if no arguments were passed. 104 | [[ $# -eq 0 ]] && set -- "-i" 105 | 106 | # Read the options and set stuff 107 | while [[ $1 = -?* ]]; do 108 | case $1 in 109 | -h|--help) usage >&2; safe_exit ;; 110 | --version) version; copyright; disclaimer; safe_exit ;; 111 | -z|--access_token) shift; access_token=$1 ;; 112 | -H|--hosturl) shift; hosturl=$1;; 113 | -d|--development) development=1 ;; 114 | -v|--verbose) verbose=1 ;; 115 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 116 | -q|--quiet) quiet=1 ;; 117 | -i|--interactive) interactive=1 ;; 118 | -f|--force) force=1 ;; 119 | --endopts) shift; break ;; 120 | *) die "invalid option: $1" ;; 121 | esac 122 | shift 123 | done 124 | 125 | # Store the remaining part as arguments. 126 | args+=("$@") 127 | 128 | # }}} 129 | 130 | # Run the script logic 131 | source "$DIR/runner.sh" 132 | -------------------------------------------------------------------------------- /bin/apps-delete: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # apps-delete 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It deletes a registered applications. User must have admin privileges 9 | # on the app to perform this operation. 10 | # 11 | 12 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 13 | 14 | source "$DIR/common.sh" 15 | 16 | # Script logic -- TOUCH THIS {{{ 17 | 18 | # A list of all variables to prompt in interactive mode. These variables HAVE 19 | # to be named exactly as the longname option definition in usage(). 20 | interactive_opts=(apisecret apikey) 21 | 22 | # Print usage 23 | usage() { 24 | echo -n "$(basename $0) [OPTION]... [APP_ID] 25 | 26 | Delete an app. Once deleted, an app cannot be undeleted. The app's 27 | unique id will be unavailable for reassignment to future apps. 28 | 29 | Options: 30 | -z, --access_token Access token 31 | -H, --hosturl URL of the service 32 | -d, --development Run in dev mode using default dev server 33 | -f, --force Skip all user interaction 34 | -i, --interactive Prompt for values 35 | -q, --quiet Quiet (no output) 36 | -v, --verbose Verbose output 37 | -V, --veryverbose Very verbose output 38 | -h, --help Display this help and exit 39 | --version Output version information and exit 40 | " 41 | } 42 | 43 | ################################################################## 44 | ################################################################## 45 | # Begin Script Logic # 46 | ################################################################## 47 | ################################################################## 48 | 49 | source "$DIR/apps-common.sh" 50 | 51 | main() { 52 | #echo -n 53 | #set -x 54 | 55 | if [ -z "$args" ]; then 56 | response="Please specify a valid app id to delete" 57 | err $response 58 | else 59 | 60 | cmd="curl -sk -H \"${authheader}\" -X DELETE '$hosturl$args?pretty=true'" 61 | 62 | if ((veryverbose)); then 63 | [ "$piped" -eq 0 ] && log "Calling $cmd" 64 | fi 65 | 66 | response=`curl -sk -H "${authheader}" -X DELETE "$hosturl$args?pretty=true"` 67 | 68 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 69 | result=$(format_api_json "$response") 70 | success "$result" 71 | else 72 | errorresponse=$(jsonquery "$response" "message") 73 | err "$errorresponse" 74 | fi 75 | fi 76 | } 77 | 78 | format_api_json() { 79 | 80 | if ((veryverbose)); then 81 | echo "$1" 82 | elif [[ $verbose -eq 1 ]]; then 83 | result=$(jsonquery "$1" "result" 1) 84 | json_prettyify "${result}" 85 | else 86 | success "Successfully deleted app $args" 87 | fi 88 | } 89 | 90 | ################################################################## 91 | ################################################################## 92 | # End Script Logic # 93 | ################################################################## 94 | ################################################################## 95 | 96 | # }}} 97 | 98 | # Parse command line options 99 | source "$DIR/options.sh" 100 | 101 | 102 | # Main loop {{{ 103 | 104 | # Print help if no arguments were passed. 105 | [[ $# -eq 0 ]] && set -- "-i" 106 | 107 | # Read the options and set stuff 108 | while [[ $1 = -?* ]]; do 109 | case $1 in 110 | -h|--help) usage >&2; safe_exit ;; 111 | --version) version; copyright; disclaimer; safe_exit ;; 112 | -z|--access_token) shift; access_token=$1 ;; 113 | -H|--hosturl) shift; hosturl=$1;; 114 | -d|--development) development=1 ;; 115 | -v|--verbose) verbose=1 ;; 116 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 117 | -q|--quiet) quiet=1 ;; 118 | -i|--interactive) interactive=1 ;; 119 | -f|--force) force=1 ;; 120 | --endopts) shift; break ;; 121 | *) die "invalid option: $1" ;; 122 | esac 123 | shift 124 | done 125 | 126 | # Store the remaining part as arguments. 127 | args+=("$@") 128 | 129 | # }}} 130 | 131 | # Run the script logic 132 | source "$DIR/runner.sh" 133 | -------------------------------------------------------------------------------- /bin/tags-delete: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # tags-delete 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It deletes an existing tag. User must have ownership privileges 9 | # on the tag to perform this operation. Once deleted, the tag 10 | # cannot be recovered and tagged resources will be untagged. 11 | # 12 | 13 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 14 | 15 | source "$DIR/common.sh" 16 | 17 | # Script logic -- TOUCH THIS {{{ 18 | 19 | # A list of all variables to prompt in interactive mode. These variables HAVE 20 | # to be named exactly as the longname option definition in usage(). 21 | interactive_opts=(apisecret apikey) 22 | 23 | # Print usage 24 | usage() { 25 | echo -n "$(basename $0) [OPTION]... [TAG_ID] 26 | 27 | Deletes a registered tag. 28 | 29 | Options: 30 | -z, --access_token Access token 31 | -H, --hosturl URL of the service 32 | -d, --development Run in dev mode using default dev server 33 | -f, --force Skip all user interaction 34 | -i, --interactive Prompt for values 35 | -q, --quiet Quiet (no output) 36 | -v, --verbose Verbose output 37 | -V, --veryverbose Very verbose output 38 | -h, --help Display this help and exit 39 | --version Output version information and exit 40 | " 41 | } 42 | 43 | ################################################################## 44 | ################################################################## 45 | # Begin Script Logic # 46 | ################################################################## 47 | ################################################################## 48 | 49 | source "$DIR/tags-common.sh" 50 | 51 | main() { 52 | #echo -n 53 | #set -x 54 | 55 | if [ -z "$args" ]; then 56 | err "Please specify a valid tag id to delete" 57 | else 58 | 59 | cmd="curl -sk -H \"${authheader}\" -X DELETE '$hosturl$args?pretty=true'" 60 | 61 | if ((veryverbose)); then 62 | [ "$piped" -eq 0 ] && log "Calling $cmd" 63 | fi 64 | 65 | response=`curl -sk -H "${authheader}" -X DELETE "$hosturl$args?pretty=true"` 66 | 67 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 68 | result=$(format_api_json "$response") 69 | success "$result" 70 | else 71 | errorresponse=$(jsonquery "$response" "message") 72 | err "$errorresponse" 73 | fi 74 | fi 75 | } 76 | 77 | format_api_json() { 78 | 79 | jsonval storedtoken "${tokenstore}" "apikey" 80 | 81 | if ((veryverbose)); then 82 | echo "$1" 83 | elif [[ $verbose -eq 1 ]]; then 84 | result=$(jsonquery "$1" "result" 1) 85 | json_prettyify "${result}" 86 | else 87 | echo "Successfully deleted tag $args" 88 | fi 89 | } 90 | 91 | ################################################################## 92 | ################################################################## 93 | # End Script Logic # 94 | ################################################################## 95 | ################################################################## 96 | 97 | # }}} 98 | 99 | # Parse command line options 100 | source "$DIR/options.sh" 101 | 102 | 103 | # Main loop {{{ 104 | 105 | # Print help if no arguments were passed. 106 | [[ $# -eq 0 ]] && set -- "-i" 107 | 108 | # Read the options and set stuff 109 | while [[ $1 = -?* ]]; do 110 | case $1 in 111 | -h|--help) usage >&2; safe_exit ;; 112 | --version) version; copyright; disclaimer; safe_exit ;; 113 | -z|--access_token) shift; access_token=$1 ;; 114 | -H|--hosturl) shift; hosturl=$1;; 115 | -d|--development) development=1 ;; 116 | -v|--verbose) verbose=1 ;; 117 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 118 | -q|--quiet) quiet=1 ;; 119 | -i|--interactive) interactive=1 ;; 120 | -f|--force) force=1 ;; 121 | --endopts) shift; break ;; 122 | *) die "invalid option: $1" ;; 123 | esac 124 | shift 125 | done 126 | 127 | # Store the remaining part as arguments. 128 | args+=("$@") 129 | 130 | # }}} 131 | 132 | # Run the script logic 133 | source "$DIR/runner.sh" 134 | -------------------------------------------------------------------------------- /bin/profiles-delete: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # profiles-delete 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It deletes a user account. Calling user must have user-account-manager 9 | # role. The account cannot be recovered. Science API data is not deleted. 10 | # 11 | 12 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 13 | 14 | source "$DIR/common.sh" 15 | 16 | # Script logic -- TOUCH THIS {{{ 17 | 18 | # A list of all variables to prompt in interactive mode. These variables HAVE 19 | # to be named exactly as the longname option definition in usage(). 20 | interactive_opts=(apisecret apikey) 21 | 22 | # Print usage 23 | usage() { 24 | echo -n "$(basename $0) [OPTION]... [USERNAME] 25 | 26 | Deletes a user account.Calling user must have user-account-manager 27 | role. The account cannot be recovered. Science API data is not deleted. 28 | 29 | Options: 30 | -z, --access_token Access token 31 | -H, --hosturl URL of the service 32 | -d, --development Run in dev mode using default dev server 33 | -f, --force Skip all user interaction 34 | -i, --interactive Prompt for values 35 | -q, --quiet Quiet (no output) 36 | -v, --verbose Verbose output 37 | -V, --veryverbose Very verbose output 38 | -h, --help Display this help and exit 39 | --version Output version information and exit 40 | " 41 | } 42 | 43 | ################################################################## 44 | ################################################################## 45 | # Begin Script Logic # 46 | ################################################################## 47 | ################################################################## 48 | 49 | source "$DIR/profiles-common.sh" 50 | 51 | main() { 52 | #echo -n 53 | #set -x 54 | 55 | if [ -z "$args" ]; then 56 | err "Please specify a valid account username to delete" 57 | else 58 | 59 | cmd="curl -sk -H \"${authheader}\" -X DELETE '$hosturl$args?pretty=true'" 60 | 61 | if ((veryverbose)); then 62 | [ "$piped" -eq 0 ] && log "Calling $cmd" 63 | fi 64 | 65 | response=`curl -sk -H "${authheader}" -X DELETE "$hosturl$args?pretty=true"` 66 | 67 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 68 | result=$(format_api_json "$response") 69 | success "$result" 70 | else 71 | errorresponse=$(jsonquery "$response" "message") 72 | err "$errorresponse" 73 | fi 74 | fi 75 | } 76 | 77 | format_api_json() { 78 | 79 | jsonval storedtoken "${tokenstore}" "apikey" 80 | 81 | if ((veryverbose)); then 82 | echo "$1" 83 | elif [[ $verbose -eq 1 ]]; then 84 | result=$(jsonquery "$1" "result" 1) 85 | json_prettyify "${result}" 86 | else 87 | echo "Successfully deleted account $args" 88 | fi 89 | } 90 | 91 | ################################################################## 92 | ################################################################## 93 | # End Script Logic # 94 | ################################################################## 95 | ################################################################## 96 | 97 | # }}} 98 | 99 | # Parse command line options 100 | source "$DIR/options.sh" 101 | 102 | 103 | # Main loop {{{ 104 | 105 | # Print help if no arguments were passed. 106 | [[ $# -eq 0 ]] && set -- "-i" 107 | 108 | # Read the options and set stuff 109 | while [[ $1 = -?* ]]; do 110 | case $1 in 111 | -h|--help) usage >&2; safe_exit ;; 112 | --version) version; copyright; disclaimer; safe_exit ;; 113 | -z|--access_token) shift; access_token=$1 ;; 114 | -H|--hosturl) shift; hosturl=$1;; 115 | -d|--development) development=1 ;; 116 | -v|--verbose) verbose=1 ;; 117 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 118 | -q|--quiet) quiet=1 ;; 119 | -i|--interactive) interactive=1 ;; 120 | -f|--force) force=1 ;; 121 | --endopts) shift; break ;; 122 | *) die "invalid option: $1" ;; 123 | esac 124 | shift 125 | done 126 | 127 | # Store the remaining part as arguments. 128 | args+=("$@") 129 | 130 | # }}} 131 | 132 | # Run the script logic 133 | source "$DIR/runner.sh" 134 | -------------------------------------------------------------------------------- /bin/tenants-list: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # tenants-list 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It retrieves a list of available tenants from the agave central 9 | # 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | source "$DIR/common.sh" 14 | 15 | # Script logic -- TOUCH THIS {{{ 16 | 17 | # A list of all variables to prompt in interactive mode. These variables HAVE 18 | # to be named exactly as the longname option definition in usage(). 19 | interactive_opts=() 20 | 21 | # Print usage 22 | usage() { 23 | echo -n "$(basename $0) [OPTION]... [TENANT_CODE] 24 | 25 | Retrieves the list of available tenants from the Agave central database. 26 | 27 | Options: 28 | -l, --limit Maximum number of results to return 29 | -o, --offset Number of results to skip from the start 30 | -H, --hosturl URL of the service 31 | -d, --development Run in dev mode using default dev server 32 | -f, --force Skip all user interaction 33 | -i, --interactive Prompt for values 34 | -q, --quiet Quiet (no output) 35 | -v, --verbose Verbose output 36 | -V, --veryverbose Very verbose output 37 | -h, --help Display this help and exit 38 | --version Output version information and exit 39 | --rich Provide rich response 40 | " 41 | } 42 | 43 | ################################################################## 44 | ################################################################## 45 | # Begin Script Logic # 46 | ################################################################## 47 | ################################################################## 48 | 49 | source "$DIR/tenants-common.sh" 50 | 51 | main() { 52 | #echo -n 53 | #set -x 54 | 55 | cmd="curl -sk ${hosturl%/}/${args}?pretty=true$(pagination)" 56 | 57 | if ((veryverbose)); then 58 | [ "$piped" -eq 0 ] && log "Calling $cmd" 59 | fi 60 | 61 | response=`curl -sk "${hosturl%/}/${args}?pretty=true$(pagination)"` 62 | 63 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 64 | result=$(format_api_json "$response") 65 | success "$result" 66 | else 67 | errorresponse=$(jsonquery "$response" "message") 68 | err "$errorresponse" 69 | fi 70 | 71 | 72 | } 73 | 74 | format_api_json() { 75 | 76 | if ((veryverbose)); then 77 | json_prettyify "${1}" 78 | elif [[ $verbose -eq 1 ]]; then 79 | result=$(jsonquery "$1" "result" 1) 80 | json_prettyify "${result}" 81 | elif [[ $rich -eq 1 ]]; then 82 | result=$(richify "$1") 83 | columnize "${result}" 84 | else 85 | result=$(jsonquery "$1" "result.[].code") 86 | echo "${result}" 87 | fi 88 | } 89 | 90 | ################################################################## 91 | ################################################################## 92 | # End Script Logic # 93 | ################################################################## 94 | ################################################################## 95 | 96 | # }}} 97 | 98 | # Parse command line options 99 | source "$DIR/options.sh" 100 | 101 | # Main loop {{{ 102 | 103 | # Print help if no arguments were passed. 104 | #[[ $# -eq 0 ]] && set -- "--help" 105 | 106 | # Read the options and set stuff 107 | while [[ $1 = -?* ]]; do 108 | case $1 in 109 | -h|--help) usage >&2; safe_exit ;; 110 | --version) version; copyright; disclaimer; safe_exit ;; 111 | -z|--access_token) shift; access_token=$1 ;; 112 | -l|--limit) shift; limit=$1;; 113 | -o|--offset) shift; offset=$1;; 114 | --filter) shift; responsefilter=$1 ;; 115 | -H|--hosturl) shift; hosturl=$1;; 116 | -d|--development) development=1 ;; 117 | -v|--verbose) verbose=1 ;; 118 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 119 | -q|--quiet) quiet=1 ;; 120 | -i|--interactive) interactive=1 ;; 121 | -f|--force) force=1 ;; 122 | --rich) rich=1 ;; 123 | --endopts) shift; break ;; 124 | *) die "invalid option: $1" ;; 125 | esac 126 | shift 127 | done 128 | 129 | # Store the remaining part as arguments. 130 | args+=("$@") 131 | 132 | # }}} 133 | 134 | # Run the script logic 135 | source "$DIR/runner.sh" 136 | -------------------------------------------------------------------------------- /bin/metadata-schema-delete: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # metadata-schema-delete 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It deletes a metadata schema object. All associated metadata will be 9 | # deleted as well. 10 | # 11 | 12 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 13 | 14 | source "$DIR/common.sh" 15 | 16 | # Script logic -- TOUCH THIS {{{ 17 | 18 | # A list of all variables to prompt in interactive mode. These variables HAVE 19 | # to be named exactly as the longname option definition in usage(). 20 | interactive_opts=(apisecret apikey) 21 | 22 | # Print usage 23 | usage() { 24 | echo -n "$(basename $0) [OPTION]... [SCHEMA_ID] 25 | 26 | Delete a metadata schema record. No associated metadata will be deleted, 27 | however the association will be removed. 28 | 29 | Options: 30 | -z, --access_token Access token 31 | --filter Comma separated list of fields to return in the response 32 | -H, --hosturl URL of the service 33 | -d, --development Run in dev mode using default dev server 34 | -f, --force Skip all user interaction 35 | -i, --interactive Prompt for values 36 | -q, --quiet Quiet (no output) 37 | -v, --verbose Verbose output 38 | -V, --veryverbose Very verbose output 39 | -h, --help Display this help and exit 40 | --version Output version information and exit 41 | " 42 | } 43 | 44 | ################################################################## 45 | ################################################################## 46 | # Begin Script Logic # 47 | ################################################################## 48 | ################################################################## 49 | 50 | source "$DIR/metadata-common.sh" 51 | 52 | main() { 53 | #echo -n 54 | #set -x 55 | 56 | if [ -z "$args" ]; then 57 | err "Please specify a valid metadata object id to delete" 58 | else 59 | 60 | cmd="curl -sk -H \"${authheader}\" -X DELETE '${hosturl}schemas/${args}?pretty=true'" 61 | 62 | if ((veryverbose)); then 63 | [ "$piped" -eq 0 ] && log "Calling $cmd" 64 | fi 65 | 66 | response=`curl -sk -H "${authheader}" -X DELETE "${hosturl}schemas/${args}?pretty=true"` 67 | 68 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 69 | result=$(format_api_json "$response") 70 | success "$result" 71 | else 72 | errorresponse=$(jsonquery "$response" "message") 73 | err "$errorresponse" 74 | fi 75 | fi 76 | } 77 | 78 | format_api_json() { 79 | 80 | if ((veryverbose)); then 81 | echo "$1" 82 | elif [[ $verbose -eq 1 ]]; then 83 | result=$(jsonquery "$1" "result" 1) 84 | json_prettyify "${result}" 85 | else 86 | echo "Successfully deleted schema object $arg" 87 | fi 88 | } 89 | 90 | ################################################################## 91 | ################################################################## 92 | # End Script Logic # 93 | ################################################################## 94 | ################################################################## 95 | 96 | # }}} 97 | 98 | # Parse command line options 99 | source "$DIR/options.sh" 100 | 101 | 102 | # Main loop {{{ 103 | 104 | # Print help if no arguments were passed. 105 | [[ $# -eq 0 ]] && set -- "-i" 106 | 107 | # Read the options and set stuff 108 | while [[ $1 = -?* ]]; do 109 | case $1 in 110 | -h|--help) usage >&2; safe_exit ;; 111 | --version) version; copyright; disclaimer; safe_exit ;; 112 | -z|--access_token) shift; access_token=$1 ;; 113 | --filter) shift; responsefilter=$1 ;; 114 | -H|--hosturl) shift; hosturl=$1;; 115 | -d|--development) development=1 ;; 116 | -v|--verbose) verbose=1 ;; 117 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 118 | -q|--quiet) quiet=1 ;; 119 | -i|--interactive) interactive=1 ;; 120 | -f|--force) force=1 ;; 121 | --endopts) shift; break ;; 122 | *) die "invalid option: $1" ;; 123 | esac 124 | shift 125 | done 126 | 127 | # Store the remaining part as arguments. 128 | args+=("$@") 129 | 130 | # }}} 131 | 132 | # Run the script logic 133 | source "$DIR/runner.sh" 134 | -------------------------------------------------------------------------------- /bin/systems-enable: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # systems-enable 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # Toggles the availability of the system 9 | # 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | source "$DIR/common.sh" 14 | 15 | # Script logic -- TOUCH THIS {{{ 16 | 17 | # A list of all variables to prompt in interactive mode. These variables HAVE 18 | # to be named exactly as the longname option definition in usage(). 19 | interactive_opts=(apisecret apikey) 20 | 21 | # Print usage 22 | usage() { 23 | echo -n "$(basename $0) [OPTION]... [SYSTEM_ID] 24 | 25 | Toggles the availability of the system on. System admin privileges are required. 26 | 27 | Options: 28 | -z, --access_token Access token 29 | --filter Comma separated list of fields to return in the response 30 | -H, --hosturl URL of the service 31 | -d, --development Run in dev mode using default dev server 32 | -f, --force Skip all user interaction 33 | -i, --interactive Prompt for values 34 | -q, --quiet Quiet (no output) 35 | -v, --verbose Verbose output 36 | -V, --veryverbose Very verbose output 37 | -h, --help Display this help and exit 38 | --version Output version information and exit 39 | " 40 | } 41 | 42 | ################################################################## 43 | ################################################################## 44 | # Begin Script Logic # 45 | ################################################################## 46 | ################################################################## 47 | 48 | source "$DIR/systems-common.sh" 49 | 50 | main() { 51 | #echo -n 52 | #set -x 53 | 54 | if [ -z "$args" ]; then 55 | err "Please specify a valid system id to enable" 56 | else 57 | action="enable" 58 | 59 | cmd="curl -sk -H \"${authheader}\" -X PUT -d \"action=${action}\" '$hosturl$args?pretty=true'" 60 | 61 | if ((veryverbose)); then 62 | [ "$piped" -eq 0 ] && log "Calling $cmd" 63 | fi 64 | 65 | response=`curl -sk -H "${authheader}" -X PUT -d "action=${action}" "$hosturl$args?pretty=true"` 66 | 67 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 68 | result=$(format_api_json "$response") 69 | success "$result" 70 | else 71 | errorresponse=$(jsonquery "$response" "message") 72 | err "$errorresponse" 73 | fi 74 | fi 75 | } 76 | 77 | format_api_json() { 78 | 79 | if ((veryverbose)); then 80 | echo "$1" 81 | elif [[ $verbose -eq 1 ]]; then 82 | result=$(jsonquery "$1" "result" 1) 83 | json_prettyify "${result}" 84 | else 85 | system_id=$(jsonquery "$1" "result.id") 86 | system_type=$(jsonquery "$1" "result.type") 87 | echo "Successfully enabled $system_id" 88 | fi 89 | } 90 | 91 | ################################################################## 92 | ################################################################## 93 | # End Script Logic # 94 | ################################################################## 95 | ################################################################## 96 | 97 | # }}} 98 | 99 | # Parse command line options 100 | source "$DIR/options.sh" 101 | 102 | 103 | # Main loop {{{ 104 | 105 | # Print help if no arguments were passed. 106 | [[ $# -eq 0 ]] && set -- "-i" 107 | 108 | # Read the options and set stuff 109 | while [[ $1 = -?* ]]; do 110 | case $1 in 111 | -h|--help) usage >&2; safe_exit ;; 112 | --version) version; copyright; disclaimer; safe_exit ;; 113 | -z|--access_token) shift; access_token=$1 ;; 114 | --filter) shift; responsefilter=$1;; 115 | -H|--hosturl) shift; hosturl=$1 ;; 116 | -d|--development) development=1 ;; 117 | -v|--verbose) verbose=1 ;; 118 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 119 | -q|--quiet) quiet=1 ;; 120 | -i|--interactive) interactive=1 ;; 121 | -f|--force) force=1 ;; 122 | --endopts) shift; break ;; 123 | *) die "invalid option: $1" ;; 124 | esac 125 | shift 126 | done 127 | 128 | # Store the remaining part as arguments. 129 | args+=("$@") 130 | 131 | # }}} 132 | 133 | # Run the script logic 134 | source "$DIR/runner.sh" 135 | -------------------------------------------------------------------------------- /bin/monitors-disable: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # monitors-enable 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # Toggles the availability of the monitor off 9 | # 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | source "$DIR/common.sh" 14 | 15 | # Script logic -- TOUCH THIS {{{ 16 | 17 | # A list of all variables to prompt in interactive mode. These variables HAVE 18 | # to be named exactly as the longname option definition in usage(). 19 | interactive_opts=(apisecret apikey) 20 | 21 | # Print usage 22 | usage() { 23 | echo -n "$(basename $0) [OPTION]... [SYSTEM_ID] 24 | 25 | Toggles the availability of the monitor off. 26 | 27 | Options: 28 | -z, --access_token Access token 29 | --filter Comma separated list of fields to return in the response 30 | -H, --hosturl URL of the service 31 | -d, --development Run in dev mode using default dev server 32 | -f, --force Skip all user interaction 33 | -i, --interactive Prompt for values 34 | -q, --quiet Quiet (no output) 35 | -v, --verbose Verbose output 36 | -V, --veryverbose Very verbose output 37 | -h, --help Display this help and exit 38 | --version Output version information and exit 39 | " 40 | } 41 | 42 | ################################################################## 43 | ################################################################## 44 | # Begin Script Logic # 45 | ################################################################## 46 | ################################################################## 47 | 48 | source "$DIR/monitors-common.sh" 49 | 50 | main() { 51 | #echo -n 52 | #set -x 53 | 54 | if [ -z "$args" ]; then 55 | err "Please specify a valid monitor id to enable" 56 | else 57 | 58 | cmd="curl -sk -H \"${authheader}\" -H 'Content-Type: application/json' -X PUT --data-binary '{\"action\":\"disable\"}' '$hosturl$args?pretty=true'" 59 | 60 | if ((veryverbose)); then 61 | [ "$piped" -eq 0 ] && log "Calling $cmd" 62 | fi 63 | 64 | response=`curl -sk -H "${authheader}" -H 'Content-Type: application/json' -X PUT --data-binary '{"action":"disable"}' "$hosturl$args?pretty=true"` 65 | 66 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 67 | result=$(format_api_json "$response") 68 | success "$result" 69 | else 70 | errorresponse=$(jsonquery "$response" "message") 71 | err "$errorresponse" 72 | fi 73 | fi 74 | } 75 | 76 | format_api_json() { 77 | 78 | if ((veryverbose)); then 79 | echo "$1" 80 | elif [[ $verbose -eq 1 ]]; then 81 | result=$(jsonquery "$1" "result" 1) 82 | json_prettyify "${result}" 83 | else 84 | monitor_id=$(jsonquery "$1" "result.id") 85 | echo "Successfully disabled $monitor_id" 86 | fi 87 | } 88 | 89 | ################################################################## 90 | ################################################################## 91 | # End Script Logic # 92 | ################################################################## 93 | ################################################################## 94 | 95 | # }}} 96 | 97 | # Parse command line options 98 | source "$DIR/options.sh" 99 | 100 | 101 | # Main loop {{{ 102 | 103 | # Print help if no arguments were passed. 104 | [[ $# -eq 0 ]] && set -- "-i" 105 | 106 | # Read the options and set stuff 107 | while [[ $1 = -?* ]]; do 108 | case $1 in 109 | -h|--help) usage >&2; safe_exit ;; 110 | --version) version; copyright; disclaimer; safe_exit ;; 111 | -z|--access_token) shift; access_token=$1 ;; 112 | --filter) shift; responsefilter=$1;; 113 | -H|--hosturl) shift; hosturl=$1 ;; 114 | -d|--development) development=1 ;; 115 | -v|--verbose) verbose=1 ;; 116 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 117 | -q|--quiet) quiet=1 ;; 118 | -i|--interactive) interactive=1 ;; 119 | -f|--force) force=1 ;; 120 | --endopts) shift; break ;; 121 | *) die "invalid option: $1" ;; 122 | esac 123 | shift 124 | done 125 | 126 | # Store the remaining part as arguments. 127 | args+=("$@") 128 | 129 | # }}} 130 | 131 | # Run the script logic 132 | source "$DIR/runner.sh" 133 | -------------------------------------------------------------------------------- /bin/monitors-enable: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # monitors-enable 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # Toggles the availability of the monitor on. 9 | # 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | source "$DIR/common.sh" 14 | 15 | # Script logic -- TOUCH THIS {{{ 16 | 17 | # A list of all variables to prompt in interactive mode. These variables HAVE 18 | # to be named exactly as the longname option definition in usage(). 19 | interactive_opts=(apisecret apikey) 20 | 21 | # Print usage 22 | usage() { 23 | echo -n "$(basename $0) [OPTION]... [SYSTEM_ID] 24 | 25 | Toggles the availability of the monitor on. 26 | 27 | Options: 28 | -z, --access_token Access token 29 | --filter Comma separated list of fields to return in the response 30 | -H, --hosturl URL of the service 31 | -d, --development Run in dev mode using default dev server 32 | -f, --force Skip all user interaction 33 | -i, --interactive Prompt for values 34 | -q, --quiet Quiet (no output) 35 | -v, --verbose Verbose output 36 | -V, --veryverbose Very verbose output 37 | -h, --help Display this help and exit 38 | --version Output version information and exit 39 | " 40 | } 41 | 42 | ################################################################## 43 | ################################################################## 44 | # Begin Script Logic # 45 | ################################################################## 46 | ################################################################## 47 | 48 | source "$DIR/monitors-common.sh" 49 | 50 | main() { 51 | #echo -n 52 | #set -x 53 | 54 | if [ -z "$args" ]; then 55 | err "Please specify a valid monitor id to enable" 56 | else 57 | 58 | cmd="curl -sk -H \"${authheader}\" -H 'Content-Type: application/json' -X PUT --data-binary '{\"action\":\"enable\"}' '$hosturl$args?pretty=true'" 59 | 60 | if ((veryverbose)); then 61 | [ "$piped" -eq 0 ] && log "Calling $cmd" 62 | fi 63 | 64 | response=`curl -sk -H "${authheader}" -H 'Content-Type: application/json' -X PUT --data-binary '{"action":"disable"}' "$hosturl$args?pretty=true"` 65 | 66 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 67 | result=$(format_api_json "$response") 68 | success "$result" 69 | else 70 | errorresponse=$(jsonquery "$response" "message") 71 | err "$errorresponse" 72 | fi 73 | fi 74 | } 75 | 76 | format_api_json() { 77 | 78 | if ((veryverbose)); then 79 | echo "$1" 80 | elif [[ $verbose -eq 1 ]]; then 81 | result=$(jsonquery "$1" "result" 1) 82 | json_prettyify "${result}" 83 | else 84 | monitor_id=$(jsonquery "$1" "result.id") 85 | echo "Successfully enabled $monitor_id" 86 | fi 87 | } 88 | 89 | ################################################################## 90 | ################################################################## 91 | # End Script Logic # 92 | ################################################################## 93 | ################################################################## 94 | 95 | # }}} 96 | 97 | # Parse command line options 98 | source "$DIR/options.sh" 99 | 100 | 101 | # Main loop {{{ 102 | 103 | # Print help if no arguments were passed. 104 | [[ $# -eq 0 ]] && set -- "-i" 105 | 106 | # Read the options and set stuff 107 | while [[ $1 = -?* ]]; do 108 | case $1 in 109 | -h|--help) usage >&2; safe_exit ;; 110 | --version) version; copyright; disclaimer; safe_exit ;; 111 | -z|--access_token) shift; access_token=$1 ;; 112 | --filter) shift; responsefilter=$1;; 113 | -H|--hosturl) shift; hosturl=$1 ;; 114 | -d|--development) development=1 ;; 115 | -v|--verbose) verbose=1 ;; 116 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 117 | -q|--quiet) quiet=1 ;; 118 | -i|--interactive) interactive=1 ;; 119 | -f|--force) force=1 ;; 120 | --endopts) shift; break ;; 121 | *) die "invalid option: $1" ;; 122 | esac 123 | shift 124 | done 125 | 126 | # Store the remaining part as arguments. 127 | args+=("$@") 128 | 129 | # }}} 130 | 131 | # Run the script logic 132 | source "$DIR/runner.sh" 133 | -------------------------------------------------------------------------------- /bin/systems-disable: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # systems-disable 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # Toggles the availability of the system 9 | # 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | source "$DIR/common.sh" 14 | 15 | # Script logic -- TOUCH THIS {{{ 16 | 17 | # A list of all variables to prompt in interactive mode. These variables HAVE 18 | # to be named exactly as the longname option definition in usage(). 19 | interactive_opts=(apisecret apikey) 20 | 21 | # Print usage 22 | usage() { 23 | echo -n "$(basename $0) [OPTION]... [SYSTEM_ID] 24 | 25 | Toggles the availability of the system off. System admin privileges are required. 26 | 27 | Options: 28 | -z, --access_token Access token 29 | --filter Comma separated list of fields to return in the response 30 | -H, --hosturl URL of the service 31 | -d, --development Run in dev mode using default dev server 32 | -f, --force Skip all user interaction 33 | -i, --interactive Prompt for values 34 | -q, --quiet Quiet (no output) 35 | -v, --verbose Verbose output 36 | -V, --veryverbose Very verbose output 37 | -h, --help Display this help and exit 38 | --version Output version information and exit 39 | " 40 | } 41 | 42 | ################################################################## 43 | ################################################################## 44 | # Begin Script Logic # 45 | ################################################################## 46 | ################################################################## 47 | 48 | source "$DIR/systems-common.sh" 49 | 50 | main() { 51 | #echo -n 52 | #set -x 53 | 54 | if [ -z "$args" ]; then 55 | err "Please specify a valid system id to disable" 56 | else 57 | action="disable" 58 | 59 | cmd="curl -sk -H \"${authheader}\" -X PUT -d \"action=${action}\" '$hosturl$args?pretty=true'" 60 | 61 | if ((veryverbose)); then 62 | [ "$piped" -eq 0 ] && log "Calling $cmd" 63 | fi 64 | 65 | response=`curl -sk -H "${authheader}" -X PUT -d "action=${action}" "$hosturl$args?pretty=true"` 66 | 67 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 68 | result=$(format_api_json "$response") 69 | success "$result" 70 | else 71 | errorresponse=$(jsonquery "$response" "message") 72 | err "$errorresponse" 73 | fi 74 | fi 75 | } 76 | 77 | format_api_json() { 78 | 79 | if ((veryverbose)); then 80 | echo "$1" 81 | elif [[ $verbose -eq 1 ]]; then 82 | result=$(jsonquery "$1" "result" 1) 83 | json_prettyify "${result}" 84 | else 85 | system_id=$(jsonquery "$1" "result.id") 86 | system_type=$(jsonquery "$1" "result.type") 87 | echo "Successfully disabled $system_id" 88 | fi 89 | } 90 | 91 | ################################################################## 92 | ################################################################## 93 | # End Script Logic # 94 | ################################################################## 95 | ################################################################## 96 | 97 | # }}} 98 | 99 | # Parse command line options 100 | source "$DIR/options.sh" 101 | 102 | 103 | # Main loop {{{ 104 | 105 | # Print help if no arguments were passed. 106 | [[ $# -eq 0 ]] && set -- "-i" 107 | 108 | # Read the options and set stuff 109 | while [[ $1 = -?* ]]; do 110 | case $1 in 111 | -h|--help) usage >&2; safe_exit ;; 112 | --version) version; copyright; disclaimer; safe_exit ;; 113 | -z|--access_token) shift; access_token=$1 ;; 114 | --filter) shift; responsefilter=$1;; 115 | -H|--hosturl) shift; hosturl=$1 ;; 116 | -d|--development) development=1 ;; 117 | -v|--verbose) verbose=1 ;; 118 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 119 | -q|--quiet) quiet=1 ;; 120 | -i|--interactive) interactive=1 ;; 121 | -f|--force) force=1 ;; 122 | --endopts) shift; break ;; 123 | *) die "invalid option: $1" ;; 124 | esac 125 | shift 126 | done 127 | 128 | # Store the remaining part as arguments. 129 | args+=("$@") 130 | 131 | # }}} 132 | 133 | # Run the script logic 134 | source "$DIR/runner.sh" 135 | -------------------------------------------------------------------------------- /bin/clients-delete: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # clients-delete 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It deletes a registered system. User must have admin privileges 9 | # on the system to perform this operation. Once deleted, the system 10 | # cannot be recovered and all registered applications on that system 11 | # will be disabled 12 | # 13 | 14 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 15 | 16 | source "$DIR/common.sh" 17 | interactive=1 18 | 19 | # Script logic -- TOUCH THIS {{{ 20 | 21 | # A list of all variables to prompt in interactive mode. These variables HAVE 22 | # to be named exactly as the longname option definition in usage(). 23 | interactive_opts=(apiusername apipassword) 24 | 25 | # Print usage 26 | usage() { 27 | echo -n "$(basename $0) [OPTION]... [CLIENT_NAME] 28 | 29 | Deletes a client application and associated API keys. 30 | 31 | Options: 32 | -u, --apiusername API apiusername 33 | -p, --apipassword API apipassword 34 | -H, --hosturl URL of the service 35 | -d, --development Run in dev mode using default dev server 36 | -f, --force Skip all user interaction 37 | -i, --interactive Prompt for values 38 | -q, --quiet Quiet (no output) 39 | -v, --verbose Verbose output 40 | -V, --veryverbose Very verbose output 41 | -h, --help Display this help and exit 42 | --version Output version information and exit 43 | " 44 | } 45 | 46 | ################################################################## 47 | ################################################################## 48 | # Begin Script Logic # 49 | ################################################################## 50 | ################################################################## 51 | 52 | source "$DIR/clients-common.sh" 53 | 54 | main() { 55 | #echo -n 56 | #set -x 57 | 58 | if [ -z "$args" ]; then 59 | err "Please specify a valid client to delete" 60 | else 61 | 62 | cmd="curl -sku \"${apiusername}:xxxx\" -X DELETE '$hosturl$args?pretty=true'" 63 | 64 | if ((veryverbose)); then 65 | [ "$piped" -eq 0 ] && log "Calling $cmd" 66 | fi 67 | 68 | response=`curl -sku "${apiusername}:${apipassword}" -X DELETE "$hosturl$args?pretty=true"` 69 | 70 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 71 | result=$(format_api_json "$response") 72 | success "$result" 73 | else 74 | errorresponse=$(jsonquery "$response" "message") 75 | err "$errorresponse" 76 | fi 77 | fi 78 | } 79 | 80 | format_api_json() { 81 | 82 | if ((veryverbose)); then 83 | json_prettyify "${1}" 84 | elif [[ $verbose -eq 1 ]]; then 85 | result=$(jsonquery "$1" "result" 1) 86 | json_prettyify "${result}" 87 | else 88 | echo "Successfully deleted client $args" 89 | fi 90 | } 91 | 92 | ################################################################## 93 | ################################################################## 94 | # End Script Logic # 95 | ################################################################## 96 | ################################################################## 97 | 98 | # }}} 99 | 100 | # Parse command line options 101 | source "$DIR/options.sh" 102 | 103 | 104 | # Main loop {{{ 105 | 106 | # Print help if no arguments were passed. 107 | [[ $# -eq 0 ]] && set -- "-i" 108 | 109 | # Read the options and set stuff 110 | while [[ $1 = -?* ]]; do 111 | case $1 in 112 | -h|--help) usage >&2; safe_exit ;; 113 | --version) version; copyright; disclaimer; safe_exit ;; 114 | -u|--apiusername) shift; apiusername=$1 ;; 115 | -p|--apipassword) shift; apipassword=$1;; 116 | -H|--hosturl) shift; hosturl=$1;; 117 | -d|--development) development=1 ;; 118 | -v|--verbose) verbose=1 ;; 119 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 120 | -q|--quiet) quiet=1 ;; 121 | -i|--interactive) interactive=1 ;; 122 | -f|--force) force=1 ;; 123 | --endopts) shift; break ;; 124 | *) die "invalid option: $1" ;; 125 | esac 126 | shift 127 | done 128 | 129 | # Store the remaining part as arguments. 130 | args+=("$@") 131 | 132 | # }}} 133 | 134 | # Run the script logic 135 | source "$DIR/runner.sh" 136 | -------------------------------------------------------------------------------- /bin/monitors-fire: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # monitors-fire 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It forces a monitor check. You must have admin permissions to use this script. 9 | # 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | source "$DIR/common.sh" 14 | 15 | # Script logic -- TOUCH THIS {{{ 16 | 17 | # A list of all variables to prompt in interactive mode. These variables HAVE 18 | # to be named exactly as the longname option definition in usage(). 19 | interactive_opts=(apisecret apikey) 20 | 21 | # Print usage 22 | usage() { 23 | echo -n "$(basename $0) [OPTION]... 24 | $(basename $0) [OPTION]... [MONITOR_CHECK_ID] 25 | 26 | Forces a monitor to run. You must have admin permissions to use this script. 27 | 28 | Options: 29 | -z, --access_token Access token 30 | --filter Comma separated list of fields to return in the response 31 | -H, --hosturl URL of the service 32 | -d, --development Run in dev mode using default dev server 33 | -f, --force Skip all user interaction 34 | -i, --interactive Prompt for values 35 | -q, --quiet Quiet (no output) 36 | -v, --verbose Verbose output 37 | -V, --veryverbose Very verbose output 38 | -h, --help Display this help and exit 39 | --version Output version information and exit 40 | " 41 | } 42 | 43 | ################################################################## 44 | ################################################################## 45 | # Begin Script Logic # 46 | ################################################################## 47 | ################################################################## 48 | 49 | source "$DIR/monitors-common.sh" 50 | 51 | main() { 52 | #echo -n 53 | #set -x 54 | 55 | hosturl=${hosturl%/} 56 | if [ -n "$args" ]; then 57 | hosturl="${hosturl}/${args}/checks?pretty=true" 58 | else 59 | err "Please provide a monitor id." 60 | fi 61 | 62 | cmd="curl -sk -H \"${authheader}\" -XPOST -d \"foo=bar\" '${hosturl}'" 63 | 64 | if ((veryverbose)); then 65 | log "Calling $cmd" 66 | fi 67 | 68 | response=`curl -sk -H "${authheader}" -X POST -d "foo=bar" "${hosturl}"` 69 | 70 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 71 | result=$(format_api_json "$response") 72 | success "$result" 73 | else 74 | errorresponse=$(jsonquery "$response" "message") 75 | err "$errorresponse" 76 | fi 77 | } 78 | 79 | format_api_json() { 80 | 81 | if ((veryverbose)); then 82 | echo "$1" 83 | elif [[ $verbose -eq 1 ]]; then 84 | result=$(jsonquery "$1" "result" 1) 85 | json_prettyify "${result}" 86 | else 87 | checkresult=$(jsonquery "$1" "result.result") 88 | checkdate=$(jsonquery "$1" "result.created") 89 | echo "$args $checkdate $checkresult" 90 | fi 91 | } 92 | 93 | ################################################################## 94 | ################################################################## 95 | # End Script Logic # 96 | ################################################################## 97 | ################################################################## 98 | 99 | # }}} 100 | 101 | # Parse command line options 102 | source "$DIR/options.sh" 103 | 104 | # Main loop {{{ 105 | 106 | # Print help if no arguments were passed. 107 | #[[ $# -eq 0 ]] && set -- "--help" 108 | 109 | # Read the options and set stuff 110 | while [[ $1 = -?* ]]; do 111 | case $1 in 112 | -h|--help) usage >&2; safe_exit ;; 113 | --version) version; copyright; disclaimer; safe_exit ;; 114 | -z|--access_token) shift; access_token=$1 ;; 115 | --filter) shift; responsefilter=$1 ;; 116 | -H|--hosturl) shift; hosturl=$1;; 117 | -d|--development) development=1 ;; 118 | -v|--verbose) verbose=1 ;; 119 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 120 | -q|--quiet) quiet=1 ;; 121 | -i|--interactive) interactive=1 ;; 122 | -f|--force) force=1 ;; 123 | --endopts) shift; break ;; 124 | *) die "invalid option: $1" ;; 125 | esac 126 | shift 127 | done 128 | 129 | # Store the remaining part as arguments. 130 | args+=("$@") 131 | 132 | # }}} 133 | 134 | # Run the script logic 135 | source "$DIR/runner.sh" 136 | -------------------------------------------------------------------------------- /bin/profiles-users-delete: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # profiles-list 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It retrieves a list of one or more registered user profiles from the api 9 | # 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | source "$DIR/common.sh" 14 | 15 | # Script logic -- TOUCH THIS {{{ 16 | 17 | # A list of all variables to prompt in interactive mode. These variables HAVE 18 | # to be named exactly as the longname option definition in usage(). 19 | interactive_opts=(apisecret apikey internalusername) 20 | 21 | # Print usage 22 | usage() { 23 | echo -n "$(basename $0) [OPTION]... 24 | 25 | Delete an internal user. This will simply disable the internal user account. 26 | Once deleted, the username cannot be reused. 27 | 28 | Options: 29 | -z, --access_token Access token 30 | -U, --internalusername Username of internal user to delete 31 | -H, --hosturl URL of the service 32 | -d, --development Run in dev mode using default dev server 33 | -f, --force Skip all user interaction 34 | -i, --interactive Prompt for values 35 | -q, --quiet Quiet (no output) 36 | -v, --verbose Verbose output 37 | -V, --veryverbose Very verbose output 38 | -h, --help Display this help and exit 39 | --version Output version information and exit 40 | " 41 | } 42 | 43 | ################################################################## 44 | ################################################################## 45 | # Begin Script Logic # 46 | ################################################################## 47 | ################################################################## 48 | 49 | source "$DIR/profiles-common.sh" 50 | 51 | main() { 52 | #echo -n 53 | #set -x 54 | 55 | cmd="curl -sk -H \"${authheader}\" -X DELETE '$hosturl$username/users/$internalusername?pretty=true'" 56 | 57 | if ((veryverbose)); then 58 | [ "$piped" -eq 0 ] && log "Calling $cmd" 59 | fi 60 | 61 | response=`curl -sk -H "${authheader}" -X DELETE $hosturl$username/users/$internalusername?pretty=true` 62 | 63 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 64 | result=$(format_api_json "$response") 65 | success "$result" 66 | else 67 | errorresponse=$(jsonquery "$response" "message") 68 | err "$errorresponse" 69 | fi 70 | } 71 | 72 | format_api_json() { 73 | 74 | if ((veryverbose)); then 75 | echo "$1" 76 | elif [[ $verbose -eq 1 ]]; then 77 | result=$(jsonquery "$1" "result" 1) 78 | json_prettyify "${result}" 79 | else 80 | if [ -n "$internalUsername" ]; then 81 | echo "Successfully deleted internal user $internalUsername" 82 | else 83 | echo "Successfully deleted all internal users" 84 | fi 85 | fi 86 | } 87 | 88 | ################################################################## 89 | ################################################################## 90 | # End Script Logic # 91 | ################################################################## 92 | ################################################################## 93 | 94 | # }}} 95 | 96 | # Parse command line options 97 | source "$DIR/options.sh" 98 | 99 | 100 | # Main loop {{{ 101 | 102 | # Print help if no arguments were passed. 103 | #[[ $# -eq 0 ]] && set -- "--help" 104 | 105 | # Read the options and set stuff 106 | while [[ $1 = -?* ]]; do 107 | case $1 in 108 | -h|--help) usage >&2; safe_exit ;; 109 | --version) version; copyright; disclaimer; safe_exit ;; 110 | -z|--access_token) shift; access_token=$1 ;; 111 | -U|--internalusername) shift; internalusername=$1 ;; 112 | -h|--hosturl) shift; hosturl=$1;; 113 | -d|--development) development=1 ;; 114 | -v|--verbose) verbose=1 ;; 115 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 116 | -q|--quiet) quiet=1 ;; 117 | -i|--interactive) interactive=1 ;; 118 | -f|--force) force=1 ;; 119 | --endopts) shift; break ;; 120 | *) die "invalid option: $1" ;; 121 | esac 122 | shift 123 | done 124 | 125 | # Store the remaining part as arguments. 126 | args+=("$@") 127 | 128 | # }}} 129 | 130 | # Run the script logic 131 | source "$DIR/runner.sh" 132 | -------------------------------------------------------------------------------- /bin/postits-list: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # postit-create 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # Lists all active PostIts for the authenticated user. 9 | # 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | source "$DIR/common.sh" 14 | 15 | # Script logic -- TOUCH THIS {{{ 16 | 17 | # A list of all variables to prompt in interactive mode. These variables HAVE 18 | # to be named exactly as the longname option definition in usage(). 19 | interactive_opts=(apisecret apikey) 20 | 21 | # Print usage 22 | usage() { 23 | echo -n "$(basename $0) [OPTION]... 24 | 25 | Lists all active PostIts for the authenticated user. 26 | 27 | Options: 28 | -z, --access_token Access token 29 | -l, --limit Maximum number of results to return 30 | -o, --offset Number of results to skip from the start 31 | --filter Comma separated list of fields to return in the response 32 | -H, --hosturl URL of the service 33 | -d, --development Run in dev mode using default dev server 34 | -f, --force Skip all user interaction 35 | -i, --interactive Prompt for values 36 | -q, --quiet Quiet (no output) 37 | -v, --verbose Verbose output 38 | -V, --veryverbose Very verbose output 39 | -h, --help Display this help and exit 40 | --version Output version information and exit 41 | " 42 | } 43 | 44 | ################################################################## 45 | ################################################################## 46 | # Begin Script Logic # 47 | ################################################################## 48 | ################################################################## 49 | 50 | source "$DIR/postits-common.sh" 51 | 52 | main() { 53 | #echo -n 54 | #set -x 55 | 56 | local post_options=''; 57 | 58 | if [ -n "$args" ]; then 59 | hosturl="${hosturl}/${args}" 60 | fi 61 | 62 | cmd="curl -sk -H \"${authheader}\" '${hosturl}?pretty=true$(pagination)'" 63 | 64 | if ((veryverbose)); then 65 | [ "$piped" -eq 0 ] && log "Calling $cmd" 66 | fi 67 | 68 | response=`curl -sk -H "${authheader}" "${hosturl}?pretty=true$(pagination)"` 69 | 70 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 71 | result=$(format_api_json "$response") 72 | success "$result" 73 | else 74 | errorresponse=$(jsonquery "$response" "message") 75 | err "$errorresponse" 76 | fi 77 | } 78 | 79 | format_api_json() { 80 | 81 | if ((veryverbose)); then 82 | echo "$1" 83 | elif [[ $verbose -eq 1 ]]; then 84 | result=$(jsonquery "$1" "result" 1) 85 | json_prettyify "${result}" 86 | else 87 | result=$(jsonquery "$1" "result.[]._links.self.href") 88 | echo "${result}" 89 | fi 90 | } 91 | 92 | ################################################################## 93 | ################################################################## 94 | # End Script Logic # 95 | ################################################################## 96 | ################################################################## 97 | 98 | # }}} 99 | 100 | # Parse command line options 101 | source "$DIR/options.sh" 102 | 103 | # Main loop {{{ 104 | 105 | # Print help if no arguments were passed. 106 | #[[ $# -eq 0 ]] && set -- "-i" 107 | 108 | # Read the options and set stuff 109 | while [[ $1 = -?* ]]; do 110 | case $1 in 111 | -h|--help) usage >&2; safe_exit ;; 112 | --version) version; copyright; disclaimer; safe_exit ;; 113 | -z|--access_token) shift; access_token=$1 ;; 114 | -l|--limit) shift; limit=$1;; 115 | -o|--offset) shift; offset=$1;; 116 | --filter) shift; responsefilter=$1 ;; 117 | -H|--hosturl) shift; hosturl=$1;; 118 | -d|--development) development=1 ;; 119 | -v|--verbose) verbose=1 ;; 120 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 121 | -q|--quiet) quiet=1 ;; 122 | -i|--interactive) interactive=1 ;; 123 | -f|--force) force=1 ;; 124 | --endopts) shift; break ;; 125 | *) die "invalid option: $1" ;; 126 | esac 127 | shift 128 | done 129 | 130 | # Store the remaining part as arguments. 131 | args+=("$@") 132 | 133 | # }}} 134 | 135 | # Run the script logic 136 | source "$DIR/runner.sh" 137 | -------------------------------------------------------------------------------- /bin/systems-publish: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # systems-publish 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It publishes the system for public use. Global admin privileges are 9 | # required to publish a system. 10 | # 11 | 12 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 13 | 14 | source "$DIR/common.sh" 15 | 16 | # Script logic -- TOUCH THIS {{{ 17 | 18 | # A list of all variables to prompt in interactive mode. These variables HAVE 19 | # to be named exactly as the longname option definition in usage(). 20 | interactive_opts=(apisecret apikey) 21 | 22 | # Print usage 23 | usage() { 24 | echo -n "$(basename $0) [OPTION]... [SYSTEM_ID] 25 | 26 | Publishes a system for public use. Global admin privileges are 27 | required to publish a system. 28 | 29 | Options: 30 | -z, --access_token Access token 31 | --filter Comma separated list of fields to return in the response 32 | -H, --hosturl URL of the service 33 | -d, --development Run in dev mode using default dev server 34 | -f, --force Skip all user interaction 35 | -i, --interactive Prompt for values 36 | -q, --quiet Quiet (no output) 37 | -v, --verbose Verbose output 38 | -V, --veryverbose Very verbose output 39 | -h, --help Display this help and exit 40 | --version Output version information and exit 41 | " 42 | } 43 | 44 | ################################################################## 45 | ################################################################## 46 | # Begin Script Logic # 47 | ################################################################## 48 | ################################################################## 49 | 50 | source "$DIR/systems-common.sh" 51 | 52 | main() { 53 | #echo -n 54 | #set -x 55 | 56 | if [ -z "$args" ]; then 57 | err "Please specify a valid system id to publish" 58 | else 59 | 60 | cmd="curl -sk -H \"${authheader}\" -X PUT -d \"action=publish\" '$hosturl$args?pretty=true'" 61 | 62 | if ((veryverbose)); then 63 | [ "$piped" -eq 0 ] && log "Calling $cmd" 64 | fi 65 | 66 | response=`curl -sk -H "${authheader}" -X PUT -d "action=publish" "$hosturl$args?pretty=true"` 67 | 68 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 69 | result=$(format_api_json "$response") 70 | success "$result" 71 | else 72 | errorresponse=$(jsonquery "$response" "message") 73 | err "$errorresponse" 74 | fi 75 | fi 76 | } 77 | 78 | format_api_json() { 79 | 80 | if ((veryverbose)); then 81 | echo "$1" 82 | elif [[ $verbose -eq 1 ]]; then 83 | result=$(jsonquery "$1" "result" 1) 84 | json_prettyify "${result}" 85 | else 86 | system_id=$(jsonquery "$1" "result.id") 87 | echo "Successfully published system $args as $system_id" 88 | fi 89 | } 90 | 91 | ################################################################## 92 | ################################################################## 93 | # End Script Logic # 94 | ################################################################## 95 | ################################################################## 96 | 97 | # }}} 98 | 99 | # Parse command line options 100 | source "$DIR/options.sh" 101 | 102 | 103 | # Main loop {{{ 104 | 105 | # Print help if no arguments were passed. 106 | [[ $# -eq 0 ]] && set -- "-i" 107 | 108 | # Read the options and set stuff 109 | while [[ $1 = -?* ]]; do 110 | case $1 in 111 | -h|--help) usage >&2; safe_exit ;; 112 | --version) version; copyright; disclaimer; safe_exit ;; 113 | -z|--access_token) shift; access_token=$1 ;; 114 | -a|--action) shift; action=$1 ;; 115 | --filter) shift; responsefilter=$1;; 116 | -H|--hosturl) shift; hosturl=$1 ;; 117 | -d|--development) development=1 ;; 118 | -v|--verbose) verbose=1 ;; 119 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 120 | -q|--quiet) quiet=1 ;; 121 | -i|--interactive) interactive=1 ;; 122 | -f|--force) force=1 ;; 123 | --endopts) shift; break ;; 124 | *) die "invalid option: $1" ;; 125 | esac 126 | shift 127 | done 128 | 129 | # Store the remaining part as arguments. 130 | args+=("$@") 131 | 132 | # }}} 133 | 134 | # Run the script logic 135 | source "$DIR/runner.sh" 136 | -------------------------------------------------------------------------------- /bin/apps-erase: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # apps-erase 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It erases the app completely. This is an admin-only action and 9 | # should not be used unless you completely understand what you are 10 | # doing. 11 | # 12 | 13 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 14 | 15 | source "$DIR/common.sh" 16 | 17 | # Script logic -- TOUCH THIS {{{ 18 | 19 | # A list of all variables to prompt in interactive mode. These variables HAVE 20 | # to be named exactly as the longname option definition in usage(). 21 | interactive_opts=(apisecret apikey) 22 | 23 | # Print usage 24 | usage() { 25 | echo -n "$(basename $0) [OPTION]... [APP_ID] 26 | 27 | Erases an app completely. This is an admin-only action and should not 28 | be used unless you completely understand what you are doing. This action 29 | removes jobs, notifications, and metadata associated with it. Use with 30 | caution! 31 | 32 | Options: 33 | -z, --access_token Access token 34 | -H, --hosturl URL of the service 35 | -d, --development Run in dev mode using default dev server 36 | -f, --force Skip all user interaction 37 | -i, --interactive Prompt for values 38 | -q, --quiet Quiet (no output) 39 | -v, --verbose Verbose output 40 | -V, --veryverbose Very verbose output 41 | -h, --help Display this help and exit 42 | --version Output version information and exit 43 | " 44 | } 45 | 46 | ################################################################## 47 | ################################################################## 48 | # Begin Script Logic # 49 | ################################################################## 50 | ################################################################## 51 | 52 | source "$DIR/apps-common.sh" 53 | 54 | main() { 55 | #echo -n 56 | #set -x 57 | 58 | if [ -z "$args" ]; then 59 | err "Please specify a valid app id to erase" 60 | else 61 | 62 | cmd="curl -sk -H \"${authheader}\" -X PUT -d \"action=erase\" '$hosturl$args?pretty=true'" 63 | 64 | if ((veryverbose)); then 65 | [ "$piped" -eq 0 ] && log "Calling $cmd" 66 | fi 67 | 68 | response=`curl -sk -H "${authheader}" -X PUT -d "action=erase" "$hosturl$args?pretty=true"` 69 | 70 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 71 | result=$(format_api_json "$response") 72 | success "$result" 73 | else 74 | errorresponse=$(jsonquery "$response" "message") 75 | err "$errorresponse" 76 | fi 77 | fi 78 | } 79 | 80 | format_api_json() { 81 | 82 | if ((veryverbose)); then 83 | echo "$1" 84 | elif [[ $verbose -eq 1 ]]; then 85 | result=$(jsonquery "$1" "result" 1) 86 | json_prettyify "${result}" 87 | else 88 | echo "Successfully erased app $args" 89 | fi 90 | } 91 | 92 | ################################################################## 93 | ################################################################## 94 | # End Script Logic # 95 | ################################################################## 96 | ################################################################## 97 | 98 | # }}} 99 | 100 | # Parse command line options 101 | source "$DIR/options.sh" 102 | 103 | 104 | # Main loop {{{ 105 | 106 | # Print help if no arguments were passed. 107 | [[ $# -eq 0 ]] && set -- "-i" 108 | 109 | # Read the options and set stuff 110 | while [[ $1 = -?* ]]; do 111 | case $1 in 112 | -h|--help) usage >&2; safe_exit ;; 113 | --version) version; copyright; disclaimer; safe_exit ;; 114 | -z|--access_token) shift; access_token=$1 ;; 115 | -a|--action) shift; action=$1 ;; 116 | -H|--hosturl) shift; hosturl=$1;; 117 | -d|--development) development=1 ;; 118 | -v|--verbose) verbose=1 ;; 119 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 120 | -q|--quiet) quiet=1 ;; 121 | -i|--interactive) interactive=1 ;; 122 | -f|--force) force=1 ;; 123 | --endopts) shift; break ;; 124 | *) die "invalid option: $1" ;; 125 | esac 126 | shift 127 | done 128 | 129 | # Store the remaining part as arguments. 130 | args+=("$@") 131 | 132 | # }}} 133 | 134 | # Run the script logic 135 | source "$DIR/runner.sh" 136 | -------------------------------------------------------------------------------- /bin/systems-queues-delete: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # systems-queues-delete 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It provides a mechanism for removing batch queues on a system. 9 | # 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | source "$DIR/common.sh" 14 | 15 | # Script logic -- TOUCH THIS {{{ 16 | 17 | # A list of all variables to prompt in interactive mode. These variables HAVE 18 | # to be named exactly as the longname option definition in usage(). 19 | interactive_opts=(apisecret apikey username) 20 | 21 | # Print usage 22 | usage() { 23 | echo -n "$(basename $0) [OPTION]... [SYSTEM_ID] 24 | 25 | Remove a batch queue from a system. 26 | 27 | Options: 28 | -z, --access_token Access token 29 | -n, --queuename The name or id of the queue to delete 30 | -H, --hosturl URL of the service 31 | -d, --development Run in dev mode using default dev server 32 | -f, --force Skip all user interaction 33 | -i, --interactive Prompt for values 34 | -q, --quiet Quiet (no output) 35 | -v, --verbose Verbose output 36 | -V, --veryverbose Very verbose output 37 | -h, --help Display this help and exit 38 | --version Output version information and exit 39 | " 40 | } 41 | 42 | ################################################################## 43 | ################################################################## 44 | # Begin Script Logic # 45 | ################################################################## 46 | ################################################################## 47 | 48 | source "$DIR/systems-common.sh" 49 | 50 | main() { 51 | #echo -n 52 | #set -x 53 | 54 | if [ -z "$args" ]; then 55 | err "Please specify a valid system id for which to delete the batch queues" 56 | else 57 | 58 | cmd="curl -sk -H \"${authheader}\" -X DELETE '$hosturl$args/queues/$queuename?pretty=true'" 59 | 60 | if ((veryverbose)); then 61 | [ "$piped" -eq 0 ] && log "Calling $cmd" 62 | fi 63 | 64 | response=`curl -sk -H "${authheader}" -X DELETE "$hosturl$args/queues/$queuename?pretty=true"` 65 | 66 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 67 | result=$(format_api_json "$response") 68 | success "$result" 69 | else 70 | errorresponse=$(jsonquery "$response" "message") 71 | err "$errorresponse" 72 | fi 73 | fi 74 | } 75 | 76 | format_api_json() { 77 | 78 | if ((veryverbose)); then 79 | echo "$1" 80 | elif [[ $verbose -eq 1 ]]; then 81 | result=$(jsonquery "$1" "result" 1) 82 | echo "${result}" | python -mjson.tool 83 | else 84 | if [ -n "$queuename" ]; then 85 | echo "Successfully deleted queue for user $username" 86 | else 87 | echo "Successfully deleted all batch queues for $args" 88 | fi 89 | fi 90 | } 91 | 92 | ################################################################## 93 | ################################################################## 94 | # End Script Logic # 95 | ################################################################## 96 | ################################################################## 97 | 98 | # }}} 99 | 100 | # Parse command line options 101 | source "$DIR/options.sh" 102 | 103 | 104 | # Main loop {{{ 105 | 106 | # Print help if no arguments were passed. 107 | #[[ $# -eq 0 ]] && set -- "--help" 108 | 109 | # Read the options and set stuff 110 | while [[ $1 = -?* ]]; do 111 | case $1 in 112 | -h|--help) usage >&2; safe_exit ;; 113 | --version) version; copyright; disclaimer; safe_exit ;; 114 | -z|--access_token) shift; access_token=$1 ;; 115 | -n|--queuename) shift; queuename=$1 ;; 116 | --filter) shift; responsefilter=$1;; 117 | -H|--hosturl) shift; hosturl=$1 ;; 118 | -d|--development) development=1 ;; 119 | -v|--verbose) verbose=1 ;; 120 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 121 | -q|--quiet) quiet=1 ;; 122 | -i|--interactive) interactive=1 ;; 123 | -f|--force) force=1 ;; 124 | --endopts) shift; break ;; 125 | *) die "invalid option: $1" ;; 126 | esac 127 | shift 128 | done 129 | 130 | # Store the remaining part as arguments. 131 | args+=("$@") 132 | 133 | # }}} 134 | 135 | # Run the script logic 136 | source "$DIR/runner.sh" 137 | -------------------------------------------------------------------------------- /bin/systems-roles-delete: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # systems-roles-delete 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It provides a mechanism for removing user roles on a system. 9 | # 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | source "$DIR/common.sh" 14 | 15 | # Script logic -- TOUCH THIS {{{ 16 | 17 | # A list of all variables to prompt in interactive mode. These variables HAVE 18 | # to be named exactly as the longname option definition in usage(). 19 | interactive_opts=(apisecret apikey username) 20 | 21 | # Print usage 22 | usage() { 23 | echo -n "$(basename $0) [OPTION]... [SYSTEM_ID] 24 | 25 | Removes user roles on a system. Specifying a username will remove just the 26 | role for the named user. 27 | 28 | Options: 29 | -z, --access_token Access token 30 | -u, --roleusername The user whose permissions should be set 31 | -H, --hosturl URL of the service 32 | -d, --development Run in dev mode using default dev server 33 | -f, --force Skip all user interaction 34 | -i, --interactive Prompt for values 35 | -q, --quiet Quiet (no output) 36 | -v, --verbose Verbose output 37 | -V, --veryverbose Very verbose output 38 | -h, --help Display this help and exit 39 | --version Output version information and exit 40 | " 41 | } 42 | 43 | ################################################################## 44 | ################################################################## 45 | # Begin Script Logic # 46 | ################################################################## 47 | ################################################################## 48 | 49 | source "$DIR/systems-common.sh" 50 | 51 | main() { 52 | #echo -n 53 | #set -x 54 | 55 | if [ -z "$args" ]; then 56 | err "Please specify a valid system id for which to retrieve the user roles" 57 | else 58 | cmd="curl -sk -H \"${authheader}\" -X DELETE '$hosturl$args/roles/$roleusername?pretty=true'" 59 | 60 | if ((veryverbose)); then 61 | [ "$piped" -eq 0 ] && log "Calling $cmd" 62 | fi 63 | 64 | response=`curl -sk -H "${authheader}" -X DELETE "$hosturl$args/roles/$roleusername?pretty=true"` 65 | 66 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 67 | result=$(format_api_json "$response") 68 | success "$result" 69 | else 70 | errorresponse=$(jsonquery "$response" "message") 71 | err "$errorresponse" 72 | fi 73 | fi 74 | } 75 | 76 | format_api_json() { 77 | 78 | if ((veryverbose)); then 79 | echo "$1" 80 | elif [[ $verbose -eq 1 ]]; then 81 | result=$(jsonquery "$1" "result" 1) 82 | json_prettyify "${result}" 83 | else 84 | if [ -n "$username" ]; then 85 | echo "Successfully deleted roles for user $username" 86 | else 87 | echo "Successfully deleted all user roles for $args" 88 | fi 89 | fi 90 | } 91 | 92 | ################################################################## 93 | ################################################################## 94 | # End Script Logic # 95 | ################################################################## 96 | ################################################################## 97 | 98 | # }}} 99 | 100 | # Parse command line options 101 | source "$DIR/options.sh" 102 | 103 | 104 | # Main loop {{{ 105 | 106 | # Print help if no arguments were passed. 107 | #[[ $# -eq 0 ]] && set -- "--help" 108 | 109 | # Read the options and set stuff 110 | while [[ $1 = -?* ]]; do 111 | case $1 in 112 | -h|--help) usage >&2; safe_exit ;; 113 | --version) version; copyright; disclaimer; safe_exit ;; 114 | -z|--access_token) shift; access_token=$1 ;; 115 | -u|--roleusername) shift; roleusername=$1 ;; 116 | -H|--hosturl) shift; hosturl=$1;; 117 | -d|--development) development=1 ;; 118 | -v|--verbose) verbose=1 ;; 119 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 120 | -q|--quiet) quiet=1 ;; 121 | -i|--interactive) interactive=1 ;; 122 | -f|--force) force=1 ;; 123 | --endopts) shift; break ;; 124 | *) die "invalid option: $1" ;; 125 | esac 126 | shift 127 | done 128 | 129 | # Store the remaining part as arguments. 130 | args+=("$@") 131 | 132 | # }}} 133 | 134 | # Run the script logic 135 | source "$DIR/runner.sh" 136 | -------------------------------------------------------------------------------- /bin/systems-unpublish: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # systems-publish 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It removes the system from public use. Global admin privileges are 9 | # required to publish and unpublish a system. 10 | # 11 | 12 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 13 | 14 | source "$DIR/common.sh" 15 | 16 | # Script logic -- TOUCH THIS {{{ 17 | 18 | # A list of all variables to prompt in interactive mode. These variables HAVE 19 | # to be named exactly as the longname option definition in usage(). 20 | interactive_opts=(apisecret apikey) 21 | 22 | # Print usage 23 | usage() { 24 | echo -n "$(basename $0) [OPTION]... [SYSTEM_ID] 25 | 26 | Removes the system from public use. Global admin privileges are required to 27 | publish and unpublish a system. 28 | 29 | Options: 30 | -z, --access_token Access token 31 | --filter Comma separated list of fields to return in the response 32 | -H, --hosturl URL of the service 33 | -d, --development Run in dev mode using default dev server 34 | -f, --force Skip all user interaction 35 | -i, --interactive Prompt for values 36 | -q, --quiet Quiet (no output) 37 | -v, --verbose Verbose output 38 | -V, --veryverbose Very verbose output 39 | -h, --help Display this help and exit 40 | --version Output version information and exit 41 | " 42 | } 43 | 44 | ################################################################## 45 | ################################################################## 46 | # Begin Script Logic # 47 | ################################################################## 48 | ################################################################## 49 | 50 | source "$DIR/systems-common.sh" 51 | 52 | main() { 53 | #echo -n 54 | #set -x 55 | 56 | if [ -z "$args" ]; then 57 | err "Please specify a valid system id to publish" 58 | else 59 | 60 | cmd="curl -sk -H \"${authheader}\" -X PUT -d \"action=unpublish\" '$hosturl$args?pretty=true'" 61 | 62 | if ((veryverbose)); then 63 | [ "$piped" -eq 0 ] && log "Calling $cmd" 64 | fi 65 | 66 | response=`curl -sk -H "${authheader}" -X PUT -d "action=unpublish" "$hosturl$args?pretty=true"` 67 | 68 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 69 | result=$(format_api_json "$response") 70 | success "$result" 71 | else 72 | errorresponse=$(jsonquery "$response" "message") 73 | err "$errorresponse" 74 | fi 75 | fi 76 | } 77 | 78 | format_api_json() { 79 | 80 | if ((veryverbose)); then 81 | echo "$1" 82 | elif [[ $verbose -eq 1 ]]; then 83 | result=$(jsonquery "$1" "result" 1) 84 | json_prettyify "${result}" 85 | else 86 | system_id=$(jsonquery "$1" "result.id") 87 | echo "Successfully removed system $args from public use" 88 | fi 89 | } 90 | 91 | ################################################################## 92 | ################################################################## 93 | # End Script Logic # 94 | ################################################################## 95 | ################################################################## 96 | 97 | # }}} 98 | 99 | # Parse command line options 100 | source "$DIR/options.sh" 101 | 102 | 103 | # Main loop {{{ 104 | 105 | # Print help if no arguments were passed. 106 | [[ $# -eq 0 ]] && set -- "-i" 107 | 108 | # Read the options and set stuff 109 | while [[ $1 = -?* ]]; do 110 | case $1 in 111 | -h|--help) usage >&2; safe_exit ;; 112 | --version) version; copyright; disclaimer; safe_exit ;; 113 | -z|--access_token) shift; access_token=$1 ;; 114 | -a|--action) shift; action=$1 ;; 115 | --filter) shift; responsefilter=$1;; 116 | -H|--hosturl) shift; hosturl=$1 ;; 117 | -d|--development) development=1 ;; 118 | -v|--verbose) verbose=1 ;; 119 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 120 | -q|--quiet) quiet=1 ;; 121 | -i|--interactive) interactive=1 ;; 122 | -f|--force) force=1 ;; 123 | --endopts) shift; break ;; 124 | *) die "invalid option: $1" ;; 125 | esac 126 | shift 127 | done 128 | 129 | # Store the remaining part as arguments. 130 | args+=("$@") 131 | 132 | # }}} 133 | 134 | # Run the script logic 135 | source "$DIR/runner.sh" 136 | -------------------------------------------------------------------------------- /bin/systems-erase: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # systems-erase 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It erases the system completely. This is an admin-only action and 9 | # should not be used unless you completely understand what you are 10 | # doing. 11 | # 12 | 13 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 14 | 15 | source "$DIR/common.sh" 16 | 17 | # Script logic -- TOUCH THIS {{{ 18 | 19 | # A list of all variables to prompt in interactive mode. These variables HAVE 20 | # to be named exactly as the longname option definition in usage(). 21 | interactive_opts=(apisecret apikey) 22 | 23 | # Print usage 24 | usage() { 25 | echo -n "$(basename $0) [OPTION]... [SYSTEM_ID] 26 | 27 | Erases a system completely. This is an admin-only action and should not 28 | be used unless you completely understand what you are doing. This action 29 | does not clean up references to itself in remote apps, files, metadata, 30 | etc, so it can get messy. 31 | 32 | Options: 33 | -z, --access_token Access token 34 | -H, --hosturl URL of the service 35 | -d, --development Run in dev mode using default dev server 36 | -f, --force Skip all user interaction 37 | -i, --interactive Prompt for values 38 | -q, --quiet Quiet (no output) 39 | -v, --verbose Verbose output 40 | -V, --veryverbose Very verbose output 41 | -h, --help Display this help and exit 42 | --version Output version information and exit 43 | " 44 | } 45 | 46 | ################################################################## 47 | ################################################################## 48 | # Begin Script Logic # 49 | ################################################################## 50 | ################################################################## 51 | 52 | source "$DIR/systems-common.sh" 53 | 54 | main() { 55 | #echo -n 56 | #set -x 57 | 58 | if [ -z "$args" ]; then 59 | err "Please specify a valid system id to erase" 60 | else 61 | 62 | cmd="curl -sk -H \"${authheader}\" -X PUT -d \"action=erase\" '$hosturl$args?pretty=true'" 63 | 64 | if ((veryverbose)); then 65 | [ "$piped" -eq 0 ] && log "Calling $cmd" 66 | fi 67 | 68 | response=`curl -sk -H "${authheader}" -X PUT -d "action=erase" "$hosturl$args?pretty=true"` 69 | 70 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 71 | result=$(format_api_json "$response") 72 | success "$result" 73 | else 74 | errorresponse=$(jsonquery "$response" "message") 75 | err "$errorresponse" 76 | fi 77 | fi 78 | } 79 | 80 | format_api_json() { 81 | 82 | if ((veryverbose)); then 83 | echo "$1" 84 | elif [[ $verbose -eq 1 ]]; then 85 | result=$(jsonquery "$1" "result" 1) 86 | json_prettyify "${result}" 87 | else 88 | system_id=$(jsonquery "$1" "result.id") 89 | echo "Successfully erased system $args" 90 | fi 91 | } 92 | 93 | ################################################################## 94 | ################################################################## 95 | # End Script Logic # 96 | ################################################################## 97 | ################################################################## 98 | 99 | # }}} 100 | 101 | # Parse command line options 102 | source "$DIR/options.sh" 103 | 104 | 105 | # Main loop {{{ 106 | 107 | # Print help if no arguments were passed. 108 | [[ $# -eq 0 ]] && set -- "-i" 109 | 110 | # Read the options and set stuff 111 | while [[ $1 = -?* ]]; do 112 | case $1 in 113 | -h|--help) usage >&2; safe_exit ;; 114 | --version) version; copyright; disclaimer; safe_exit ;; 115 | -z|--access_token) shift; access_token=$1 ;; 116 | -a|--action) shift; action=$1 ;; 117 | --filter) shift; responsefilter=$1;; 118 | -H|--hosturl) shift; hosturl=$1 ;; 119 | -d|--development) development=1 ;; 120 | -v|--verbose) verbose=1 ;; 121 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 122 | -q|--quiet) quiet=1 ;; 123 | -i|--interactive) interactive=1 ;; 124 | -f|--force) force=1 ;; 125 | --endopts) shift; break ;; 126 | *) die "invalid option: $1" ;; 127 | esac 128 | shift 129 | done 130 | 131 | # Store the remaining part as arguments. 132 | args+=("$@") 133 | 134 | # }}} 135 | 136 | # Run the script logic 137 | source "$DIR/runner.sh" 138 | -------------------------------------------------------------------------------- /bin/apps-disable: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # apps-disable 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # Disables an app by settings its available flag to false 9 | # 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | source "$DIR/common.sh" 14 | 15 | # Script logic -- TOUCH THIS {{{ 16 | 17 | # A list of all variables to prompt in interactive mode. These variables HAVE 18 | # to be named exactly as the longname option definition in usage(). 19 | interactive_opts=(apisecret apikey) 20 | 21 | # Print usage 22 | usage() { 23 | echo -n "$(basename $0) [OPTION]... [APP_ID] 24 | 25 | Makes an app unavailable by setting the available flag to false. 26 | Proper app permissions are required. 27 | 28 | Options: 29 | -z, --access_token Access token 30 | --filter Comma separated list of fields to return in the response 31 | -H, --hosturl URL of the service 32 | -d, --development Run in dev mode using default dev server 33 | -f, --force Skip all user interaction 34 | -i, --interactive Prompt for values 35 | -q, --quiet Quiet (no output) 36 | -v, --verbose Verbose output 37 | -V, --veryverbose Very verbose output 38 | -h, --help Display this help and exit 39 | --version Output version information and exit 40 | " 41 | } 42 | 43 | ################################################################## 44 | ################################################################## 45 | # Begin Script Logic # 46 | ################################################################## 47 | ################################################################## 48 | 49 | source "$DIR/apps-common.sh" 50 | 51 | main() { 52 | #echo -n 53 | #set -x 54 | 55 | if [ -z "$args" ]; then 56 | err "Please specify a valid app id to enable" 57 | else 58 | 59 | cmd="curl -sk -H \"${authheader}\" -X PUT -d \"action=disable\" '$hosturl$args?pretty=true'" 60 | 61 | if ((veryverbose)); then 62 | [ "$piped" -eq 0 ] && log "Calling $cmd" 63 | fi 64 | 65 | response=`curl -sk -H "${authheader}" -X PUT -d "action=disable" "$hosturl$args?pretty=true"` 66 | 67 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 68 | result=$(format_api_json "$response") 69 | success "$result" 70 | else 71 | errorresponse=$(jsonquery "$response" "message") 72 | err "$errorresponse" 73 | fi 74 | fi 75 | } 76 | 77 | format_api_json() { 78 | 79 | if ((veryverbose)); then 80 | echo "$1" 81 | elif [[ $verbose -eq 1 ]]; then 82 | result=$(jsonquery "$1" "result" 1) 83 | json_prettyify "${result}" 84 | else 85 | result=$(jsonquery "$1" "result.id") 86 | success "Successfully disabled app $args" 87 | fi 88 | } 89 | 90 | ################################################################## 91 | ################################################################## 92 | # End Script Logic # 93 | ################################################################## 94 | ################################################################## 95 | 96 | # }}} 97 | 98 | # Parse command line options 99 | source "$DIR/options.sh" 100 | 101 | 102 | # Main loop {{{ 103 | 104 | # Print help if no arguments were passed. 105 | [[ $# -eq 0 ]] && set -- "-i" 106 | 107 | # Read the options and set stuff 108 | while [[ $1 = -?* ]]; do 109 | case $1 in 110 | -h|--help) usage >&2; safe_exit ;; 111 | --version) version; copyright; disclaimer; safe_exit ;; 112 | -s|--deploymentSystem) shift; deploymentSystem=$1 ;; 113 | -p|--deploymentPath) shift; deploymentPath=$1 ;; 114 | -e|--executionSystem) shift; executionSystem=$1 ;; 115 | -n|--name) shift; name=$1 ;; 116 | -x|--appVersion) shift; appVersion=$1 ;; 117 | -z|--access_token) shift; access_token=$1 ;; 118 | -H|--hosturl) shift; hosturl=$1 ;; 119 | -d|--development) development=1 ;; 120 | -v|--verbose) verbose=1 ;; 121 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 122 | -q|--quiet) quiet=1 ;; 123 | -i|--interactive) interactive=1 ;; 124 | -f|--force) force=1 ;; 125 | --endopts) shift; break ;; 126 | *) die "invalid option: $1" ;; 127 | esac 128 | shift 129 | done 130 | 131 | # Store the remaining part as arguments. 132 | args+=("$@") 133 | 134 | # }}} 135 | 136 | # Run the script logic 137 | source "$DIR/runner.sh" 138 | -------------------------------------------------------------------------------- /bin/apps-enable: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # apps-enable 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It makes an app available by settings its available flag to true 9 | # 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | source "$DIR/common.sh" 14 | 15 | # Script logic -- TOUCH THIS {{{ 16 | 17 | # A list of all variables to prompt in interactive mode. These variables HAVE 18 | # to be named exactly as the longname option definition in usage(). 19 | interactive_opts=(apisecret apikey) 20 | 21 | # Print usage 22 | usage() { 23 | echo -n "$(basename $0) [OPTION]... [APP_ID] 24 | 25 | Makes an app available by setting the available flag to true. 26 | Proper app permissions are required. 27 | 28 | Options: 29 | -z, --access_token Access token 30 | --filter Comma separated list of fields to return in the response 31 | -H, --hosturl URL of the service 32 | -d, --development Run in dev mode using default dev server 33 | -f, --force Skip all user interaction 34 | -i, --interactive Prompt for values 35 | -q, --quiet Quiet (no output) 36 | -v, --verbose Verbose output 37 | -V, --veryverbose Very verbose output 38 | -h, --help Display this help and exit 39 | --version Output version information and exit 40 | " 41 | } 42 | 43 | ################################################################## 44 | ################################################################## 45 | # Begin Script Logic # 46 | ################################################################## 47 | ################################################################## 48 | 49 | source "$DIR/apps-common.sh" 50 | 51 | main() { 52 | #echo -n 53 | #set -x 54 | 55 | if [ -z "$args" ]; then 56 | err "Please specify a valid app id to enable" 57 | else 58 | 59 | cmd="curl -sk -H \"${authheader}\" -X PUT -d \"action=enable\" '$hosturl$args?pretty=true'" 60 | 61 | if ((veryverbose)); then 62 | [ "$piped" -eq 0 ] && log "Calling $cmd" 63 | fi 64 | 65 | response=`curl -sk -H "${authheader}" -X PUT -d "action=enable" "$hosturl$args?pretty=true"` 66 | 67 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 68 | result=$(format_api_json "$response") 69 | success "$result" 70 | else 71 | errorresponse=$(jsonquery "$response" "message") 72 | err "$errorresponse" 73 | fi 74 | fi 75 | } 76 | 77 | format_api_json() { 78 | 79 | if ((veryverbose)); then 80 | echo "$1" 81 | elif [[ $verbose -eq 1 ]]; then 82 | result=$(jsonquery "$1" "result" 1) 83 | json_prettyify "${result}" 84 | else 85 | result=$(jsonquery "$1" "result.id") 86 | success "Successfully enabled app $args" 87 | fi 88 | } 89 | 90 | ################################################################## 91 | ################################################################## 92 | # End Script Logic # 93 | ################################################################## 94 | ################################################################## 95 | 96 | # }}} 97 | 98 | # Parse command line options 99 | source "$DIR/options.sh" 100 | 101 | 102 | # Main loop {{{ 103 | 104 | # Print help if no arguments were passed. 105 | [[ $# -eq 0 ]] && set -- "-i" 106 | 107 | # Read the options and set stuff 108 | while [[ $1 = -?* ]]; do 109 | case $1 in 110 | -h|--help) usage >&2; safe_exit ;; 111 | --version) version; copyright; disclaimer; safe_exit ;; 112 | -s|--deploymentSystem) shift; deploymentSystem=$1 ;; 113 | -p|--deploymentPath) shift; deploymentPath=$1 ;; 114 | -e|--executionSystem) shift; executionSystem=$1 ;; 115 | -n|--name) shift; name=$1 ;; 116 | -x|--appVersion) shift; appVersion=$1 ;; 117 | -z|--access_token) shift; access_token=$1 ;; 118 | -H|--hosturl) shift; hosturl=$1 ;; 119 | -d|--development) development=1 ;; 120 | -v|--verbose) verbose=1 ;; 121 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 122 | -q|--quiet) quiet=1 ;; 123 | -i|--interactive) interactive=1 ;; 124 | -f|--force) force=1 ;; 125 | --endopts) shift; break ;; 126 | *) die "invalid option: $1" ;; 127 | esac 128 | shift 129 | done 130 | 131 | # Store the remaining part as arguments. 132 | args+=("$@") 133 | 134 | # }}} 135 | 136 | # Run the script logic 137 | source "$DIR/runner.sh" 138 | -------------------------------------------------------------------------------- /bin/metadata-schema-addupdate: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # metadata-schema-addupdate 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It adds a piece of metadata. 9 | # 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | source "$DIR/common.sh" 14 | 15 | # Script logic -- TOUCH THIS {{{ 16 | 17 | # A list of all variables to prompt in interactive mode. These variables HAVE 18 | # to be named exactly as the longname option definition in usage(). 19 | interactive_opts=(apisecret apikey) 20 | 21 | # Print usage 22 | usage() { 23 | echo -n "$(basename $0) [OPTION]... 24 | $(basename $0) [OPTION]... [SCHEMA_ID] 25 | 26 | Add a metadata schema. If registering a new metadata schema, no schema id should 27 | be provided. If updating an existing metadata schema, a schema id must be 28 | provided. 29 | 30 | Options: 31 | -z, --access_token Access token 32 | -F, --filetoupload The file containing the JSON metadata schema to submit 33 | -D, --data The raw JSON to upload 34 | --filter Comma separated list of fields to return in the response 35 | -H, --hosturl URL of the service 36 | -d, --development Run in dev mode using default dev server 37 | -f, --force Skip all user interaction 38 | -i, --interactive Prompt for values 39 | -q, --quiet Quiet (no output) 40 | -v, --verbose Verbose output 41 | -V, --veryverbose Very verbose output 42 | -h, --help Display this help and exit 43 | --version Output version information and exit 44 | " 45 | } 46 | 47 | ################################################################## 48 | ################################################################## 49 | # Begin Script Logic # 50 | ################################################################## 51 | ################################################################## 52 | 53 | source "$DIR/metadata-common.sh" 54 | 55 | main() { 56 | #echo -n 57 | #set -x 58 | 59 | cmd="curl -sk -H \"${authheader}\" -X POST -F \"fileToUpload=@$filetoupload\" '${hosturl}schemas/${args}?pretty=true'" 60 | 61 | if ((veryverbose)); then 62 | [ "$piped" -eq 0 ] && log "Calling $cmd" 63 | fi 64 | 65 | response=`curl -sk -H "${authheader}" -X POST -F "fileToUpload=@${filetoupload}" "${hosturl}schemas/${args}?pretty=true"` 66 | 67 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 68 | result=$(format_api_json "$response") 69 | success "$result" 70 | else 71 | errorresponse=$(jsonquery "$response" "message") 72 | err "$errorresponse" 73 | fi 74 | } 75 | 76 | format_api_json() { 77 | 78 | if ((veryverbose)); then 79 | echo "$1" 80 | elif [[ $verbose -eq 1 ]]; then 81 | result=$(jsonquery "$1" "result" 1) 82 | json_prettyify "${result}" 83 | else 84 | uuid=$(jsonquery "$1" "result.uuid") 85 | echo "Successfully submitted metadata schema object $uuid" 86 | fi 87 | } 88 | 89 | ################################################################## 90 | ################################################################## 91 | # End Script Logic # 92 | ################################################################## 93 | ################################################################## 94 | 95 | # }}} 96 | 97 | # Parse command line options 98 | source "$DIR/options.sh" 99 | 100 | 101 | # Main loop {{{ 102 | 103 | # Print help if no arguments were passed. 104 | [[ $# -eq 0 ]] && set -- "-i" 105 | 106 | # Read the options and set stuff 107 | while [[ $1 = -?* ]]; do 108 | case $1 in 109 | -h|--help) usage >&2; safe_exit ;; 110 | --version) version; copyright; disclaimer; safe_exit ;; 111 | -z|--access_token) shift; access_token=$1 ;; 112 | -F|--filetoupload) shift; filetoupload=$1 ;; 113 | --filter) shift; responsefilter=$1 ;; 114 | -H|--hosturl) shift; hosturl=$1;; 115 | -d|--development) development=1 ;; 116 | -v|--verbose) verbose=1 ;; 117 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 118 | -q|--quiet) quiet=1 ;; 119 | -i|--interactive) interactive=1 ;; 120 | -f|--force) force=1 ;; 121 | --endopts) shift; break ;; 122 | *) die "invalid option: $1" ;; 123 | esac 124 | shift 125 | done 126 | 127 | # Store the remaining part as arguments. 128 | args+=("$@") 129 | 130 | # }}} 131 | 132 | # Run the script logic 133 | source "$DIR/runner.sh" 134 | -------------------------------------------------------------------------------- /bin/requestbin-requests-list: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # requestbin-requests-list 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It lists the contents of a requestbin 9 | # 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | source "$DIR/common.sh" 14 | 15 | # Script logic -- TOUCH THIS {{{ 16 | 17 | # A list of all variables to prompt in interactive mode. These variables HAVE 18 | # to be named exactly as the longname option definition in usage(). 19 | interactive_opts=() 20 | 21 | # Print usage 22 | usage() { 23 | echo -n "$(basename $0) [OPTION]... [REQUESTBIN_ID] 24 | 25 | Lists all requests made to the requestbin with the given id. 26 | 27 | Options: 28 | -H, --hosturl URL of the service 29 | -d, --development Run in dev mode using default dev server 30 | -f, --force Skip all user interaction 31 | -i, --interactive Prompt for values 32 | -q, --quiet Quiet (no output) 33 | -v, --verbose Verbose output 34 | -V, --veryverbose Very verbose output 35 | -h, --help Display this help and exit 36 | --version Output version information and exit 37 | " 38 | } 39 | 40 | ################################################################## 41 | ################################################################## 42 | # Begin Script Logic # 43 | ################################################################## 44 | ################################################################## 45 | 46 | source "$DIR/requestbin-common.sh" 47 | 48 | main() { 49 | #echo -n 50 | #set -x 51 | 52 | if [ -z "$args" ]; then 53 | err "Please specify a valid system id for which to retrieve the credentials" 54 | else 55 | cmd="curl -sk '${hosturl}api/v1/bins/${args}/requests'" 56 | 57 | if ((veryverbose)); then 58 | [ "$piped" -eq 0 ] && log "Calling $cmd" 59 | fi 60 | 61 | response=`curl -sk ${hosturl}api/v1/bins/${args}/requests` 62 | 63 | if [[ -n $(jsonquery "$response" "[].id") ]]; then 64 | result=$(format_api_json "$response") 65 | success "$result" 66 | else 67 | errorresponse=$(jsonquery "$response" "error") 68 | err "$errorresponse" 69 | fi 70 | fi 71 | } 72 | 73 | format_api_json() { 74 | 75 | if ((veryverbose)); then 76 | json_prettyify "${1}" 77 | elif [[ $verbose -eq 1 ]]; then 78 | json_prettyify "${result}" 79 | else 80 | times=( $(jsonquery "$1" "[].time") ) 81 | n=0 82 | for i in $(jsonquery "$1" "[].method") 83 | do 84 | # adjust for bsd date vs gnu date 85 | if [[ "$os" = "Darwin" ]]; then 86 | TS=${times[$n]%.*} 87 | # TS=${TS%.*} 88 | TS=$(date -r $TS) 89 | else 90 | TS=$(date -d @"${times[$n]%.*}") 91 | fi 92 | requests[$n]="$i on $TS" 93 | n=$[n+1] 94 | done 95 | 96 | for i in "${requests[@]}"; do 97 | echo "$i" 98 | done 99 | fi 100 | } 101 | 102 | ################################################################## 103 | ################################################################## 104 | # End Script Logic # 105 | ################################################################## 106 | ################################################################## 107 | 108 | # }}} 109 | 110 | # Parse command line options 111 | source "$DIR/options.sh" 112 | 113 | # Main loop {{{ 114 | 115 | # Print help if no arguments were passed. 116 | #[[ $# -eq 0 ]] && set -- "--help" 117 | 118 | # Read the options and set stuff 119 | while [[ $1 = -?* ]]; do 120 | case $1 in 121 | -h|--help) usage >&2; safe_exit ;; 122 | --version) version; copyright; disclaimer; safe_exit ;; 123 | -H|--hosturl) shift; hosturl=$1;; 124 | -d|--development) development=1 ;; 125 | -v|--verbose) verbose=1 ;; 126 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 127 | -q|--quiet) quiet=1 ;; 128 | -i|--interactive) interactive=1 ;; 129 | -f|--force) force=1 ;; 130 | --endopts) shift; break ;; 131 | *) die "invalid option: $1" ;; 132 | esac 133 | shift 134 | done 135 | 136 | # Store the remaining part as arguments. 137 | args+=("$@") 138 | 139 | # }}} 140 | 141 | # Run the script logic 142 | source "$DIR/runner.sh" 143 | -------------------------------------------------------------------------------- /bin/clients-subscriptions-list: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # clients-subscriptions-list 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It retrieves a list of API subscriptions for the named client 9 | # 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | source "$DIR/common.sh" 14 | interactive=1 15 | 16 | # Script logic -- TOUCH THIS {{{ 17 | 18 | # A list of all variables to prompt in interactive mode. These variables HAVE 19 | # to be named exactly as the longname option definition in usage(). 20 | interactive_opts=(apiusername apipassword) 21 | 22 | # Print usage 23 | usage() { 24 | echo -n "$(basename $0) [OPTION]... [CLIENT_NAME] 25 | 26 | List all APIs to which the client is subscribed. 27 | 28 | Options: 29 | -u, --apiusername API apiusername 30 | -p, --apipassword API apipassword 31 | -l, --limit Maximum number of results to return 32 | -o, --offset Number of results to skip from the start 33 | -H, --hosturl URL of the service 34 | -d, --development Run in dev mode using default dev server 35 | -f, --force Skip all user interaction 36 | -i, --interactive Prompt for values 37 | -q, --quiet Quiet (no output) 38 | -v, --verbose Verbose output 39 | -V, --veryverbose Very verbose output 40 | -h, --help Display this help and exit 41 | --version Output version information and exit 42 | " 43 | } 44 | 45 | ################################################################## 46 | ################################################################## 47 | # Begin Script Logic # 48 | ################################################################## 49 | ################################################################## 50 | 51 | source "$DIR/clients-common.sh" 52 | 53 | main() { 54 | #echo -n 55 | #set -x 56 | 57 | if [ -z "$args" ]; then 58 | err "Please specify a valid client for which to list subscriptions" 59 | else 60 | cmd="curl -sku \"${apiusername}:${apipassword}\" '${hosturl}${args}/subscriptions?pretty=true$(pagination)'" 61 | 62 | if ((veryverbose)); then 63 | [ "$piped" -eq 0 ] && log "Calling $cmd" 64 | fi 65 | 66 | response=`curl -sku "${apiusername}:${apipassword}" "${hosturl}${args}/subscriptions?pretty=true$(pagination)"` 67 | 68 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 69 | result=$(format_api_json "$response") 70 | success "$result" 71 | else 72 | errorresponse=$(jsonquery "$response" "message") 73 | err "$errorresponse" 74 | fi 75 | 76 | fi 77 | } 78 | 79 | format_api_json() { 80 | 81 | if ((veryverbose)); then 82 | json_prettyify "${1}" 83 | elif [[ $verbose -eq 1 ]]; then 84 | result=$(jsonquery "$1" "result" 1) 85 | json_prettyify "${result}" 86 | else 87 | result=$(jsonquery "$1" "result.[].apiName") 88 | echo "${result}" 89 | fi 90 | } 91 | 92 | ################################################################## 93 | ################################################################## 94 | # End Script Logic # 95 | ################################################################## 96 | ################################################################## 97 | 98 | # }}} 99 | 100 | # Parse command line options 101 | source "$DIR/options.sh" 102 | 103 | 104 | # Main loop {{{ 105 | 106 | # Print help if no arguments were passed. 107 | #[[ $# -eq 0 ]] && set -- "--help" 108 | 109 | # Read the options and set stuff 110 | while [[ $1 = -?* ]]; do 111 | case $1 in 112 | -h|--help) usage >&2; safe_exit ;; 113 | --version) version; copyright; disclaimer; safe_exit ;; 114 | -u|--apiusername) shift; apiusername=$1 ;; 115 | -p|--apipassword) shift; apipassword=$1 ;; 116 | -l|--limit) shift; limit=$1;; 117 | -o|--offset) shift; offset=$1;; 118 | --filter) shift; responsefilter=$1 ;; 119 | -H|--hosturl) shift; hosturl=$1;; 120 | -d|--development) development=1 ;; 121 | -v|--verbose) verbose=1 ;; 122 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 123 | -q|--quiet) quiet=1 ;; 124 | -i|--interactive) interactive=1 ;; 125 | -f|--force) force=1 ;; 126 | --endopts) shift; break ;; 127 | *) die "invalid option: $1" ;; 128 | esac 129 | shift 130 | done 131 | 132 | # Store the remaining part as arguments. 133 | args+=("$@") 134 | 135 | # }}} 136 | 137 | # Run the script logic 138 | source "$DIR/runner.sh" 139 | -------------------------------------------------------------------------------- /bin/apps-pems-delete: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # apps-pems-delete 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It provides a mechanism for deleting one or more share permissions 9 | # on an application. 10 | # 11 | 12 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 13 | 14 | source "$DIR/common.sh" 15 | 16 | # Script logic -- TOUCH THIS {{{ 17 | 18 | # A list of all variables to prompt in interactive mode. These variables HAVE 19 | # to be named exactly as the longname option definition in usage(). 20 | interactive_opts=(apisecret apikey username permission) 21 | 22 | # Print usage 23 | usage() { 24 | echo -n "$(basename $0) [OPTION]... [APP_ID] 25 | 26 | Remove the user permissions on this application. This will impact who can 27 | view and run this application. If no user is specified, all permissions 28 | on this app are removed. 29 | 30 | Options: 31 | -z, --access_token Access token 32 | -u, --pemusername The user whose permissions should be removed 33 | -H, --hosturl URL of the service 34 | -d, --development Run in dev mode using default dev server 35 | -f, --force Skip all user interaction 36 | -i, --interactive Prompt for values 37 | -q, --quiet Quiet (no output) 38 | -v, --verbose Verbose output 39 | -V, --veryverbose Very verbose output 40 | -h, --help Display this help and exit 41 | --version Output version information and exit 42 | " 43 | } 44 | 45 | ################################################################## 46 | ################################################################## 47 | # Begin Script Logic # 48 | ################################################################## 49 | ################################################################## 50 | 51 | source "$DIR/apps-common.sh" 52 | 53 | main() { 54 | #echo -n 55 | #set -x 56 | 57 | if [ -z "$args" ]; then 58 | err "Please specify an app id for which to set the permissions" 59 | else 60 | cmd="curl -sk -H \"${authheader}\" -X DELETE '$hosturl$args/pems/$pemusername?pretty=true'" 61 | 62 | if ((veryverbose)); then 63 | [ "$piped" -eq 0 ] && log "Calling $cmd" 64 | fi 65 | 66 | response=`curl -sk -H "${authheader}" -X DELETE "$hosturl$args/pems/$pemusername?pretty=true"` 67 | 68 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 69 | result=$(format_api_json "$response") 70 | success "$result" 71 | else 72 | errorresponse=$(jsonquery "$response" "message") 73 | err "$errorresponse" 74 | fi 75 | fi 76 | } 77 | 78 | format_api_json() { 79 | 80 | if ((veryverbose)); then 81 | echo "$1" 82 | elif [[ $verbose -eq 1 ]]; then 83 | result=$(jsonquery "$1" "result" 1) 84 | json_prettyify "${result}" 85 | else 86 | if [[ -z "$pemusername" ]]; then 87 | success "Successfully removed all share permissions on app $args" 88 | else 89 | success "Successfully removed permission for $pemusername on app $args" 90 | fi 91 | fi 92 | } 93 | 94 | ################################################################## 95 | ################################################################## 96 | # End Script Logic # 97 | ################################################################## 98 | ################################################################## 99 | 100 | # }}} 101 | 102 | # Parse command line options 103 | source "$DIR/options.sh" 104 | 105 | 106 | # Main loop {{{ 107 | 108 | # Print help if no arguments were passed. 109 | #[[ $# -eq 0 ]] && set -- "--help" 110 | 111 | # Read the options and set stuff 112 | while [[ $1 = -?* ]]; do 113 | case $1 in 114 | -h|--help) usage >&2; safe_exit ;; 115 | --version) version; copyright; disclaimer; safe_exit ;; 116 | -z|--access_token) shift; access_token=$1 ;; 117 | -u|--pemusername) shift; pemusername=$1 ;; 118 | -H|--hosturl) shift; hosturl=$1;; 119 | -d|--development) development=1 ;; 120 | -v|--verbose) verbose=1 ;; 121 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 122 | -q|--quiet) quiet=1 ;; 123 | -i|--interactive) interactive=1 ;; 124 | -f|--force) force=1 ;; 125 | --endopts) shift; break ;; 126 | *) die "invalid option: $1" ;; 127 | esac 128 | shift 129 | done 130 | 131 | # Store the remaining part as arguments. 132 | args+=("$@") 133 | 134 | # }}} 135 | 136 | # Run the script logic 137 | source "$DIR/runner.sh" 138 | -------------------------------------------------------------------------------- /bin/systems-delete: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # systems-delete 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It deletes a registered system. User must have admin privileges 9 | # on the system to perform this operation. Once deleted, the system 10 | # cannot be recovered and all registered applications on that system 11 | # will be disabled 12 | # 13 | 14 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 15 | 16 | source "$DIR/common.sh" 17 | 18 | # Script logic -- TOUCH THIS {{{ 19 | 20 | # A list of all variables to prompt in interactive mode. These variables HAVE 21 | # to be named exactly as the longname option definition in usage(). 22 | interactive_opts=(apisecret apikey) 23 | 24 | # Print usage 25 | usage() { 26 | echo -n "$(basename $0) [OPTION]... [SYSTEM_ID] 27 | 28 | Deletes a registered system. Deleting a system automatically disables all 29 | applications registered with the given system as either a storage or 30 | execution host. Actively running jobs may fail to archive their data if 31 | the archive system is deleted. File transfers may also fail if the transfer 32 | had not yet started when the system was deleted. 33 | 34 | Options: 35 | -z, --access_token Access token 36 | -H, --hosturl URL of the service 37 | -d, --development Run in dev mode using default dev server 38 | -f, --force Skip all user interaction 39 | -i, --interactive Prompt for values 40 | -q, --quiet Quiet (no output) 41 | -v, --verbose Verbose output 42 | -V, --veryverbose Very verbose output 43 | -h, --help Display this help and exit 44 | --version Output version information and exit 45 | " 46 | } 47 | 48 | ################################################################## 49 | ################################################################## 50 | # Begin Script Logic # 51 | ################################################################## 52 | ################################################################## 53 | 54 | source "$DIR/systems-common.sh" 55 | 56 | main() { 57 | #echo -n 58 | #set -x 59 | 60 | if [ -z "$args" ]; then 61 | err "Please specify a valid system id to delete" 62 | else 63 | 64 | cmd="curl -sk -H \"${authheader}\" -X DELETE '$hosturl$args?pretty=true'" 65 | 66 | if ((veryverbose)); then 67 | [ "$piped" -eq 0 ] && log "Calling $cmd" 68 | fi 69 | 70 | response=`curl -sk -H "${authheader}" -X DELETE "$hosturl$args?pretty=true"` 71 | 72 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 73 | result=$(format_api_json "$response") 74 | success "$result" 75 | else 76 | errorresponse=$(jsonquery "$response" "message") 77 | err "$errorresponse" 78 | fi 79 | fi 80 | } 81 | 82 | format_api_json() { 83 | 84 | jsonval storedtoken "${tokenstore}" "apikey" 85 | 86 | if ((veryverbose)); then 87 | echo "$1" 88 | elif [[ $verbose -eq 1 ]]; then 89 | result=$(jsonquery "$1" "result" 1) 90 | json_prettyify "${result}" 91 | else 92 | echo "Successfully deleted system $args" 93 | fi 94 | } 95 | 96 | ################################################################## 97 | ################################################################## 98 | # End Script Logic # 99 | ################################################################## 100 | ################################################################## 101 | 102 | # }}} 103 | 104 | # Parse command line options 105 | source "$DIR/options.sh" 106 | 107 | 108 | # Main loop {{{ 109 | 110 | # Print help if no arguments were passed. 111 | [[ $# -eq 0 ]] && set -- "-i" 112 | 113 | # Read the options and set stuff 114 | while [[ $1 = -?* ]]; do 115 | case $1 in 116 | -h|--help) usage >&2; safe_exit ;; 117 | --version) version; copyright; disclaimer; safe_exit ;; 118 | -z|--access_token) shift; access_token=$1 ;; 119 | -H|--hosturl) shift; hosturl=$1;; 120 | -d|--development) development=1 ;; 121 | -v|--verbose) verbose=1 ;; 122 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 123 | -q|--quiet) quiet=1 ;; 124 | -i|--interactive) interactive=1 ;; 125 | -f|--force) force=1 ;; 126 | --endopts) shift; break ;; 127 | *) die "invalid option: $1" ;; 128 | esac 129 | shift 130 | done 131 | 132 | # Store the remaining part as arguments. 133 | args+=("$@") 134 | 135 | # }}} 136 | 137 | # Run the script logic 138 | source "$DIR/runner.sh" 139 | -------------------------------------------------------------------------------- /bin/files-delete: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # files-get 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # Deletes a file or folder from a remote system. 9 | # 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | source "$DIR/common.sh" 14 | 15 | # Script logic -- TOUCH THIS {{{ 16 | 17 | # A list of all variables to prompt in interactive mode. These variables HAVE 18 | # to be named exactly as the longname option definition in usage(). 19 | interactive_opts=(apisecret apikey) 20 | 21 | # Print usage 22 | usage() { 23 | echo -n "$(basename $0) [OPTION]... [PATH] 24 | 25 | Deletes a remote file or folder. If no system is specified, your default storage 26 | system will be used. By specifying a system, the path given will be resolved on 27 | that remote system. Note that the system id, not hostname must be given. 28 | 29 | Options: 30 | -z, --access_token Access token 31 | -S, --systemId Specify the system id 32 | -P, --print Print contents to stdout 33 | -H, --hosturl URL of the service 34 | -d, --development Run in dev mode using default dev server 35 | -f, --force Skip all user interaction 36 | -i, --interactive Prompt for values 37 | -q, --quiet Quiet (no output) 38 | -v, --verbose Verbose output 39 | -V, --veryverbose Very verbose output 40 | -h, --help Display this help and exit 41 | --version Output version information and exit 42 | " 43 | } 44 | 45 | ################################################################## 46 | ################################################################## 47 | # Begin Script Logic # 48 | ################################################################## 49 | ################################################################## 50 | 51 | source "$DIR/files-common.sh" 52 | 53 | main() { 54 | #echo -n 55 | #set -x 56 | 57 | if [ -z "$args" ]; then 58 | err "Please specify a valid file path to download. Directory downloads are not yet supported." 59 | else 60 | 61 | if [ -n "$systemId" ]; then 62 | filesurl="${hosturl}media/system/${systemId}/${args}?pretty=true" 63 | else 64 | filesurl="${hosturl}media/${args}?pretty=true" 65 | fi 66 | 67 | cmd="curl -sk -H \"${authheader}\" -X DELETE '${filesurl}'" 68 | 69 | if ((veryverbose)); then 70 | [ "$piped" -eq 0 ] && log "Calling $cmd" 71 | fi 72 | 73 | response=`curl -sk -H "${authheader}" -X DELETE "${filesurl}"` 74 | 75 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 76 | result=$(format_api_json "$response") 77 | success "$result" 78 | else 79 | errorresponse=$(jsonquery "$response" "message") 80 | err "$errorresponse" 81 | fi 82 | 83 | fi 84 | } 85 | 86 | format_api_json() { 87 | 88 | if ((veryverbose)); then 89 | echo "$1" 90 | elif [[ $verbose -eq 1 ]]; then 91 | result=$(jsonquery "$1" "result" 1) 92 | json_prettyify "${result}" 93 | else 94 | echo "Successfully deleted ${args}" 95 | fi 96 | } 97 | 98 | ################################################################## 99 | ################################################################## 100 | # End Script Logic # 101 | ################################################################## 102 | ################################################################## 103 | 104 | # }}} 105 | 106 | # Parse command line options 107 | source "$DIR/options.sh" 108 | 109 | # Main loop {{{ 110 | 111 | # Print help if no arguments were passed. 112 | #[[ $# -eq 0 ]] && set -- "--help" 113 | 114 | # Read the options and set stuff 115 | while [[ $1 = -?* ]]; do 116 | case $1 in 117 | -h|--help) usage >&2; safe_exit ;; 118 | --version) version; copyright; disclaimer; safe_exit ;; 119 | -z|--access_token) shift; access_token=$1 ;; 120 | -S|--systemId) shift; systemId=$1 ;; 121 | -P|--print) print=$1 ;; 122 | -H|--hosturl) shift; hosturl=$1;; 123 | -d|--development) development=1 ;; 124 | -v|--verbose) verbose=1 ;; 125 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 126 | -q|--quiet) quiet=1 ;; 127 | -i|--interactive) interactive=1 ;; 128 | -f|--force) force=1 ;; 129 | --endopts) shift; break ;; 130 | *) die "invalid option: $1" ;; 131 | esac 132 | shift 133 | done 134 | 135 | # Store the remaining part as arguments. 136 | args+=("$@") 137 | 138 | # }}} 139 | 140 | # Run the script logic 141 | source "$DIR/runner.sh" 142 | -------------------------------------------------------------------------------- /bin/systems-clone: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # systems-clone 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It creates a copy of an existing system private to the authenticated user. 9 | # Authentication settings, apps, and roles are not transferred. 10 | # 11 | 12 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 13 | 14 | source "$DIR/common.sh" 15 | 16 | # Script logic -- TOUCH THIS {{{ 17 | 18 | # A list of all variables to prompt in interactive mode. These variables HAVE 19 | # to be named exactly as the longname option definition in usage(). 20 | interactive_opts=(apisecret apikey id) 21 | 22 | # Print usage 23 | usage() { 24 | echo -n "$(basename $0) [OPTION]... [SYSTEM_ID] 25 | 26 | Creates a copy of an existing system private to the authenticated user. 27 | Authentication settings, apps, and roles are not transferred. 28 | 29 | Options: 30 | -z, --access_token Access token 31 | -I, --id System id of new system 32 | --filter Comma separated list of fields to return in the response 33 | -H, --hosturl URL of the service 34 | -d, --development Run in dev mode using default dev server 35 | -f, --force Skip all user interaction 36 | -i, --interactive Prompt for values 37 | -q, --quiet Quiet (no output) 38 | -v, --verbose Verbose output 39 | -V, --veryverbose Very verbose output 40 | -h, --help Display this help and exit 41 | --version Output version information and exit 42 | " 43 | } 44 | 45 | ################################################################## 46 | ################################################################## 47 | # Begin Script Logic # 48 | ################################################################## 49 | ################################################################## 50 | 51 | source "$DIR/systems-common.sh" 52 | 53 | main() { 54 | #echo -n 55 | #set -x 56 | 57 | if [ -z "$args" ]; then 58 | err "Please specify a valid system id to clone" 59 | else 60 | 61 | if [ -n "$id" ]; then 62 | new_system_id="&id=$id" 63 | fi 64 | 65 | cmd="curl -sk -H \"${authheader}\" -X PUT -d \"action=clone$new_system_id\" '$hosturl$args?pretty=true'" 66 | 67 | if ((veryverbose)); then 68 | [ "$piped" -eq 0 ] && log "Calling $cmd" 69 | fi 70 | 71 | response=`curl -sk -H "${authheader}" -X PUT -d "action=clone$new_system_id" "$hosturl$args?pretty=true"` 72 | 73 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 74 | result=$(format_api_json "$response") 75 | success "$result" 76 | else 77 | errorresponse=$(jsonquery "$response" "message") 78 | err "$errorresponse" 79 | fi 80 | fi 81 | } 82 | 83 | format_api_json() { 84 | 85 | if ((veryverbose)); then 86 | echo "$1" 87 | elif [[ $verbose -eq 1 ]]; then 88 | result=$(jsonquery "$1" "result" 1) 89 | json_prettyify "${result}" 90 | else 91 | system_id=$(jsonquery "$1" "result.id") 92 | success "Successfully cloned system $args to $system_id" 93 | fi 94 | } 95 | 96 | ################################################################## 97 | ################################################################## 98 | # End Script Logic # 99 | ################################################################## 100 | ################################################################## 101 | 102 | # }}} 103 | 104 | # Parse command line options 105 | source "$DIR/options.sh" 106 | 107 | 108 | # Print help if no arguments were passed. 109 | [[ $# -eq 0 ]] && set -- "-i" 110 | 111 | # Read the options and set stuff 112 | while [[ $1 = -?* ]]; do 113 | case $1 in 114 | -h|--help) usage >&2; safe_exit ;; 115 | --version) version; copyright; disclaimer; safe_exit ;; 116 | -z|--access_token) shift; access_token=$1 ;; 117 | -I|--id) shift; id=$1 ;; 118 | --filter) shift; responsefilter=$1;; 119 | -H|--hosturl) shift; hosturl=$1 ;; 120 | -d|--development) development=1 ;; 121 | -v|--verbose) verbose=1 ;; 122 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 123 | -q|--quiet) quiet=1 ;; 124 | -i|--interactive) interactive=1 ;; 125 | -f|--force) force=1 ;; 126 | --endopts) shift; break ;; 127 | *) die "invalid option: $1" ;; 128 | esac 129 | shift 130 | done 131 | 132 | # Store the remaining part as arguments. 133 | args+=("$@") 134 | 135 | # }}} 136 | 137 | # Run the script logic 138 | source "$DIR/runner.sh" 139 | -------------------------------------------------------------------------------- /bin/transforms-list: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # transforms-list 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It retrieves a list of one or more registered trasforms from the api 9 | # 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | source "$DIR/common.sh" 14 | 15 | # Script logic -- TOUCH THIS {{{ 16 | 17 | # A list of all variables to prompt in interactive mode. These variables HAVE 18 | # to be named exactly as the longname option definition in usage(). 19 | interactive_opts=(apisecret apikey) 20 | 21 | # Print usage 22 | usage() { 23 | echo -n "$(basename $0) [OPTION]... 24 | $(basename $0) [OPTION]... [TRANSFORM_ID] 25 | 26 | List all transforms available to the authenticated user. 27 | 28 | Options: 29 | -z, --access_token Access token 30 | -l, --limit Maximum number of results to return 31 | -o, --offset Number of results to skip from the start 32 | --filter Comma separated list of fields to return in the response 33 | -H, --hosturl URL of the service 34 | -d, --development Run in dev mode using default dev server 35 | -f, --force Skip all user interaction 36 | -i, --interactive Prompt for values 37 | -q, --quiet Quiet (no output) 38 | -v, --verbose Verbose output 39 | -V, --veryverbose Very verbose output 40 | -h, --help Display this help and exit 41 | --version Output version information and exit 42 | " 43 | } 44 | 45 | ################################################################## 46 | ################################################################## 47 | # Begin Script Logic # 48 | ################################################################## 49 | ################################################################## 50 | 51 | source "$DIR/transforms-common.sh" 52 | 53 | main() { 54 | #echo -n 55 | #set -x 56 | 57 | hosturl=${hosturl%/} 58 | if [ -n "$args" ]; then 59 | transformsurl="${hosturl}/${args}" 60 | else 61 | transformsurl="$hosturl" 62 | fi 63 | 64 | cmd="curl -sk -H \"${authheader}\" '${transformsurl}?pretty=true$(pagination)'" 65 | 66 | if ((veryverbose)); then 67 | [ "$piped" -eq 0 ] && log "Calling $cmd" 68 | fi 69 | 70 | response=`curl -sk -H "${authheader}" "${transformsurl}?pretty=true$(pagination)"` 71 | 72 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 73 | result=$(format_api_json "$response") 74 | success "$result" 75 | else 76 | errorresponse=$(jsonquery "$response" "message") 77 | err "$errorresponse" 78 | fi 79 | } 80 | 81 | format_api_json() { 82 | 83 | if ((veryverbose)); then 84 | echo "$1" 85 | elif [[ $verbose -eq 1 ]]; then 86 | result=$(jsonquery "$1" "result" 1) 87 | json_prettyify "${result}" 88 | elif [ -n "$args" ]; then 89 | result=$(jsonquery "$1" "result.name") 90 | echo "${result}" 91 | else 92 | result=$(jsonquery "$1" "result.[].name") 93 | echo "${result}" 94 | fi 95 | } 96 | 97 | ################################################################## 98 | ################################################################## 99 | # End Script Logic # 100 | ################################################################## 101 | ################################################################## 102 | 103 | # }}} 104 | 105 | # Parse command line options 106 | source "$DIR/options.sh" 107 | 108 | 109 | # Main loop {{{ 110 | 111 | # Print help if no arguments were passed. 112 | #[[ $# -eq 0 ]] && set -- "--help" 113 | 114 | # Read the options and set stuff 115 | while [[ $1 = -?* ]]; do 116 | case $1 in 117 | -h|--help) usage >&2; safe_exit ;; 118 | --version) version; copyright; disclaimer; safe_exit ;; 119 | -z|--access_token) shift; access_token=$1 ;; 120 | -l|--limit) shift; limit=$1;; 121 | -o|--offset) shift; offset=$1;; 122 | --filter) shift; responsefilter=$1 ;; 123 | -H|--hosturl) shift; hosturl=$1;; 124 | -d|--development) development=1 ;; 125 | -v|--verbose) verbose=1 ;; 126 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 127 | -q|--quiet) quiet=1 ;; 128 | -i|--interactive) interactive=1 ;; 129 | -f|--force) force=1 ;; 130 | --endopts) shift; break ;; 131 | *) die "invalid option: $1" ;; 132 | esac 133 | shift 134 | done 135 | 136 | # Store the remaining part as arguments. 137 | args+=("$@") 138 | 139 | # }}} 140 | 141 | # Run the script logic 142 | source "$DIR/runner.sh" 143 | -------------------------------------------------------------------------------- /bin/headers-check: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # auth-headers-inspect 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # Prints the JWT that would be passed to a protected API by the Agave 9 | # auth server when presented the current auth token. 10 | # 11 | 12 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 13 | 14 | source "$DIR/common.sh" 15 | 16 | # Script logic -- TOUCH THIS {{{ 17 | 18 | # A list of all variables to prompt in interactive mode. These variables HAVE 19 | # to be named exactly as the longname option definition in usage(). 20 | interactive_opts=(access_token filetoupload) 21 | 22 | # Print usage 23 | usage() { 24 | echo -n "$(basename $0) [OPTION]... 25 | 26 | Prints the headers that would be passed to a protected API by the Agave auth server 27 | when presented the current auth token. 28 | 29 | Options: 30 | -z, --access_token Access token 31 | --filter Comma separated list of fields to return in the response 32 | -H, --hosturl URL of the service 33 | -d, --development Run in dev mode using default dev server 34 | -f, --force Skip all user interaction 35 | -i, --interactive Prompt for values 36 | -q, --quiet Quiet (no output) 37 | -v, --verbose Verbose output 38 | -V, --veryverbose Very verbose output 39 | -h, --help Display this help and exit 40 | --version Output version information and exit 41 | " 42 | } 43 | 44 | ################################################################## 45 | ################################################################## 46 | # Begin Script Logic # 47 | ################################################################## 48 | ################################################################## 49 | 50 | source "$DIR/headers-common.sh" 51 | 52 | main() { 53 | 54 | if (( debug )); then 55 | response="Cannot verify jwt in devel mode" 56 | err "$response" 57 | 58 | else 59 | 60 | cmd="curl -sk -H \"${authheader}\" '${hosturl%%/}" 61 | 62 | if ((veryverbose)); then 63 | [ "$piped" -eq 0 ] && log "Calling $cmd" 64 | fi 65 | 66 | # make sure we specify content type as application/json 67 | response=`curl -sk -H "${authheader}" "${hosturl%%/}"` 68 | 69 | fi 70 | 71 | if [[ -n "$response" ]]; then 72 | result=$(format_api_json "$response") 73 | success "$result" 74 | else 75 | err "$response" 76 | fi 77 | 78 | } 79 | 80 | format_api_json() { 81 | 82 | if ((veryverbose)); then 83 | echo "$1" 84 | elif [[ $verbose -eq 1 ]]; then 85 | result=$(jsonquery "$1" "headers" 1) 86 | json_prettyify "${result}" 87 | else 88 | # decode the jwt from the response header 89 | jwt=$(echo "$1" | grep "X-Jwt-Assertion-" | sed 's/"//g' | sed 's/^.*\://g' | sed 's/ //g' | sed -E 's#^.+\.(.+)\..+#\1#' | base64 -D -i - -o - ) 90 | 91 | json_prettyify "${jwt}" 92 | 93 | fi 94 | } 95 | 96 | ################################################################## 97 | ################################################################## 98 | # End Script Logic # 99 | ################################################################## 100 | ################################################################## 101 | 102 | # }}} 103 | 104 | # Parse command line options 105 | source "$DIR/options.sh" 106 | 107 | 108 | # Main loop {{{ 109 | 110 | # Print help if no arguments were passed. 111 | [[ $# -eq 0 ]] && set -- "-i" 112 | 113 | # Read the options and set stuff 114 | while [[ $1 = -?* ]]; do 115 | case $1 in 116 | -h|--help) usage >&2; safe_exit ;; 117 | --version) version; copyright; disclaimer; safe_exit ;; 118 | -z|--access_token) shift; access_token=$1 ;; 119 | --filter) shift; responsefilter=$1;; 120 | -H|--hosturl) shift; hosturl=$1 ;; 121 | -d|--development) development=1 ;; 122 | -v|--verbose) verbose=1 ;; 123 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 124 | -q|--quiet) quiet=1 ;; 125 | -i|--interactive) interactive=1 ;; 126 | -f|--force) force=1 ;; 127 | --endopts) shift; break ;; 128 | *) die "invalid option: $1" ;; 129 | esac 130 | shift 131 | done 132 | 133 | # Store the remaining part as arguments. 134 | args+=("$@") 135 | 136 | # }}} 137 | 138 | # Run the script logic 139 | source "$DIR/runner.sh" 140 | -------------------------------------------------------------------------------- /bin/files-mkdir: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # files-mkdir 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It creates a new folder on a remote system. 9 | # 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | source "$DIR/common.sh" 14 | 15 | # Script logic -- TOUCH THIS {{{ 16 | 17 | # A list of all variables to prompt in interactive mode. These variables HAVE 18 | # to be named exactly as the longname option definition in usage(). 19 | interactive_opts=(apisecret apikey, name) 20 | 21 | # Print usage 22 | usage() { 23 | echo -n "$(basename $0) [OPTION]... [PATH] 24 | 25 | Create a folder on a remote system. If no system is specified, your default storage 26 | system will be used. By specifying a system, the path given will be resolved 27 | on that remote system. Note that the system id, not hostname must be given. 28 | 29 | Options: 30 | -z, --access_token Access token 31 | -S, --systemId Specify the system id 32 | -N, --name Name of the new folder 33 | --filter Comma separated list of fields to return in the response 34 | -H, --hosturl URL of the service 35 | -d, --development Run in dev mode using default dev server 36 | -f, --force Skip all user interaction 37 | -i, --interactive Prompt for values 38 | -q, --quiet Quiet (no output) 39 | -v, --verbose Verbose output 40 | -V, --veryverbose Very verbose output 41 | -h, --help Display this help and exit 42 | --version Output version information and exit 43 | " 44 | } 45 | 46 | ################################################################## 47 | ################################################################## 48 | # Begin Script Logic # 49 | ################################################################## 50 | ################################################################## 51 | 52 | source "$DIR/files-common.sh" 53 | 54 | main() { 55 | #echo -n 56 | #set -x 57 | 58 | if [ -n "$systemId" ]; then 59 | hosturl="${hosturl}media/system/${systemId}/" 60 | else 61 | hosturl="${hosturl}media/" 62 | fi 63 | 64 | cmd="curl -sk -H \"${authheader}\" -X PUT -d \"action=mkdir&path=${name}\" '${hosturl}${args}?pretty=true'" 65 | 66 | if ((veryverbose)); then 67 | [ "$piped" -eq 0 ] && log "Calling $cmd" 68 | fi 69 | 70 | response=`curl -sk -H "${authheader}" -X PUT -d "action=mkdir&path=${name}" "${hosturl}${args}?pretty=true"` 71 | 72 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 73 | result=$(format_api_json "$response") 74 | success "$result" 75 | else 76 | errorresponse=$(jsonquery "$response" "message") 77 | err "$errorresponse" 78 | fi 79 | } 80 | 81 | format_api_json() { 82 | 83 | if ((veryverbose)); then 84 | echo "$1" 85 | elif [[ $verbose -eq 1 ]]; then 86 | result=$(jsonquery "$1" "result" 1) 87 | json_prettyify "${result}" 88 | else 89 | newfolder=${path%/}${name} 90 | echo "Successfully created folder ${newfolder}" 91 | fi 92 | } 93 | 94 | ################################################################## 95 | ################################################################## 96 | # End Script Logic # 97 | ################################################################## 98 | ################################################################## 99 | 100 | # }}} 101 | 102 | # Parse command line options 103 | source "$DIR/options.sh" 104 | 105 | # Main loop {{{ 106 | 107 | # Print help if no arguments were passed. 108 | #[[ $# -eq 0 ]] && set -- "--help" 109 | 110 | # Read the options and set stuff 111 | while [[ $1 = -?* ]]; do 112 | case $1 in 113 | -h|--help) usage >&2; safe_exit ;; 114 | --version) version; copyright; disclaimer; safe_exit ;; 115 | -z|--access_token) shift; access_token=$1 ;; 116 | -S|--systemId) shift; systemId=$1 ;; 117 | -N|--name) shift; name=$1 ;; 118 | --filter) shift; responsefilter=$1 ;; 119 | -H|--hosturl) shift; hosturl=$1;; 120 | -d|--development) development=1 ;; 121 | -v|--verbose) verbose=1 ;; 122 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 123 | -q|--quiet) quiet=1 ;; 124 | -i|--interactive) interactive=1 ;; 125 | -f|--force) force=1 ;; 126 | --endopts) shift; break ;; 127 | *) die "invalid option: $1" ;; 128 | esac 129 | shift 130 | done 131 | 132 | # Store the remaining part as arguments. 133 | args+=("$@") 134 | 135 | # }}} 136 | 137 | # Run the script logic 138 | source "$DIR/runner.sh" 139 | -------------------------------------------------------------------------------- /bin/jobs-pems-update: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # jobs-pems-update 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It provides a mechanism for managing user permissions on a job. 9 | # 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | source "$DIR/common.sh" 14 | 15 | # Script logic -- TOUCH THIS {{{ 16 | 17 | # A list of all variables to prompt in interactive mode. These variables HAVE 18 | # to be named exactly as the longname option definition in usage(). 19 | interactive_opts=(apisecret apikey username permission) 20 | 21 | # Print usage 22 | usage() { 23 | echo -n "$(basename $0) [OPTION]... [JOB_ID] 24 | 25 | Update user permissions for a particular job. This will impact who can view the 26 | status, modify, or download output of a job. Valid permissions are READ, WRITE, 27 | and EXECUTE. 28 | 29 | Options: 30 | -z, --access_token Access token 31 | -u, --apiusername The user whose permissions should be set 32 | -p, --permission The permission to set. Valid values are READ, 33 | WRITE, READ_WRITE, ALL, and NONE 34 | --filter Comma separated list of fields to return in the response 35 | -H, --hosturl URL of the service 36 | -d, --development Run in dev mode using default dev server 37 | -f, --force Skip all user interaction 38 | -i, --interactive Prompt for values 39 | -q, --quiet Quiet (no output) 40 | -v, --verbose Verbose output 41 | -V, --veryverbose Very verbose output 42 | -h, --help Display this help and exit 43 | --version Output version information and exit 44 | " 45 | } 46 | 47 | ################################################################## 48 | ################################################################## 49 | # Begin Script Logic # 50 | ################################################################## 51 | ################################################################## 52 | 53 | source "$DIR/jobs-common.sh" 54 | 55 | main() { 56 | #echo -n 57 | #set -x 58 | 59 | if [ -z "$args" ]; then 60 | err "Please specify a job for which to set the permissions" 61 | else 62 | cmd="curl -sk -H \"${authheader}\" -X POST -d \"permission=$permission\" '$hosturl$args/pems/$apiusername?pretty=true'" 63 | 64 | if ((veryverbose)); then 65 | [ "$piped" -eq 0 ] && log "Calling $cmd" 66 | fi 67 | 68 | response=`curl -sk -H "${authheader}" -X POST -d "permission=$permission" "$hosturl$args/pems/$apiusername?pretty=true"` 69 | 70 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 71 | result=$(format_api_json "$response") 72 | success "$result" 73 | else 74 | errorresponse=$(jsonquery "$response" "message") 75 | err "$errorresponse" 76 | fi 77 | fi 78 | } 79 | 80 | format_api_json() { 81 | 82 | if ((veryverbose)); then 83 | echo "$1" 84 | elif [[ $verbose -eq 1 ]]; then 85 | result=$(jsonquery "$1" "result" 1) 86 | json_prettyify "${result}" 87 | else 88 | echo "Successfully updated permission for $apiusername" 89 | fi 90 | } 91 | 92 | ################################################################## 93 | ################################################################## 94 | # End Script Logic # 95 | ################################################################## 96 | ################################################################## 97 | 98 | # }}} 99 | 100 | # Parse command line options 101 | source "$DIR/options.sh" 102 | 103 | 104 | # Main loop {{{ 105 | 106 | # Print help if no arguments were passed. 107 | #[[ $# -eq 0 ]] && set -- "--help" 108 | 109 | # Read the options and set stuff 110 | while [[ $1 = -?* ]]; do 111 | case $1 in 112 | -h|--help) usage >&2; safe_exit ;; 113 | --version) version; copyright; disclaimer; safe_exit ;; 114 | -z|--access_token) shift; access_token=$1 ;; 115 | -u|--apiusername) shift; apiusername=$1 ;; 116 | -p|--permission) shift; permission=$1 ;; 117 | --filter) shift; responsefilter=$1 ;; 118 | -H|--hosturl) shift; hosturl=$1;; 119 | -d|--development) development=1 ;; 120 | -v|--verbose) verbose=1 ;; 121 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 122 | -q|--quiet) quiet=1 ;; 123 | -i|--interactive) interactive=1 ;; 124 | -f|--force) force=1 ;; 125 | --endopts) shift; break ;; 126 | *) die "invalid option: $1" ;; 127 | esac 128 | shift 129 | done 130 | 131 | # Store the remaining part as arguments. 132 | args+=("$@") 133 | 134 | # }}} 135 | 136 | # Run the script logic 137 | source "$DIR/runner.sh" 138 | -------------------------------------------------------------------------------- /bin/auth-check: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # auth-check 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It checks the current auth status 9 | # 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | source "$DIR/common.sh" 14 | 15 | # Script logic -- TOUCH THIS {{{ 16 | 17 | # A list of all variables to prompt in interactive mode. These variables HAVE 18 | # to be named exactly as the longname option definition in usage(). 19 | interactive_opts=() 20 | 21 | # Print usage 22 | usage() { 23 | echo -n "$(basename $0) [OPTION]... 24 | 25 | Check the status of the current Oauth bearer token. If the token is expired, 26 | you can simply do an auth-tokens-refresh with your API username and password 27 | to refresh your token. 28 | 29 | Options: 30 | -d, --development Run in dev mode using default dev server 31 | -f, --force Skip all user interaction 32 | -i, --interactive Prompt for values 33 | -q, --quiet Quiet (no output) 34 | -v, --verbose Verbose output 35 | -V, --veryverbose Very verbose output 36 | -h, --help Display this help and exit 37 | --version Output version information and exit 38 | " 39 | } 40 | 41 | ################################################################## 42 | ################################################################## 43 | # Begin Script Logic # 44 | ################################################################## 45 | ################################################################## 46 | 47 | source "$DIR/auth-common.sh" 48 | 49 | main() { 50 | #echo -n 51 | #set -x 52 | currentcache=$(kvget current) 53 | 54 | if ((veryverbose)); then 55 | out "Reading authentication cache at $AGAVE_CACHE_DIR/current" 56 | fi 57 | 58 | #access_token=$(jsonquery "${currentcache}" "access_token") 59 | jsonval access_token "$current_cache" "access_token" 60 | 61 | time_left=$(get_token_remaining_time) 62 | 63 | if [ "$time_left" -le "0" ]; then 64 | response="{\"status\":\"error\",\"message\":\"Current token is expired\",\"result\":${currentcache}}" 65 | response=`json_prettyify "${response}"` 66 | else 67 | response="{\"status\":\"success\",\"message\":\"Cache is valid for $time_left seconds\",\"result\":${currentcache}}" 68 | response=`json_prettyify "${response}"` 69 | fi 70 | 71 | format_api_json "${response}" 72 | } 73 | 74 | format_api_json() { 75 | 76 | if ((veryverbose)); then 77 | echo "$1" 78 | elif [[ $verbose -eq 1 ]]; then 79 | result=$(jsonquery "$1" "result" 1) 80 | json_prettyify "${result}" 81 | else 82 | if [ "$time_left" -le "0" ]; then 83 | err $(jsonquery "$response" "message") 84 | success "tenant: $(jsonquery "$1" "result.tenantid")" 85 | success "username: $(jsonquery "$1" "result.username")" 86 | success "time left: 0 seconds" 87 | success "expired at: $(jsonquery "$1" "result.expires_at")" 88 | else 89 | success "tenant: $(jsonquery "$1" "result.tenantid")" 90 | success "username: $(jsonquery "$1" "result.username")" 91 | success "time left: $time_left seconds" 92 | success "expires at: $(jsonquery "$1" "result.expires_at")" 93 | fi 94 | fi 95 | } 96 | 97 | ################################################################## 98 | ################################################################## 99 | # End Script Logic # 100 | ################################################################## 101 | ################################################################## 102 | 103 | # }}} 104 | 105 | # Parse command line options 106 | source "$DIR/options.sh" 107 | 108 | 109 | # Main loop {{{ 110 | 111 | # Print help if no arguments were passed. 112 | [[ $# -eq 0 ]] && set -- "-i" 113 | 114 | # Read the options and set stuff 115 | while [[ $1 = -?* ]]; do 116 | case $1 in 117 | -h|--help) usage >&2; safe_exit ;; 118 | --version) version; copyright; disclaimer; safe_exit ;; 119 | -u|--current_username) current_username=1;; 120 | -z|--current_access_token) current_access_token=1;; 121 | -d|--development) development=1 ;; 122 | -v|--verbose) verbose=1 ;; 123 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 124 | -q|--quiet) quiet=1 ;; 125 | -i|--interactive) interactive=1 ;; 126 | -f|--force) force=1 ;; 127 | --endopts) shift; break ;; 128 | *) die "invalid option: $1" ;; 129 | esac 130 | shift 131 | done 132 | 133 | # Store the remaining part as arguments. 134 | args+=("$@") 135 | 136 | # }}} 137 | 138 | # Run the script logic 139 | source "$DIR/runner.sh" 140 | -------------------------------------------------------------------------------- /bin/files-rename: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # files-rename 4 | # 5 | # author: dooley@tacc.utexas.edu 6 | # 7 | # This script is part of the Agave API command line interface (CLI). 8 | # It renames a file or folder on a remote system. 9 | # 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 12 | 13 | source "$DIR/common.sh" 14 | 15 | # Script logic -- TOUCH THIS {{{ 16 | 17 | # A list of all variables to prompt in interactive mode. These variables HAVE 18 | # to be named exactly as the longname option definition in usage(). 19 | interactive_opts=(apisecret apikey, name) 20 | 21 | # Print usage 22 | usage() { 23 | echo -n "$(basename $0) [OPTION]... [PATH] 24 | 25 | Renames a file or folder on a remote system. If no system is specified, your 26 | default storage system will be used. By specifying a system, the path given 27 | will be resolved on that remote system. Note that the system id, not hostname 28 | must be given. 29 | 30 | Options: 31 | -z, --access_token Access token 32 | -S, --systemId Specify the system id 33 | -N, --name Name of the new file or folder 34 | --filter Comma separated list of fields to return in the response 35 | -H, --hosturl URL of the service 36 | -d, --development Run in dev mode using default dev server 37 | -f, --force Skip all user interaction 38 | -i, --interactive Prompt for values 39 | -q, --quiet Quiet (no output) 40 | -v, --verbose Verbose output 41 | -V, --veryverbose Very verbose output 42 | -h, --help Display this help and exit 43 | --version Output version information and exit 44 | " 45 | } 46 | 47 | ################################################################## 48 | ################################################################## 49 | # Begin Script Logic # 50 | ################################################################## 51 | ################################################################## 52 | 53 | source "$DIR/files-common.sh" 54 | 55 | main() { 56 | #echo -n 57 | #set -x 58 | 59 | if [ -z "$args" ]; then 60 | err "Please specify a valid path to rename" 61 | else 62 | if [ -n "$systemId" ]; then 63 | hosturl="${hosturl}media/system/${systemId}/" 64 | else 65 | hosturl="${hosturl}media/" 66 | fi 67 | 68 | cmd="curl -sk -H \"${authheader}\" -X PUT -d \"action=rename&path=${name}\" '$hosturl${args}?pretty=true'" 69 | 70 | if ((veryverbose)); then 71 | [ "$piped" -eq 0 ] && log "Calling $cmd" 72 | fi 73 | 74 | response=`curl -sk -H "${authheader}" -X PUT -d "action=rename&path=${name}" "${hosturl}${args}?pretty=true"` 75 | 76 | if [[ $(jsonquery "$response" "status") = 'success' ]]; then 77 | result=$(format_api_json "$response") 78 | success "$result" 79 | else 80 | errorresponse=$(jsonquery "$response" "message") 81 | err "$errorresponse" 82 | fi 83 | fi 84 | 85 | } 86 | 87 | format_api_json() { 88 | 89 | if ((veryverbose)); then 90 | echo "$1" 91 | elif [[ $verbose -eq 1 ]]; then 92 | result=$(jsonquery "$1" "result" 1) 93 | json_prettyify "${result}" 94 | else 95 | success "Successfully renamed ${args}" 96 | fi 97 | } 98 | 99 | ################################################################## 100 | ################################################################## 101 | # End Script Logic # 102 | ################################################################## 103 | ################################################################## 104 | 105 | # }}} 106 | 107 | # Parse command line options 108 | source "$DIR/options.sh" 109 | 110 | # Main loop {{{ 111 | 112 | # Print help if no arguments were passed. 113 | #[[ $# -eq 0 ]] && set -- "--help" 114 | 115 | # Read the options and set stuff 116 | while [[ $1 = -?* ]]; do 117 | case $1 in 118 | -h|--help) usage >&2; safe_exit ;; 119 | --version) version; copyright; disclaimer; safe_exit ;; 120 | -z|--access_token) shift; access_token=$1 ;; 121 | -S|--systemId) shift; systemId=$1 ;; 122 | -N|--name) shift; name=$1 ;; 123 | --filter) shift; responsefilter=$1 ;; 124 | -H|--hosturl) shift; hosturl=$1;; 125 | -d|--development) development=1 ;; 126 | -v|--verbose) verbose=1 ;; 127 | -V|--veryverbose) veryverbose=1; verbose=1 ;; 128 | -q|--quiet) quiet=1 ;; 129 | -i|--interactive) interactive=1 ;; 130 | -f|--force) force=1 ;; 131 | --endopts) shift; break ;; 132 | *) die "invalid option: $1" ;; 133 | esac 134 | shift 135 | done 136 | 137 | # Store the remaining part as arguments. 138 | args+=("$@") 139 | 140 | # }}} 141 | 142 | # Run the script logic 143 | source "$DIR/runner.sh" 144 | --------------------------------------------------------------------------------