Skip to content

Latest commit

 

History

History
114 lines (78 loc) · 3.21 KB

Create A Site Transaction API.md

File metadata and controls

114 lines (78 loc) · 3.21 KB

Site API Design

POST /V1/CMDB/Sites/Transactions

All site modification operations must be executed in a transaction. In another word, the user should create a transaction before starting any other site changes for example, create site, move devices.

And also, after change site, the user should explicitly commit the operations .

Note that a site transaction will lock the entire NetBrain system for site change operations. To prevent a system-wide dead lock due to client exception or negligence, if no follow-up operations or heartbeat sent within a 30 seconds time frame, another could invalidate this transaction, and create a new transaction which cannot used by the current session.

Deleting a transaction could let the user to discard any site change operations since the beginning of a transaction, or called rollback.

Detail Information

Title : Create a Site Transaction API

Version : 02/01/2019.

API Server URL : http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/V1/CMDB/Sites/Transactions

Authentication :

Type In Name
Bearer Authentication Headers Authentication token

Request body(*required)

No request body.

Parameters(*required)

No parameters required.

Headers

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.

Response

Name Type Description
statusCode integer The returned status code of executing the API.
statusDescription string The explanation of the status code.

Example

{
    "statusCode": 790200,
    "statusDescription": "Success."
}

Full Example:

# import python modules 
import requests
import time
import urllib3
import pprint
import json
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

# Set the request inputs
token = "929b76e4-8a75-4500-9c1b-ee9b7d1c850f"
nb_url = "http://192.168.28.79"
full_url = nb_url + "/ServicesAPI/API/V1/CMDB/Sites/Transactions"
headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
headers["Token"] = token

try:
    response = requests.post(full_url, headers = headers, verify = False)
    if response.status_code == 200:
        result = response.json()
        print (result)
    else:
        print ("Get User Report failed! - " + str(response.text))
    
except Exception as e:
    print (str(e)) 
{'statusCode': 790200, 'statusDescription': 'Success.'}

cURL Code from Postman

curl -X POST \
  http://192.168.28.79/ServicesAPI/API/V1/CMDB/Sites/Transactions \
  -H 'Postman-Token: e2c1075d-013c-40a6-87bf-60d879d46363' \
  -H 'cache-control: no-cache' \
  -H 'token: 3d0f475d-dbae-4c44-9080-7b08ded7d35b'