diff --git a/utils/assign-role.sh b/utils/assign-role.sh new file mode 100644 index 0000000000000000000000000000000000000000..6988f3b975fe359862fcceb6e7937dd7ae9d7daa --- /dev/null +++ b/utils/assign-role.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +USERNAME=$1 +ROLE=$2 +SERVER=$3 +PORT=$4 + +if [[ $USERNAME == "" ]] || [[ $ROLE == "" ]]; then + echo "Please specify username and role" + exit 1 +fi +if [[ $SERVER == "" ]]; then + SERVER=localhost +fi +if [[ $PORT == "" ]]; then + PORT=5000 +fi + +echo "Assigning role $ROLE to User $USERNAME" +curl --header "Content-Type: application/json" \ + --request POST \ + --data "{\"query\": \"mutation {addRoleToUser(username: \\\"$USERNAME\\\", role: \\\"$ROLE\\\"){user{username, roles{edges{node{name}}}}}}\" }" \ + http://$SERVER:$PORT/graphql diff --git a/utils/create-role.sh b/utils/create-role.sh new file mode 100644 index 0000000000000000000000000000000000000000..77aa4d09c7ddecd010144d94213532622e106546 --- /dev/null +++ b/utils/create-role.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +ROLE=$1 +SERVER=$2 +PORT=$3 + +if [[ $ROLE == "" ]]; then + echo "Please specify a role name" + exit 1 +fi +if [[ $SERVER == "" ]]; then + SERVER=localhost +fi +if [[ $PORT == "" ]]; then + PORT=5000 +fi + +echo "Creating role $ROLE" +curl --header "Content-Type: application/json" \ + --request POST \ + --data "{\"query\": \"mutation {createRole(name: \\\"$ROLE\\\"){role{name}}}\" }" \ + http://$SERVER:$PORT/graphql