Call this API to get the value for a specified attribute of a device interface, get all attributes if the attribute name is not specifed.
Title : Get Module Attributes API
Version : 01/30/2019.
API Server URL : http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/V1/CMDB/Modules/Attributes
Authentication :
Type | In | Name |
---|---|---|
Bearer Authentication | Headers | Authentication token |
No request body.
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
{
"statusCode": 790200,
"statusDescription": "success",
"hostname": "Bos-Core-1",
"attributeName": "newAttribute",
"moduleAttributeValue": "newAttribute"
}
# import python modules
import requests
import time
import urllib3
import pprint
import json
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# Set the request inputs
token = "9c717c9a-4302-45b5-a068-2a3e9c4ea1a3"
nb_url = "http://192.168.28.79"
full_url = nb_url + "/ServicesAPI/API/V1/CMDB/Modules/Attributes"
headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
headers["Token"] = token
attributeName = "Module_newAtt"
moduleName = "newModule"
hostname = "R1"
data = {
"hostname":hostname,
"moduleName":moduleName,
"attributeName":attributeName
}
try:
response = requests.get(full_url, params=data, headers=headers, verify=False)
if response.status_code == 200:
result = response.json()
print ("Module Attributes :"+str(result))
else:
print ("Get module attributes failed! - " + str(response.text))
except Exception as e:
print (str(e))
Get module attributes failed! - {"statusCode":793001,"statusDescription":"Inner exception. please check system log(default location: log/NgThirdAPI.log)"}
curl -X GET \
'http://192.168.28.79/ServicesAPI/API/V1/CMDB/Modules/Attributes?attributeName=Module_newAtt&moduleName=newModule&hostname=R1' \
-H 'Postman-Token: e4e03449-689b-4732-af30-0e4e2ef6360e' \
-H 'cache-control: no-cache' \
-H 'token: 9c717c9a-4302-45b5-a068-2a3e9c4ea1a3'