This API call is used to add a benchmark task to a domain.
Note that, as the key, task name should be unique system wide.
The option for data to be retrieved in this task is 'Built-in Live Data' which the user can see from UI.
Title : Add Benchmark Task API
Version : 01/24/2019.
API Server URL : http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/V1/CMDB/Benchmark/Tasks
Authentication :
Type | In | Name |
---|---|---|
Bearer Authentication | Headers | Authentication token |
body = {
"taskName":taskName, #The name of the task.
"startDate":startDate, #The date when the task starts to run. The standard time format is required, for example, '2017-07-13', '2017/07/13'.
"schedule":{
"frequency":frequency, #The frequency to run the task. This field is required and includes ”once”, “hourly”,” daily”, “weekly” and “monthly” options.
"startTime":[startTime] #The time to run the task. This field is required and startTime should be in format: ["HH:mm:ss"], if you put date time format such as "2018/04/04 19:20:20 ", "19:20:20" will be used and the date part "2018/04/04" will be ignored.
},
"deviceScope" : {
"scopeType" : scopeType
}
}
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 | Code issued by NetBrain server indicating the execution result. |
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 = "dbd4e523-5964-4c2d-ba8f-da018cfb6299"
nb_url = "http://192.168.28.79"
taskName = "Scheduled System DiscoveryGDL11"
startDate = "2019-01-16"
frequency = "once"
startTime = "14:40:20"
scopeType = "all"
# Add a new Benchmark
full_url = nb_url + "/ServicesAPI/API/V1/CMDB/Benchmark/Tasks"
headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
headers["Token"] = token
body = {
"taskName":taskName,
"startDate":startDate,
"schedule":{
"frequency":frequency,
"startTime":[startTime]
},
"deviceScope" : {
"scopeType" : scopeType
}
}
try:
response = requests.post(full_url, data=json.dumps(body), headers=headers, verify=False)
if response.status_code == 200:
result = response.json()
print (result)
else:
print ("Benchmark Task added Failed! - " + str(response.text))
except Exception as e:
print (str(e))
{'statusCode': 790200, 'statusDescription': 'Success.'}
curl -X POST \
http://192.168.28.79/ServicesAPI/API/V1/CMDB/Benchmark/Tasks \
-H 'Content-Type: application/json' \
-H 'Postman-Token: a6b7d2b7-f331-4418-bcc0-d1a90f01dbd8' \
-H 'Token: c00de805-9210-44a9-9a26-f0c1e944ea36' \
-H 'cache-control: no-cache' \
-d 'body = {
"taskName":"Scheduled System DiscoveryGDL1",
"startDate":"2019-01-16",
"schedule":{
"frequency":"once",
"startTime":["14:40:20"]
},
"deviceScope" : {
"scopeType" : "all"
}
}'
###################################################################################################################
"""Error 1: empty taskName"""
Input:
taskName = ""
startDate = "2019-01-16"
frequency = "once"
startTime = "14:40:20"
scopeType = "all"
Response:
"Benchmark Task added Failed! -
{
"statusCode":791000,
"statusDescription":"Null parameter: the parameter 'taskName' cannot be null."
}"
###################################################################################################################
"""Error 2: tesk name duplicated"""
Input:
taskName = "Scheduled System Discovery" #Benchmark with task name "Scheduled System Discovery" already exist in system.
startDate = "2019-01-16"
frequency = "once"
startTime = "14:40:20"
scopeType = "all"
Response:
"Benchmark Task added Failed! -
{
"statusCode":791007,
"statusDescription":"Benchmark task with name Scheduled System Discovery already exists."
}"
###################################################################################################################
"""Error 1: empty startData"""
Input:
taskName = "Scheduled System DiscoveryGDL"
startDate = ""
frequency = "once"
startTime = "14:40:20"
scopeType = "all"
Response:
"Benchmark Task added Failed! -
{
"statusCode":791000,
"statusDescription":"Null parameter: the parameter 'startDate' cannot be null."
}"
###################################################################################################################
"""Error 1: wrong startData format"""
Input:
taskName = "Scheduled System DiscoveryGDL"
startDate = "20190116"
frequency = "once"
startTime = "14:40:20"
scopeType = "all"
Response:
"Benchmark Task added Failed! -
{
"statusCode":791000,
"statusDescription":"Null parameter: the parameter 'startDate' cannot be null."
}"
###################################################################################################################
"""Error 1: empty frequency"""
Input:
taskName = "Scheduled System DiscoveryGDL"
startDate = "2019-01-16"
frequency = ""
startTime = "14:40:20"
scopeType = "all"
Response:
"Benchmark Task added Failed! -
{
"statusCode":791000,
"statusDescription":"Null parameter: the parameter 'schedule frequency' cannot be null."
}"
###################################################################################################################
"""Error 1: wrong frequency input"""
Input:
taskName = "Scheduled System DiscoveryGDL"
startDate = "2019-01-16"
frequency = "1"
startTime = "14:40:20"
scopeType = "all"
Response:
"Benchmark Task added Failed! -
{
"statusCode":791001,
"statusDescription":"Invalid parameter: the parameter 'schedule.frequency' is invalid.
"Options: once, hourly, daily, weekly, monthly "
}"
###################################################################################################################
"""Error 1: empty startTime"""
Input:
taskName = "Scheduled System DiscoveryGDL"
startDate = "2019-01-16"
frequency = "once"
startTime = ""
scopeType = "all"
Response:
"Benchmark Task added Failed! -
{
"statusCode":791000,
"statusDescription":"Null parameter: the parameter 'schedule startTime' cannot be null."
}"
###################################################################################################################
"""Error 1: wrong format startTime"""
Input:
taskName = "Scheduled System DiscoveryGDL"
startDate = "2019-01-16"
frequency = "once"
startTime = "14/40/20"
scopeType = "all"
Response:
"Benchmark Task added Failed! -
{
"statusCode":791000,
"statusDescription":"Null parameter: the parameter 'schedule startTime' cannot be null."
}"
###################################################################################################################
"""Error 1: empty scopeType"""
Input:
taskName = "Scheduled System DiscoveryGDL"
startDate = "2019-01-16"
frequency = "once"
startTime = "14:40:20"
scopeType = ""
Response:
"Benchmark Task added Failed! -
{
"statusCode":792009,
"statusDescription":"Invalid data type. deviceScope.scopeType, options: all,deviceGroup,site"
}"
###################################################################################################################
"""Error 1: wrong scopeType input"""
Input:
taskName = "Scheduled System DiscoveryGDL"
startDate = "2019-01-16"
frequency = "once"
startTime = "14:40:20"
scopeType = "whole"
Response:
"Benchmark Task added Failed! -
{
"statusCode":792009,
"statusDescription":"Invalid data type. deviceScope.scopeType, options: all,deviceGroup,site"
}"