MT#7543 install API scripts in /usr/bin. Add manpages and some new options.

gjungwirth/voicemail_number
Victor Seva 11 years ago
parent 4efe1b5499
commit 8f6585518f

5
debian/control vendored

@ -162,7 +162,10 @@ Description: Catalyst based application
Package: ngcp-panel-tools
Architecture: all
Depends: openssl, ${misc:Depends}, ${perl:Depends}
Depends: curl,
openssl,
${misc:Depends},
${perl:Depends}
Description: Tools from ngcp-panel application
A completely overhauled provisioning interface for the
NGCP system.

@ -1 +1,2 @@
tools/* usr/share/ngcp-panel-tools/
tools_bin/* usr/bin/

@ -0,0 +1,5 @@
tools_man/ngcp-api-delete.1
tools_man/ngcp-api-get.1
tools_man/ngcp-api-patch.1
tools_man/ngcp-api-put.1
tools_man/ngcp-api-post.1

@ -1,14 +0,0 @@
#!/bin/sh
usage () {
echo "Usage: $0 <url>";
exit;
}
URL="$1"
test -z "$URL" && usage;
test -z "$APIUSER" && APIUSER="administrator:administrator"
HEADERS="-H 'Connection: close'"
curl -i -X DELETE "$HEADERS" --user "$APIUSER" --insecure "$URL"

@ -1,14 +0,0 @@
#!/bin/sh
usage () {
echo "Usage: $0 <url>";
exit;
}
URL="$1"
test -z "$URL" && usage;
test -z "$APIUSER" && APIUSER="administrator:administrator"
HEADERS="-H 'Connection: close'"
curl -i -X GET "$HEADERS" --user "$APIUSER" --insecure "$URL"

@ -1,15 +0,0 @@
#!/bin/sh
usage () {
echo "Usage: $0 <url>";
exit;
}
URL="$1"
test -z "$URL" && usage;
CTYPE="application/json-patch+json"
test -z "$APIUSER" && APIUSER="administrator:administrator"
curl -i -X PATCH \
-H 'Connection: close' -H 'Prefer: return=representation' -H "Content-Type: $CTYPE" \
--user "$APIUSER" --insecure "$URL" -T -

@ -1,16 +0,0 @@
#!/bin/sh
usage () {
echo "Usage: $0 <url> <content-type>";
exit;
}
URL="$1"
test -z "$URL" && usage;
CTYPE="$2"
test -z "$CTYPE" && usage;
test -z "$APIUSER" && APIUSER="administrator:administrator"
curl -i -X POST \
-H 'Connection: close' -H 'Prefer: return=representation' -H "Content-Type: $CTYPE" \
--user "$APIUSER" --insecure "$URL" -T -

@ -1,16 +0,0 @@
#!/bin/sh
usage () {
echo "Usage: $0 <url> <content-type>";
exit;
}
URL="$1"
test -z "$URL" && usage;
CTYPE="$2"
test -z "$CTYPE" && usage;
test -z "$APIUSER" && APIUSER="administrator:administrator"
curl -i -X PUT \
-H 'Connection: close' -H 'Prefer: return=representation' -H "Content-Type: $CTYPE" \
--user "$APIUSER" --insecure "$URL" -T -

@ -0,0 +1,39 @@
#!/bin/sh
CURL="/usr/bin/curl"
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
}
test -z "$APIUSER" && APIUSER="administrator:administrator"
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"
test -z "$URL" && usage;
${CURL} -i ${VERBOSE} -X DELETE "$HEADERS" --user "$APIUSER" --insecure "$URL"

@ -0,0 +1,39 @@
#!/bin/sh
CURL="/usr/bin/curl"
usage () {
cat << EOF
Usage: $0 [OPTIONS] <url>
sends a get request to NGCP REST API
OPTIONS:
-h this help
-v verbose mode
EOF
exit 1
}
test -z "$APIUSER" && APIUSER="administrator:administrator"
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"
test -z "$URL" && usage;
${CURL} -i ${VERBOSE} -X GET "$HEADERS" --user "$APIUSER" --insecure "$URL"

@ -0,0 +1,57 @@
#!/bin/sh
CURL="/usr/bin/curl"
usage () {
cat << EOF
Usage: $0 [OPTIONS] <url>
sends a patch request to NGCP REST API
OPTIONS:
-h this help
-v verbose mode
-f read the input info from a file instead of read stdin
-m use Header 'Refer: return=minimal'
EOF
exit 1
}
test -z "$APIUSER" && APIUSER="administrator:administrator"
INPUT="-T -"
CTYPE="application/json-patch+json"
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
done
shift $(($OPTIND - 1))
URL="$1"
test -z "$URL" && usage;
${CURL} -i ${VERBOSE} -X PATCH \
-H 'Connection: close' -H "Prefer: return=$PREFER" \
-H "Content-Type: $CTYPE" \
--user "$APIUSER" --insecure ${FILE_INPUT} "$URL" ${INPUT}

@ -0,0 +1,52 @@
#!/bin/sh
CURL="/usr/bin/curl"
usage () {
cat << EOF
Usage: $0 [OPTIONS] <url> [content-type]
sends a post request to NGCP REST API
OPTIONS:
-h this help
-v verbose mode
-f read the input info from a file instead of read stdin
EOF
exit 1
}
test -z "$APIUSER" && APIUSER="administrator:administrator"
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
done
shift $(($OPTIND - 1))
URL="$1"
test -z "$URL" && usage;
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}

@ -0,0 +1,52 @@
#!/bin/sh
CURL="/usr/bin/curl"
usage () {
cat << EOF
Usage: $0 [OPTIONS] <url> [content-type]
sends a put request to NGCP REST API
OPTIONS:
-h this help
-v verbose mode
-f read the input info from a file instead of read stdin
EOF
exit 1
}
test -z "$APIUSER" && APIUSER="administrator:administrator"
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
done
shift $(($OPTIND - 1))
URL="$1"
test -z "$URL" && usage;
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}

@ -0,0 +1,31 @@
.TH NGCP-API 1
.SH NAME
sends a delete request to NGCP REST API
.SH SYNOPSIS
.B ngcp-api-delete
[\fB\-v\fR]
[\fB\-h\fR]
.IR URL
.SH DESCRIPTION
.B ngcp-api-delete
sends a delete request to NGCP REST API.
.SH OPTIONS
.TP
.BR \-v
verbose mode.
.TP
.BR \-h
print usage.
.TP
URL
Url for the request
.SH EXAMPLES
.TP
ngcp-api-delete 'https://example.org:1443/api/domains/1'
.SH SEE ALSO
.TP
ngcp-api-put(1), ngcp-api-post(1), ngcp-api-patch(1), ngcp-api-get(1)
.TP
https://ngcp-server.domain:1443/api
.SH COPYRIGHT
2014 Sipwise Development Team <support@sipwise.com>

@ -0,0 +1,31 @@
.TH NGCP-API 1
.SH NAME
sends a get request to NGCP REST API
.SH SYNOPSIS
.B ngcp-api-get
[\fB\-v\fR]
[\fB\-h\fR]
.IR URL
.SH DESCRIPTION
.B ngcp-api-get
sends a get request to NGCP REST API.
.SH OPTIONS
.TP
.BR \-v
verbose mode.
.TP
.BR \-h
print usage.
.TP
URL
Url for the request
.SH EXAMPLES
.TP
ngcp-api-get 'https://example.org:1443/api/domains/'
.SH SEE ALSO
.TP
ngcp-api-put(1), ngcp-api-post(1), ngcp-api-patch(1), ngcp-api-delete(1)
.TP
https://ngcp-server.domain:1443/api
.SH COPYRIGHT
2014 Sipwise Development Team <support@sipwise.com>

@ -0,0 +1,40 @@
.TH NGCP-API 1
.SH NAME
sends a patch request to NGCP REST API
.SH SYNOPSIS
.B ngcp-api-patch
[\fB\-f\fR \fIFILEPATH\fR]
[\fB\-m\fR]
[\fB\-v\fR]
[\fB\-h\fR]
.IR URL
.SH DESCRIPTION
.B ngcp-api-patch
sends a patch request to NGCP REST API.
.SH OPTIONS
.TP
.BR \-f " " \fIFILEPATH\fR
use input file instead of stdin.
.TP
.BR \-m
Use Header 'Refer: return=minimal'. Default is 'Refer: return=representation'
.TP
.BR \-v
verbose mode.
.TP
.BR \-h
print usage.
.TP
URL
Url for the request
.SH EXAMPLES
.TP
echo '[ { "op" : "remove", "path" : "/active" } ]'|\\
ngcp-api-patch 'https://example.org:1443/api/faxserversettings/2'
.SH SEE ALSO
.TP
ngcp-api-put(1), ngcp-api-post(1), ngcp-api-delete(1), ngcp-api-get(1)
.TP
https://ngcp-server.domain:1443/api
.SH COPYRIGHT
2014 Sipwise Development Team <support@sipwise.com>

@ -0,0 +1,42 @@
.TH NGCP-API 1
.SH NAME
sends a post request to NGCP REST API
.SH SYNOPSIS
.B ngcp-api-post
[\fB\-f\fR \fIFILEPATH\fR]
[\fB\-v\fR]
[\fB\-h\fR]
.IR URL
[content_type]
.SH DESCRIPTION
.B ngcp-api-post
sends a post request to NGCP REST API.
.SH OPTIONS
.TP
.BR \-f " " \fIFILEPATH\fR
use input file instead of stdin.
.TP
.BR \-v
verbose mode.
.TP
.BR \-h
print usage.
.TP
URL
Url for the request
.TP
content_type
The default is 'application/json'
.SH EXAMPLES
.TP
echo '{ "domain" : "test", "reseller_id" : 4 }' \\
| ngcp-api-post https://127.0.0.1:1443/api/domains/
.TP
ngcp-api-post -f ../test_post.txt https://127.0.0.1:1443/api/domains/ 'application/json'
.SH SEE ALSO
.TP
ngcp-api-get(1), ngcp-api-put(1), ngcp-api-patch(1), ngcp-api-delete(1)
.TP
https://ngcp-server.domain:1443/api
.SH COPYRIGHT
2014 Sipwise Development Team <support@sipwise.com>

@ -0,0 +1,42 @@
.TH NGCP-API 1
.SH NAME
sends a put request to NGCP REST API
.SH SYNOPSIS
.B ngcp-api-put
[\fB\-f\fR \fIFILEPATH\fR]
[\fB\-v\fR]
[\fB\-h\fR]
.IR URL
[content_type]
.SH DESCRIPTION
.B ngcp-api-put
sends a put request to NGCP REST API.
.SH OPTIONS
.TP
.BR \-f " " \fIFILEPATH\fR
use input file instead of stdin.
.TP
.BR \-v
verbose mode.
.TP
.BR \-h
print usage.
.TP
URL
Url for the request
.TP
content_type
The default is 'application/json'
.SH EXAMPLES
.TP
echo '{"body":"test","from_email":"test","name":"test","reseller_id":4,"subject":"test"}'\\
|ngcp-api-put 'https://example.org:1443/api/emailtemplates/2'
.TP
ngcp-api-put -f ../test_put.json https://127.0.0.1:1443/api/domains/ 'application/json'
.SH SEE ALSO
.TP
ngcp-api-get(1), ngcp-api-post(1), ngcp-api-patch(1), ngcp-api-delete(1)
.TP
https://ngcp-server.domain:1443/api
.SH COPYRIGHT
2014 Sipwise Development Team <support@sipwise.com>
Loading…
Cancel
Save