Use this API to send a third party system event data to NetBrain.
Title : Auto Trigger API
Version : 01/31/2022
API Server URL : http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/V1/TAF/Auto
Authentication :
Type | In | Name |
---|---|---|
Bearer Authentication | Headers | Authentication token |
No query parameter
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. |
import json
import requests
import requests.packages.urllib3 as urllib3
urllib3.disable_warnings()
def getTokens(endpoint, user,password):
login_api_url = r"/V1/Session"
Login_url = endpoint + login_api_url
data = {
"username": user,
"password": password
}
token = requests.post(Login_url, data=json.dumps(
data), headers=headers, verify=False)
if token.status_code == 200:
# print(token.json())
return token.json()["token"]
else:
return "error"
def PublishEvent(endpoint, API_Body):
API_URL = r"/V1/TAF/Auto"
api_full_url = endpoint + API_URL
try:
api_result = requests.post(api_full_url, data=json.dumps(API_Body), headers=headers, verify=False)
if api_result.status_code == 200:
return api_result.json()
else:
return api_result.json()
except Exception as e:
return str(e)
nb_endpoint = "https://netbraintech.com/ServicesAPI/API"
nb_username = ""
nb_password = ""
tenantId = ""
domainId = ""
source = "Python Sample"
specificData = {
"hostname":"US-BOS-R1",
"status":"rebooted"
}
api_body = {
"specificData":specificData,
"option": {
"scope":"Demo",
"source":"https://notapplicable.com",
"category":"Event"
}
}
headers = {
"Accepted":"application/json",
"Content-Type":"application/json"
}
token = getTokens(nb_endpoint, nb_username, nb_password)
headers["token"] = token
print(PublishEvent(nb_endpoint, api_body))
{'incidentId': '10017G', 'incidentUrl': 'i.html?id=10017G', 'incidentPortalUrl': 'i/10017G', 'taskId': 'f21e2e16-3bcb-4770-aa8f-9d9d0456882c', 'statusCode': 790200, 'statusDescription': 'Success.'}
{
"incidentId": "100033",
"incidentUrl": "i.html?id=100033",
"incidentPortalUrl": "i/100033",
"taskId": "5c8930f8-c5c4-4645-94b9-d0f1a4c80a76",
"statusCode": 790200,
"statusDescription": "Success."
}