Adding inventoryHandle API

This commit is contained in:
stephb9959
2021-08-23 20:40:22 -07:00
parent 83c613ec60
commit ceff684d66
3 changed files with 30 additions and 5 deletions

View File

@@ -49,7 +49,7 @@ login() {
exit 13
fi
echo "${token}" > token.json
setfms
setprov
}
findbrowser() {
@@ -72,7 +72,7 @@ findbrowser() {
fi
}
setfms() {
setprov() {
curl ${FLAGS} -X GET "https://${UCENTRALSEC}/api/v1/systemEndpoints" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
@@ -131,7 +131,25 @@ setroot() {
addentity() {
payload="{ \"name\" : \"$1\", \"description\" : \"sub entity.\", \"parent\" : \"0000-0000-0000\", \"notes\" : [ {\"note\" : \"CLI added\"} ] }";
curl ${FLAGS} -X POST "https://${OWPROV}/api/v1/entity/1" \
curl ${FLAGS} -X POST "https://${OWPROV}/api/v1/inventory/1" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${token}" \
-H "accept: application/json" \
-d "$payload" > ${result_file}
jq < ${result_file}
}
getentities() {
curl ${FLAGS} "https://${OWPROV}/api/v1/entity" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${token}" \
-H "accept: application/json" > ${result_file}
jq < ${result_file}
}
addtag() {
payload="{ \"name\" : \"$1\",\"entity\" : \"$2\", \"serialNumber\" : \"$1\", \"deviceType\" : \"linksys_ea8300\" }";
curl ${FLAGS} -X POST "https://${OWPROV}/api/v1/inventory/1" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${token}" \
-H "accept: application/json" \
@@ -145,6 +163,8 @@ case "$1" in
"getroot") login; getroot; logout;;
"setroot") login; setroot; logout;;
"addentity") login; addentity "$2" ; logout;;
"addtag") login; addtag $2 $3; logout;;
"getentities") login; getentities ; logout;;
*) help ;;
esac