Call this API to get device groups information.
Title : Get Device Groups API
Version : 03/07/2022
API Server URL : http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/V1/CMDB/DeviceGroups
Authentication :
Type | In | Name |
---|---|---|
Bearer Authentication | Headers | Authentication token |
No request body.
No parameters required.
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. |
Example
{
"deviceGroups": [
{
"id": "d6fb1de4-f092-41dd-a8f7-80832b4b253d",
"name": "System Device Groups/#BGP 12076",
"type": 2
},
{
"id": "f6dfac40-ea61-4cf1-9f46-777bb5cfec03",
"name": "System Device Groups/#BGP 64515",
"type": 2
},
{
"id": "56c1f8a6-9762-062c-3e99-8055f969e4ae",
"name": "Shared Device Groups/Test for Demo",
"type": 0
},
{
"id": "6b4fe54d-28be-bed9-daf9-65144861ef6e",
"name": "Shared Device Groups/NICUseCaseTrain/training_case2_check_ospf_neighbor_interface_cost_mismatch",
"type": 0
},
{
"id": "907691ce-09e8-19cb-7b3e-f47b74152f44",
"name": "Shared Device Groups/NICUseCaseTrain/training_case3_check_ibgp_reflector_and_clients_connectivity",
"type": 0
},
{
"id": "c3a81388-18d3-4be0-91f4-de6ea9b38596",
"name": "System Device Groups/#Device Per Driver",
"type": 2
}
],
"statusCode": 790200,
"statusDescription": "Success."
}
# import python modules
import requests
import json
# Set the request inputs
token = "1f93390b-9b11-41b5-9d89-3fc0b1e8af10"
full_url = "https://unicorn-new.netbraintech.com/ServicesAPI/API/V1/CMDB/DeviceGroups"
# Set proper headers
headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
headers["Token"] = token
try:
# Do the HTTP request
response = requests.get(full_url, headers=headers, verify=False)
# Check for HTTP codes other than 200
if response.status_code == 200:
# Decode the JSON response into a dictionary and use the data
result = response.json()
print (result)
else:
print ("Get Device Groups failed! - " + str(response.text))
except Exception as e: print (str(e))
curl --location --request GET 'https://unicorn-new.netbraintech.com/ServicesAPI/API/V1/CMDB/DeviceGroups' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'token: 0f93390b-9b11-41b5-9d89-3fc0b1e8af10' \
--data-raw ''