Skip to content

Latest commit

 

History

History
113 lines (77 loc) · 2.91 KB

Remove Site Transaction API.md

File metadata and controls

113 lines (77 loc) · 2.91 KB

Site API Design

DELETE /V1/CMDB/Sites/Transactions

This API is used to remove an existing transaction. Note that you need to commit the transaction before calling this API, all uncommitted operations would be lost after delete the transaction.

This API can also be used for rollback purpose.

Removing a site transaction is not necessary since a transaction would automatcially times out after 30 seconds. However, by doing this, you can give the site control back to the system explicitly within 30 seconds.

Detail Information

Title : Remove 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 = "3d0f475d-dbae-4c44-9080-7b08ded7d35b"
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.delete(full_url, headers = headers, verify = False)
    if response.status_code == 200:
        result = response.json()
        print (result)
    else:
        print ("Site transaction remove Failed! - " + str(response.text))
    
except Exception as e:
    print (str(e)) 
{'statusCode': 790200, 'statusDescription': 'Success.'}

cURL Code from Postman:

curl -X DELETE \
  http://192.168.28.79/ServicesAPI/API/V1/CMDB/Sites/Transactions \
  -H 'Postman-Token: 58f69351-b49e-4223-95b0-9fed3c108cc1' \
  -H 'cache-control: no-cache' \
  -H 'token: 3d0f475d-dbae-4c44-9080-7b08ded7d35b'