#!/bin/bash
CURL="/usr/bin/curl"
CREDS="$HOME/.ngcp-api"
TOOLS="/usr/share/ngcp-panel-tools/ngcp-api.inc"

usage () {
	cat << EOF
Usage: $0 [OPTIONS] <url>

sends a delete request to NGCP REST API

OPTIONS:
  -h this help
  -v verbose mode
EOF
	exit 1
}

if [ -z "$APIUSER" ] ; then
	if [ -f "$TOOLS" ] ; then
		source "$TOOLS"
		importcreds
	else
		APIUSER="administrator:administrator"
	fi
fi
HEADERS="-H 'Connection: close'"

while getopts "hv" OPTION
do
	case $OPTION in
		h)
			usage
			;;
		v)
			VERBOSE="--verbose"
			;;
		?)
			usage
			;;
	esac
done
shift $(($OPTIND - 1))

URL="$1"
if [ -z "$URL" ] ; then
	usage
fi

${CURL} -i ${VERBOSE} -X DELETE "$HEADERS" --user "$APIUSER" --insecure "$URL"
