Skip to content

Latest commit

 

History

History
205 lines (165 loc) · 6.04 KB

Create Dynamic Search in Site API.md

File metadata and controls

205 lines (165 loc) · 6.04 KB

Create Dynamic Search API Design

PUT /V1/CMDB/Sites/Leaf/DynamicSearch

Call this API to create dynamic search in NetBrain Domain Management - Site Manager.

Detail Information

Title : Create Dynamic Search API

Version : 03/08/2024

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

Authentication :

Type In Name
Bearer Authentication Headers Authentication token

Request body(*required)

Name Type Description
sitesId^ string TThe unique id of specified site. Need either or of siteId and sitePath.
sitePath^ string Full path name of a site. e.g. 'My Network/Site1/Boston'.
filter string This string will include all parameters selected such as Device Property, Interface Property, Module Property, Config File, and Front Server, and their respective parameters.
filter.expression string e.g. A and B and C
filter.conditions array
filter.conditions.schema string Schema name
filter.conditions.operator integer
Operator Operator int value Schema Type Schema
Matches any 0 Select mainType
subType
Does not match any 1
Contains 4 String
Does not match5
Matches0
Does not contain 1
Matches 0 IP or Int
iploc
mgmtip
ips
ipv6
proxyserver
externalservers.externalserverid
Does not match any 1
is0Bool
filter.conditions.expression string
filter.conditions.fieldType^ integer String = 0, Double = 1, Boolean = 2,

Example

{
  sitePath : "My Network/Unnamed-site1"
  filter : {
          "expression": "A and (b and C)",
          "conditions": [
              {
                  "schema": "subType",
                  "operator": 0,
                  "expression": "rootType"
              },
              {
                  "schema": "intfs.speed",
                  "operator": 4,
                  "expression": "1"
              },
              {
                  "expression": "False",
                  "operator": 0,
                  "schema": "hasEIGRPConfig",
                  "fieldType": 2
              }
          ]
      }
}

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 = '684c4e42-833a-428d-a5c9-3f047f3d3a67'
nb_url = "http://192.168.31.191"
full_url = nb_url + "/ServicesAPI/API/V1/CMDB/Sites/Leaf/DynamicSearch"
headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
headers["Token"] = token
 
{
  sitePath : "My Network/Unnamed-site1"
  filter : {
          "expression": "A and (b and C)",
          "conditions": [
              {
                  "schema": "subType",
                  "operator": 0,
                  "expression": "rootType"
              },
              {
                  "schema": "intfs.speed",
                  "operator": 4,
                  "expression": "1"
              },
              {
                  "expression": "False",
                  "operator": 0,
                  "schema": "hasEIGRPConfig",
                  "fieldType": 2
              }
          ]
      }
}

body = {
    "sitePath": sitePath,
    "filter" : filter
}
 
try:
    response = requests.put(full_url, json.dumps(body), headers=headers, verify=False)
    print(response)
    if response.status_code == 200:
        result = response.json()
        print (result)
    else:
        print ("Failed to create dynamic search - " + str(response.text))

except Exception as e:
    print (str(e)) 
{'statusCode': 790200, 'statusDescription': 'Success.'}

cURL Code from Postman:

curl -X PUT \
  http://192.168.31.191/ServicesAPI/API/V1/CMDB/Sites/Leaf/DynamicSearch \
  -H "Content-Type: application/json"
  -H 'token: db4363c3-2f5f-47da-bfc8-2d14b6992558' \
  -d '{
    "sitePath": "My Network/Unnamed-site1",
    "filter" : {
        "expression": "A and (b and C)",
        "conditions": [
            {
                "schema": "subType",
                "operator": 0,
                "expression": "rootType"
            },
            {
                "schema": "intfs.speed",
                "operator": 4,
                "expression": "1"
            },
            {
                "expression": "False",
                "operator": 0,
                "schema": "hasEIGRPConfig",
                "fieldType": 2
            }
        ]
    }
}'