The following request is used to retrieve all import data.
API Request
Python
Request:
GET ot-base/api/v1/imports
import requests
# Enter your hostname (for example: myserver.com or 127.0.0.1) between the quotes.
hostname = 'enterHostnameOrIP'
# Replace username and password with your username and password credentials.
auth = ('username', 'password')
url = 'https://' + hostname + '/ot-base/api/v1/imports/'
response = requests.get(url, auth=auth)
print(response.status_code)
print(response.text)
This request can be limited to show only a subset of imports using the count option.
API Request
Python
Request:
GET /ot-base/api/v1/imports/?count=n
import requests
# Enter your hostname (for example: myserver.com or 127.0.0.1) between the quotes.
hostname = 'enterHostnameOrIP'
# Replace username and password with your username and password credentials.
auth = ('username', 'password')
# Specify the count value. Replace 'n' with the desired page size, a number greater than zero.
count_value = 'n'
url = f'https://{hostname}/ot-base/api/v1/imports/?count={count_value}'
response = requests.get(url, auth=auth)
print(response.status_code)
print(response.text)
The optional parameter count=n, where n is a number greater zero, can be used to define a page size for results, if you are concerned about too many result data.
Response:
"data": [ {
"importId": "ADI_1",
"time": "2019-08-08 07:44:57",
"user": "OTbase Discovery",
"node": "nodename",
"locationId": "",
"summary": {
"total": 225,
"new": 218,
"changed": 3,
"skipped": 1
}
}],
"info": {
"total": 4808,
"offset": 0,
"next_offset": 1,
"user": "admin",
"origin": "OTbase Inventory 8.01"
}
Retrieving import details
Individual imports can be retrieved by specifying the import identifier (importId) in the API call. This will result in only the data for this particular import being returned.
API Request
Python
Request:
GET /ot-base/api/v1/imports/ADI_1
import requests
# Enter your hostname (for example: myserver.com or 127.0.0.1) between the quotes.
hostname = 'enterHostnameOrIP'
# Specify the import identifier
importId = 'ADI_1' # Example importId value
# Replace username and password with your username and password credentials.
auth = ('username', 'password')
url = f'https://{hostname}/ot-base/api/v1/imports/{importId}'
response = requests.get(url, auth=auth)
print(response.status_code)
print(response.text)
Response:
"data": {
"importId": "ADI_1",
"time": "2019-08-08 07:44:57",
"user": "OTbase Discovery",
"node": "---",
"locationId": "",
"summary": {
"total": 225,
"new": 218,
"skipped": 1,
"changed": 3,
"unchanged": 3,
"unknown": 0
},
"devices": {
"new": [
{
"name": "nodename.PLC1",
"deviceId": "nodename.PLC1"
},
.
.
.
{
"name": "nodename.Other146",
"deviceId": "nodename.Other146"
}
],
"skipped": [
{
"name": "",
"deviceId": "nodename.PLC1",
"reasons": ["Not updated because existing device is not flagged for automatic updates"]
}
],
"changed": [
{
"name": "nodename",
"deviceId": "nodename.Desktop1",
"reasons": ["Hardware has been changed"]
},
{
"name": "",
"deviceId": "nodename.PLC4",
"reasons": [
"Hardware has been changed",
"Modules changed",
"Nics have been changed"
]
}
],
"unchanged": [
{
"name": "",
"deviceId": "nodename.Desktop2"
}
],
"unknown": []
}
},
"info": {
"user": "admin",
"origin": "OTbase Inventory 8.01"
}
Comments
0 comments
Please sign in to leave a comment.