Files
kubernetes/dev/itop/create-change.sh
T
2026-01-18 12:56:16 +01:00

28 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-dev.allarddcs.nl"
ITOP_USER="admin"
ITOP_PWD="Itop01@"
ORGANIZATION="0001"
TITLE="UserRequest"
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"
echo $RESULT
else
echo "ERROR: failed to create change"
echo $RESULT
fi