MT#12923 tools: move tools_bin/ngcp-api-tools to tools/ngcp-api.inc

- it was not a command

Change-Id: I1e0ae200906f7eeacdd558e5eebf06146b769378
changes/24/1824/6
Victor Seva 11 years ago
parent e8f318db31
commit e68f3cd63f

@ -1,11 +1,10 @@
#!/bin/sh
#!/bin/bash
CURL="/usr/bin/curl"
CREDS="$HOME/.ngcp-api"
TOOLS="/usr/bin/ngcp-api-tools"
test -f "$TOOLS" && . "$TOOLS"
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
@ -14,11 +13,17 @@ OPTIONS:
-h this help
-v verbose mode
EOF
exit 1
exit 1
}
test -z "$APIUSER" && -f "$TOOLS" && importcreds
test -z "$APIUSER" && APIUSER="administrator:administrator"
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
@ -38,6 +43,8 @@ done
shift $(($OPTIND - 1))
URL="$1"
test -z "$URL" && usage;
if [ -z "$URL" ] ; then
usage
fi
${CURL} -i ${VERBOSE} -X DELETE "$HEADERS" --user "$APIUSER" --insecure "$URL"

@ -1,24 +1,29 @@
#!/bin/bash
CURL="/usr/bin/curl"
CREDS="$HOME/.ngcp-api"
TOOLS="/usr/bin/ngcp-api-tools"
test -f "$TOOLS" && . "$TOOLS"
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
}
test -z "$APIUSER" && -f "$TOOLS" && importcreds
test -z "$APIUSER" && APIUSER="administrator:administrator"
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
@ -38,6 +43,8 @@ done
shift $(($OPTIND - 1))
URL="$1"
test -z "$URL" && usage;
if [ -z "$URL" ] ; then
usage
fi
${CURL} -i ${VERBOSE} -X GET "$HEADERS" --user "$APIUSER" --insecure "$URL"

@ -1,11 +1,10 @@
#!/bin/sh
#!/bin/bash
CURL="/usr/bin/curl"
CREDS="$HOME/.ngcp-api"
TOOLS="/usr/bin/ngcp-api-tools"
test -f "$TOOLS" && . "$TOOLS"
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
@ -16,11 +15,17 @@ OPTIONS:
-f read the input info from a file instead of read stdin
-m use Header 'Refer: return=minimal'
EOF
exit 1
exit 1
}
test -z "$APIUSER" && -f "$TOOLS" && importcreds
test -z "$APIUSER" && APIUSER="administrator:administrator"
if [ -z "$APIUSER" ] ; then
if [ -f "$TOOLS" ] ; then
source "$TOOLS"
importcreds
else
APIUSER="administrator:administrator"
fi
fi
INPUT="-T -"
CTYPE="application/json-patch+json"
PREFER="representation"
@ -53,7 +58,9 @@ done
shift $(($OPTIND - 1))
URL="$1"
test -z "$URL" && usage;
if [ -z "$URL" ] ; then
usage
fi
${CURL} -i ${VERBOSE} -X PATCH \
-H 'Connection: close' -H "Prefer: return=$PREFER" \

@ -1,11 +1,10 @@
#!/bin/sh
#!/bin/bash
CURL="/usr/bin/curl"
CREDS="$HOME/.ngcp-api"
TOOLS="/usr/bin/ngcp-api-tools"
test -f "$TOOLS" && . "$TOOLS"
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
@ -15,11 +14,17 @@ OPTIONS:
-v verbose mode
-f read the input info from a file instead of read stdin
EOF
exit 1
exit 1
}
test -z "$APIUSER" && -f "$TOOLS" && importcreds
test -z "$APIUSER" && APIUSER="administrator:administrator"
if [ -z "$APIUSER" ] ; then
if [ -f "$TOOLS" ] ; then
source "$TOOLS"
importcreds
else
APIUSER="administrator:administrator"
fi
fi
INPUT="-T -"
while getopts "f:hv" OPTION
@ -47,7 +52,9 @@ done
shift $(($OPTIND - 1))
URL="$1"
test -z "$URL" && usage;
if [ -z "$URL" ] ; then
usage
fi
CTYPE=${2:-application/json}
${CURL} -i ${VERBOSE} -X POST \

@ -1,11 +1,10 @@
#!/bin/sh
#!/bin/bash
CURL="/usr/bin/curl"
CREDS="$HOME/.ngcp-api"
TOOLS="/usr/bin/ngcp-api-tools"
test -f "$TOOLS" && . "$TOOLS"
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
@ -15,11 +14,17 @@ OPTIONS:
-v verbose mode
-f read the input info from a file instead of read stdin
EOF
exit 1
exit 1
}
test -z "$APIUSER" && -f "$TOOLS" && importcreds
test -z "$APIUSER" && APIUSER="administrator:administrator"
if [ -z "$APIUSER" ] ; then
if [ -f "$TOOLS" ] ; then
source "$TOOLS"
importcreds
else
APIUSER="administrator:administrator"
fi
fi
INPUT="-T -"
while getopts "f:hv" OPTION
@ -47,7 +52,9 @@ done
shift $(($OPTIND - 1))
URL="$1"
test -z "$URL" && usage;
if [ -z "$URL" ] ; then
usage
fi
CTYPE=${2:-application/json}
${CURL} -i ${VERBOSE} -X PUT \

Loading…
Cancel
Save