TT#77256 ngcp-api-tools: Normalize coding style

Use the prevalent Sipwise coding style.

Change-Id: I50fb2ee49c188b65ea7151c8b097fe39dc6b3101
changes/54/39054/1
Guillem Jover 6 years ago
parent 624139ffcf
commit 29d5761bec

@ -1,10 +1,10 @@
#!/bin/bash
CURL="/usr/bin/curl"
CREDS="$HOME/.ngcp-api"
CREDS="${HOME}/.ngcp-api"
TOOLS="/usr/share/ngcp-panel-tools/ngcp-api.inc"
usage () {
cat << EOF
cat << EOF
Usage: $0 [OPTIONS] <url>
sends a delete request to NGCP REST API
@ -13,38 +13,39 @@ OPTIONS:
-h this help
-v verbose mode
EOF
exit 1
exit 1
}
if [ -z "$APIUSER" ] ; then
if [ -f "$TOOLS" ] ; then
source "$TOOLS"
importcreds "$CREDS"
else
APIUSER="administrator:administrator"
fi
if [ -z "${APIUSER}" ]; then
if [ -f "${TOOLS}" ]; then
source "${TOOLS}"
importcreds "${CREDS}"
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
case ${OPTION} in
h)
usage
;;
v)
VERBOSE="--verbose"
;;
?)
usage
;;
esac
done
shift $((OPTIND - 1))
URL="$1"
if [ -z "$URL" ] ; then
usage
if [ -z "${URL}" ] ; then
usage
fi
${CURL} -i ${VERBOSE} -X DELETE "$HEADERS" --user "$APIUSER" --insecure "$URL"
${CURL} -i ${VERBOSE} -X DELETE \
-H 'Connection: close' \
"${HEADERS}" --user "${APIUSER}" --insecure "${URL}"

@ -1,50 +1,51 @@
#!/bin/bash
CURL="/usr/bin/curl"
CREDS="$HOME/.ngcp-api"
CREDS="${HOME}/.ngcp-api"
TOOLS="/usr/share/ngcp-panel-tools/ngcp-api.inc"
usage () {
cat << EOF
cat << EOF
Usage: $0 [OPTIONS] <url>
sends a get request to NGCP REST API
OPTIONS:
-h this help
-v verbose mode
-h this help
-v verbose mode
EOF
exit 1
exit 1
}
if [ -z "$APIUSER" ] ; then
if [ -f "$TOOLS" ] ; then
source "$TOOLS"
importcreds "$CREDS"
else
APIUSER="administrator:administrator"
fi
if [ -z "${APIUSER}" ]; then
if [ -f "${TOOLS}" ]; then
source "${TOOLS}"
importcreds "${CREDS}"
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
case ${OPTION} in
h)
usage
;;
v)
VERBOSE="--verbose"
;;
?)
usage
;;
esac
done
shift $((OPTIND - 1))
URL="$1"
if [ -z "$URL" ] ; then
usage
if [ -z "${URL}" ]; then
usage
fi
${CURL} -i ${VERBOSE} -X GET "$HEADERS" --user "$APIUSER" --insecure "$URL"
${CURL} -i ${VERBOSE} -X GET \
-H 'Connection: close' \
--user "${APIUSER}" --insecure "${URL}"

@ -1,10 +1,10 @@
#!/bin/bash
CURL="/usr/bin/curl"
CREDS="$HOME/.ngcp-api"
CREDS="${HOME}/.ngcp-api"
TOOLS="/usr/share/ngcp-panel-tools/ngcp-api.inc"
usage () {
cat << EOF
cat << EOF
Usage: $0 [OPTIONS] <url>
sends a patch request to NGCP REST API
@ -15,13 +15,13 @@ OPTIONS:
-f read the input info from a file instead of read stdin
-m use Header 'Refer: return=minimal'
EOF
exit 1
exit 1
}
if [ -z "$APIUSER" ] ; then
if [ -f "$TOOLS" ] ; then
source "$TOOLS"
importcreds "$CREDS"
if [ -z "${APIUSER}" ]; then
if [ -f "${TOOLS}" ]; then
source "${TOOLS}"
importcreds "${CREDS}"
else
APIUSER="administrator:administrator"
fi
@ -32,37 +32,37 @@ PREFER="representation"
while getopts "mf:hv" OPTION
do
case $OPTION in
h)
usage
;;
f)
INPUT=()
FILE_INPUT=(--data-binary @$OPTARG)
if [ ! -f "$OPTARG" ]; then
echo "No '$OPTARG' file found"
usage
fi
;;
m)
PREFER="minimal"
;;
v)
VERBOSE="--verbose"
;;
?)
usage
;;
esac
case ${OPTION} in
h)
usage
;;
f)
INPUT=()
FILE_INPUT=(--data-binary @${OPTARG})
if [ ! -f "${OPTARG}" ]; then
echo "No '${OPTARG}' file found"
usage
fi
;;
m)
PREFER="minimal"
;;
v)
VERBOSE="--verbose"
;;
?)
usage
;;
esac
done
shift $((OPTIND - 1))
URL="$1"
if [ -z "$URL" ] ; then
if [ -z "${URL}" ] ; then
usage
fi
${CURL} -i ${VERBOSE} -X PATCH \
-H 'Connection: close' -H "Prefer: return=$PREFER" \
-H "Content-Type: $CTYPE" \
--user "$APIUSER" --insecure "${FILE_INPUT[@]}" "$URL" "${INPUT[@]}"
-H 'Connection: close' -H "Prefer: return=${PREFER}" \
-H "Content-Type: ${CTYPE}" \
--user "${APIUSER}" --insecure "${FILE_INPUT[@]}" "${URL}" "${INPUT[@]}"

