Create a new Remote Worker Group from BASH

Pliant has an extensive API (See https://your.instance/api for your Pliant API Swagger) that allows much of the same functions that can be performed via the UI.

The following steps illustrate how to authenticate to the Pliant API via curl and create a new worker group. Please update the variables and curl arguments as needed for your environment

# authenticate:

TOKEN=`curl -ks "https://$PLIANT_HOST/api/oauth/token" -H 'Authorization: Basic cGxpYW50LmlvLXNwYTpWN1VPR3pBbHZ4V0xVWDhGYzVhVA==' -d "grant_type=password&username=$PLIANT_USER&password=$PLIANT_PASS" | grep -Po '(?<="access_token":").*?[^\\\\](?=")'`

You can now check for a long alphanumeric token in the $TOKEN variable

echo $TOKEN

If you have a valid token, you have authenticated to the API and are ready to perform a request

# request:
GROUP_DESC="New worker group created by User via CLI for Denmark Datacenter"

curl -k -X POST "https://${PLIANT_HOST}:443/api/v1/worker-group" -H  "accept: */*" -H  "authorization: Bearer ${TOKEN}" -H  "Content-Type: application/json" -d "{  \"description\": \"${GROUP_DESC}\",  \"name\": \"${GROUP_NAME}\",  \"secret\": \"${GROUP_SECRET}\",  \"validateCertificates\": false}"

The curl command will have no output if successful