Files
kubernetes/dev/itop/itop-integrations/create-change.sh
2025-11-23 18:58:51 +01:00

29 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
##################################################################################
# #
# Example script for creating a UserRequest ticket via the REST/JSON webservices #
# #
##################################################################################
# iTop location and credentials, change them to suit your iTop installation
ITOP_URL="https://itop.alldcs.nl"
ITOP_USER="tekton"
ITOP_PWD="Itop01@@@"
ORGANIZATION="0002"
TITLE="Change registration"
DESCRIPTION="Container created"
CALLER="0001"
COMMENT="commentaar"
CHANGE="RoutineChange"
# Let's create the ticket via the REST/JSON API
JSON_DATA='{"operation":"core/create", "class":"'"${CHANGE}"'", "fields": {"org_id":"'"${ORGANIZATION}"'", "title":"'"$TITLE"'", "description":"'"$DESCRIPTION"'"}, "caller": "'"$CALLER"'", "comment": "'"$COMMENT"'"}'
RESULT=`wget -q --post-data='auth_user='"${ITOP_USER}"'&auth_pwd='"${ITOP_PWD}"'&json_data='"${JSON_DATA}" --no-check-certificate -O - "${ITOP_URL}/webservices/rest.php?version=1.0"`
PATTERN='"key":"([0-9])+"'
if [[ $RESULT =~ $PATTERN ]]; then
echo "Change created successfully"
else
echo "ERROR: failed to create change"
echo $RESULT
exit 1
fi