- please download and save the above file
setup_resources.sh
- navigate to the file's directory and perform
chmod +x setup_resources.sh
- to run enter
./setup_resources.sh
and follow the prompts
Last active
September 26, 2018 15:37
-
-
Save dpawluk/6cda1d0af0cb1699a2ea79a44e2ad129 to your computer and use it in GitHub Desktop.
Bash script that sets a specific resource_type and relationship_type to help save time with a demo app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Ask the user for their name | |
echo "This app will set up your custom resources resource and relationship types\n" | |
echo "To begin, please enter your subdomain:" | |
read subdomain | |
echo "Now enter your administrator email:" | |
read adminemail | |
echo "Lastly, please enter your password:" | |
read adminpassword | |
echo "Now creating resource_type..." | |
request1=$(/usr/bin/curl https://$subdomain.zendesk.com/api/custom_resources/resource_types -u $adminemail:$adminpassword -H "Content-type: application/json" -X POST -d '{ "data": { "key": "sticky_note", "schema": { "properties": { "note": { "type": "string", "description": "The of the sticky note" } }, "required": [ "note" ] } } }') | |
if [[ $request1 = *"error"* ]]; then | |
echo "There was an error creating the resource_type, please raise your hand" | |
else | |
echo "Successfully set up resource_type" | |
fi | |
request2=$(/usr/bin/curl https://$subdomain.zendesk.com/api/custom_resources/relationship_types -u $adminemail:$adminpassword -H "Content-type: application/json" -X POST -d '{ "data": { "key": "user_to_note", "source": ["zen:user"], "target": "sticky_note" } }') | |
if [[ $request2 = *"error"* ]]; then | |
echo "There was an error creating the resource_type, please raise your hand" | |
else | |
echo "Successfully set up resource_type" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment