Calling this API to assign users and roles to a specified Domain.
Title : Remove Users from Domain API
Version : 02/05/2019.
API Server URL : http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/V1/CMDB/Domains/Users
Authentication :
Type | In | Name |
---|---|---|
Bearer Authentication | Headers | Authentication token |
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 | The returned status code of executing the API. |
statusDescription | string | The explanation of the status code. |
Example
{
"statusCode": 790200,
"statusDescription": "string",
}
# import python modules
import requests
import time
import urllib3
import pprint
import json
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# Set the request inputs
token = "220d6462-ba64-4058-83cb-affb2d55de78"
nb_url = "http://192.168.28.79"
full_url = nb_url + "/ServicesAPI/API/V1/CMDB/Domains/Users"
headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
headers["Token"] = token
domainId = "bcae6de1-55b3-45c2-9dbd-ced9bf14b1e0"
users = [ "gdluserTest"]
body = {
"domainId": domainId,
"users": users
}
try:
response = requests.put(full_url, data = json.dumps(body), headers = headers, verify = False)
if response.status_code == 200:
result = response.json()
print (result)
else:
print ("Delete users from domain failed! - " + str(response.text))
except Exception as e:
print (str(e))
{'statusCode': 790200, 'statusDescription': 'Success.'}
curl -X PUT \
http://192.168.28.79/ServicesAPI/API/V1/CMDB/Domains/Users \
-H 'Content-Type: application/json' \
-H 'Postman-Token: 0ee44c87-143a-4eaf-8c96-e5a79e6a14a2' \
-H 'cache-control: no-cache' \
-H 'token: 4b78f855-6515-4c1f-b4ae-408bfdedcfad' \
-d '{
"domainId": "bcae6de1-55b3-45c2-9dbd-ced9bf14b1e0",
"users": [ "gongdaiAdmin"]
}'
###################################################################################################################
"""Error 1: empty inputs"""
Input:
domainId = "" # Can not be null
users = [""] # Can not be null
Response:
"Delete users from domain failed! -
{
"statusCode":791000,
"statusDescription":"Null parameter: the parameter 'users' cannot be null."
}"
###################################################################################################################
"""Error 1: wrong privilege user role"""
Input:
domainId = "9f43080f-d502-4ddb-9c76-006c3ef665ad"
users = ["gdluserTest"] # user as a tenant admin of current tenant or system admin.
Response:
"Delete users from domain failed! -
{
"statusCode":794011,
"statusDescription":"Operation failed. Reason:
"A user with system or tenant admin permissions is contained in the user list."
}"