Calling this API to get the One-IP Table.
If user provide an input value of "ip" attribute, then this API will return all items which have the same ip address in One-IP Table;
If user set "IP = null" or " IP = "" " but provide the input values of "beginIndex" and "count", API will return One-IP Table with items number equal to "count" values start from "beginIndex". But notice that the default maximum value of "count" is 1000. So if the input value of "count" greater than 1000, API will only return 1000 itmes. And if start from beginIndex to the end of table, there are no enough count items, API will return the rest of items.
Note: The One-IP table records the physical connections for all IP addresses in your workspace. It is retrieved during the Layer 2 topology discovery. You can use the One-IP table to troubleshoot any Layer 2 connection issues.
Title : Get One-Ip Table API
Version : 02/06/2019.
API Server URL : http(s):// IP address of your NetBrain Web API Server /ServicesAPI/API/V1/CMDB/Topology/OneIPTable
Authentication :
Type | In | Name |
---|---|---|
Bearer Authentication | Parameters | Authentication token |
No request body.
Name | Type | Description |
---|---|---|
ip | string | The ip address of current device.If user provide an input value of "ip" attribute, then this API will return all items which have the same ip address in One-IP Table; |
lan | string | The LAN Segment of the IP address.If user provide an input value of “lan” attribute, then this API will return all items which have the same LAN segement in One-IP Table; |
mac | string | The MAC address related to the IP address.If user provide an input value of “mac” attribute, then this API will return all items which have the same mac address in One-IP Table; |
switch_name | string | The switch name connected to the end system.If user provide an input value of “switch_name” attribute, then this API will return all items which have the same switch name in One-IP Table; |
switch_port | string | The fullname of switchport to connected to end system or the device interface configured with this IP address. This is not a independent attribute, to use this attribute, 'switch_name' is necessary. |
dns | string | The resolved DNS name of the end system, or the combination of the device name and interface name. If the DNS name is not resolved, it is null. |
beginIndex* | int | Begin index of data, API will return OneIP Table items start from "beginIndex". |
count* | int | Count number of returned data, API will return OneIP Table items, the total number of items is the value of "count". Maximum "count" value is 10000. So API will only return 10000 itmes even users set the input value of "count" greater than 10000. If the total number of items which start from "beginIndex" to the end of table are less than "count" value, API will return the rest of items. Note: If customer insert the beginindex as 1 and count as 10002 which meands the total number will greater than 10000. Then customer would get an error and without any result returned. |
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
{
"OneIPList": [
{
"lanSegment": "123.20.1.8/29",
"ip": "123.20.1.11",
"mac": "AABB.CC80.1300",
"devName": "SW6",
"interfaceName": "Vlan66",
"switchName": "",
"portName": "",
"alias": "",
"dns": "SW6.Vlan66",
"sourceDevice": "SW6",
"serverType": 2001,
"switchType": 2001,
"updateTime": "2019-02-01T19:13:05Z",
"userFlag": 9,
"source": "Device Interface",
"vendor": "",
"descr": ""
}
],
"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 = "220d6462-ba64-4058-83cb-affb2d55de78"
nb_url = "http://192.168.28.79"
full_url = nb_url + "/ServicesAPI/API/V1/CMDB/Topology/OneIPTable"
headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
headers["Token"] = token
ip = "123.20.1.11"
beginIndex = 0
count = 5
data = {
"ip" : ip,
"beginIndex" : beginIndex,
"count" : count
}
try:
response = requests.get(full_url, params = data, headers = headers, verify = False)
if response.status_code == 200:
result = response.json()
print (result)
else:
print ("Get One-Ip Table failed! - " + str(response.text))
except Exception as e:
print (str(e))
{'OneIPList': [{'lanSegment': '123.20.1.8/29', 'ip': '123.20.1.11', 'mac': 'AABB.CC80.1300', 'devName': 'SW6', 'interfaceName': 'Vlan66', 'switchName': '', 'portName': '', 'alias': '', 'dns': 'SW6.Vlan66', 'sourceDevice': 'SW6', 'serverType': 2001, 'switchType': 2001, 'updateTime': '2019-02-01T19:13:05Z', 'userFlag': 9, 'source': 'Device Interface', 'vendor': '', 'descr': ''}], 'statusCode': 790200, 'statusDescription': 'Success.'}
curl -X GET \
'http://192.168.28.79/ServicesAPI/API/V1/CMDB/Topology/OneIPTable?ip=123.20.1.11&beginIndex=0&count=5' \
-H 'Postman-Token: ae0e4721-9d20-44ac-9b4d-4d73ccb8abcd' \
-H 'cache-control: no-cache' \
-H 'token: 220d6462-ba64-4058-83cb-affb2d55de78'
###################################################################################################################
"""Error 1: empty inputs"""
Input:
ip = ""
count = None # Can not be null.
beginIndex = None # Can not be null.
Response:
"Get One-Ip Table failed! -
{"statusCode":791000,"statusDescription":"Null parameter: the parameter 'BeginIndex(int)' cannot be null."}
"Get One-Ip Table failed! -
{"statusCode":791000,"statusDescription":"Null parameter: the parameter 'Count(int)' cannot be null."}"
###################################################################################################################
"""Error 2: wrong input values type """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Input:
ip = ""
count = "100" # Should be integer
beginIndex = "50" # Should be integer
Response:
"{
'OneIPList': [...],
'statusCode': 790200,
'statusDescription': 'Success.'
}"
###################################################################################################################
"""Error 3: wrong input values type """
Input:
ip = "hahahahaah" # There is no Ip address like this
count = 100
beginIndex = 50
Response:
"Get One-Ip Table failed! -
{
"statusCode":791001,
"statusDescription":"Invalid parameter: the parameter 'IP' is invalid."
}"
###################################################################################################################
"""Error 4: count > 1000 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Input:
ip = ""
count = 10000 # Should be less or equal to 1000
beginIndex = 50
Response:
"Get One-Ip Table failed! -
{
"statusCode":791002,
"statusDescription":"Invalid value"
}"
###################################################################################################################
"""Error 5: "beginIndex" > size of One-Ip Table """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Input:
ip = ""
count = 1
beginIndex = 500 # There are only 117 items in this table.
Response:
"{
'OneIPList': [],
'statusCode': 790200,
'statusDescription': 'Success.'
}"