clemmy/api.sh

7 lines
521 B
Bash
Raw Normal View History

baseurl(){ if [ -z $INSEC ]; then sec=s; fi; echo "http$sec://$INSTANCE/api/v3/"; } # This needs to be a function so updates to INSTANCE affect it. This is a very old bug lmao
2023-01-17 01:07:40 +11:00
#Generics
get(){ curl -sH "Cookie:jwt=$TOKE" "$(baseurl)$1?${*:3}" | jq "${2:-.}"; }
post(){ curl -sH "Cookie:jwt=$TOKE" "$(baseurl)$1" --json "${*:2}"; }
2023-01-17 01:07:40 +11:00
# I'm just gonna clone this thing rather than try to palm the -X PUT into post. I can fix it later.
2023-07-02 19:28:33 +10:00
put(){ curl -sX PUT "$(baseurl)$1" --json "$(echo ${*:2} | jq '.+{"auth":"'$TOKE'"}')"; }