@ -1,10 +1,10 @@
#!/bin/bash
CURL="/usr/bin/curl"
CREDS="$HOME/.ngcp-api"
CREDS="${HOME}/.ngcp-api"
TOOLS="/usr/share/ngcp-panel-tools/ngcp-api.inc"
usage () {
cat << EOF
cat << EOF
Usage: $0 [OPTIONS] <url> [content-type]
sends a post request to NGCP REST API
@ -14,50 +14,50 @@ OPTIONS:
-v verbose mode
-f read the input info from a file instead of read stdin
EOF
exit 1
exit 1
}
if [ -z "$APIUSER" ] ; then
if [ -f "$TOOLS" ] ; then
source "$TOOLS"
importcreds "$CREDS"
else
APIUSER="administrator:administrator"
fi
if [ -z "${APIUSER}" ]; then
if [ -f "${TOOLS}" ]; then
source "${TOOLS}"
importcreds "${CREDS}"
else
APIUSER="administrator:administrator"
fi
fi
INPUT=(-T -)
while getopts "f:hv" OPTION
do
case $OPTION in
h)
usage
;;
f)
INPUT=()
FILE_INPUT=(--data-binary @$OPTARG)
if [ ! -f "$OPTARG" ]; then
echo "No '$OPTARG' file found"
usage
fi
;;
v)
VERBOSE="--verbose"
;;
?)
usage
;;
esac
case ${OPTION} in
h)
usage
;;
f)
INPUT=()
FILE_INPUT=(--data-binary @${OPTARG})
if [ ! -f "${OPTARG}" ]; then
echo "No '{$OPTARG}' file found"
usage
fi
;;
v)
VERBOSE="--verbose"
;;
?)
usage
;;
esac
done
shift $((OPTIND - 1))
URL="$1"
if [ -z "$URL" ] ; then
usage
if [ -z "${URL}" ]; then
usage
fi
CTYPE=${2:-application/json}
${CURL} -i ${VERBOSE} -X POST \
-H 'Connection: close' -H 'Prefer: return=representation' \
-H "Content-Type: $CTYPE" \
--user "$APIUSER" --insecure "${FILE_INPUT[@]}" "$URL" "${INPUT[@]}"
-H 'Connection: close' -H 'Prefer: return=representation' \
-H "Content-Type: ${CTYPE}" \
--user "${APIUSER}" --insecure "${FILE_INPUT[@]}" "${URL}" "${INPUT[@]}"

@ -1,10 +1,10 @@
#!/bin/bash
CURL="/usr/bin/curl"
CREDS="$HOME/.ngcp-api"
CREDS="${HOME}/.ngcp-api"
TOOLS="/usr/share/ngcp-panel-tools/ngcp-api.inc"
usage () {
cat << EOF
cat << EOF
Usage: $0 [OPTIONS] <url> [content-type]
sends a put request to NGCP REST API
@ -14,13 +14,13 @@ OPTIONS:
-v verbose mode
-f read the input info from a file instead of read stdin
EOF
exit 1
exit 1
}
if [ -z "$APIUSER" ] ; then
if [ -f "$TOOLS" ] ; then
source "$TOOLS"
importcreds "$CREDS"
if [ -z "${APIUSER}" ]; then
if [ -f "${TOOLS}" ]; then
source "${TOOLS}"
importcreds "${CREDS}"
else
APIUSER="administrator:administrator"
fi
@ -29,35 +29,35 @@ INPUT=(-T -)
while getopts "f:hv" OPTION
do
case $OPTION in
h)
usage
;;
f)
INPUT=()
FILE_INPUT=(--data-binary @$OPTARG)
if [ ! -f "$OPTARG" ]; then
echo "No '$OPTARG' file found"
usage
fi
;;
v)
VERBOSE="--verbose"
;;
?)
usage
;;
esac
case ${OPTION} in
h)
usage
;;
f)
INPUT=()
FILE_INPUT=(--data-binary @${OPTARG})
if [ ! -f "${OPTARG}" ]; then
echo "No '${OPTARG}' file found"
usage
fi
;;
v)
VERBOSE="--verbose"
;;
?)
usage
;;
esac
done
shift $((OPTIND - 1))
URL="$1"
if [ -z "$URL" ] ; then
if [ -z "${URL}" ] ; then
usage
fi
CTYPE=${2:-application/json}
${CURL} -i ${VERBOSE} -X PUT \
-H 'Connection: close' -H 'Prefer: return=representation' \
-H "Content-Type: $CTYPE" \
--user "$APIUSER" --insecure "${FILE_INPUT[@]}" "$URL" "${INPUT[@]}"
-H 'Connection: close' -H 'Prefer: return=representation' \
-H "Content-Type: ${CTYPE}" \
--user "${APIUSER}" --insecure "${FILE_INPUT[@]}" "${URL}" "${INPUT[@]}"

Loading…
Cancel
Save