This API call deletes device group
Title : Delete Device Group API
Version : 2019/10/08
API Server URL : http(s):// IP address of your NetBrain Web API Server /ServicesAPI/API/V1//CMDB/DeviceGroups/{deviceGroupID}
Authentication :
Type | In | Name |
---|---|---|
Bearer Authentication | Headers | Authentication token |
No parameters required.
Data Format Headers
Name | Type | Description |
---|---|---|
Content-Type | string | support "application/json" |
Accept | string | support "application/json" |
Authorization Headers
Name | Type | Description |
---|---|---|
token | string | Authentication token, get from login API. |
Name | Type | Description |
---|---|---|
statusCode | integer | The returned status code of executing the API. |
statusDescription | string | The explanation of the status code. |
Example
{
"statusCode": 790200,
"statusDescription": "Success."
}
# import python modules
import requests
import time
import urllib3
import pprint
import json
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# Set the request inputs
token = "ad3c616e-5f3d-45e9-9ba1-bb71f003a098"
deviceGroupID = 'ef1864f2-58a2-4f4f-8d48-015ce8068d93'
nb_url = "http://192.168.28.143"
full_url = nb_url + "/ServicesAPI/API/V1/CMDB/DeviceGroups/"+deviceGroupID
headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
headers["Token"] = token
try:
response = requests.delete(full_url, headers = headers, verify = False)
if response.status_code == 200:
result = response.json()
print (result)
else:
print ("Delete device group failed! - " + str(response.text))
except Exception as e:
print (str(e))
{'statusCode': 790200, 'statusDescription': 'Success.'}
curl -X DELETE \
http://192.168.28.143/ServicesAPI/API/V1/CMDB/DeviceGroups/9732dca7-9709-4c49-91e1-a2310b8364d9 \
-H 'accept: application/json' \
-H 'content-type: application/json' \
-H 'token: ad3c616e-5f3d-45e9-9ba1-bb71f003a098'
###################################################################################################################
"""Error 1: Null parameter: the parameter '{}' cannot be null."""
Input:
"name": "",
"type": "policy"
Response:
"Parameter cannot be null -
{
"statusCode":791000,
"statusDescription":"Null parameter: the parameter '{}' cannot be null."
}"
###################################################################################################################
"""Error 2: device group: {}, type: {} already exists."""
Input:
"name": "Device Group 1",
"type": "policy"
Response:
"Device Group already exists! -
{
"statusCode":791007,
"statusDescription":"device group: {}, type: {} already exists."
}"
###################################################################################################################
"""Error 3: You are not allowed to perform the operation."""
Input:
"User has no privilege to make change to device groups"
Response:
"You are not allowed to perform the operation. Failed! -
{
"statusCode":791000,
"statusDescription":"You are not allowed to perform the operation."
}"