API-Based Query

Users can access the Lucidum main database programmatically through API. Currently, Lucidum UI limits API access to no more than 10 queries per minute to avoid negative impacts on the system. Below is an API request example:

 

Endpoint: /CMDB/v1/data/cmdb

REST method: POST

Request body:

{

“collectionName”: “AWS_CMDB_Output”,

“outputFields”: [ “CPU_Cores”, “sourcetype”],

“filter”: [

{

“field”: “CPU_Cores”,

“operator”: “=”,

“value”: “4”

}

],

“page”: {

“currentPage”: 1,

“itemPerPage”: 25

}

}

 

User can change the parameter values below as needed:

  • CollectionName: Lucidum database target table name
  • OutputFields: The field list to be included in the API response. If outputFields is set as an empty list, all data fields from the target table will be returned.
  • Filter: The record filters on the API response. If the filter is set as an empty list, all records from the target table will be returned. More information on filter operators and examples on different field types is listed below. Note that the operators used in the API call are slightly different from the operators on the Explore page.

 

Field type Supported operator Example
Number >, <, =, >=, <=, != {“field”: “CPU_Cores”,

“operator”: “>=”,

“value”: 4}

Number in {“field”: “CPU_Cores”,

“operator”: “in”,

“value”: [4,8,16]}

String = {“field”: “Asset_Name”,

“operator”: “=”,

“value”: “ec2-1324”}

String like {“field”: “Asset_Name”,

“operator”: “like”,

“value”: “%abc%”}

String in {“field”: “Asset_Name”,

“operator”: “in”,

“value”: [“ec2-123”, “ec2-456”]}

Boolean = {“field”: “Is_Virtual”,

“operator”: “=”,

“value”: true}

List contains {“field”: “List_Users”,

“operator”: “contains”,

“value”: [“user1”, “user2”]}

List not contains {“field”: “List_Users”,

“operator”: “not contains”,

“value”: [“user1”, “user2”]}

 

Below is an API response example:

 

Response Body:

{

“code”: 200,

“data”: [

{

“_id”: “5cf5db6ccaf94c7fc261c08c”,

“CPU_Cores”: 8,

“sourcetype”: [

“AWS_EC2”

]

}

],

“page”: {

“currentPage”: 1,

“itemPerPage”: 25,

“totalPage”: 1,

“totalCount”: 1

}

}

 

The table below lists some API response codes as a reference:

 

Response Code Description
201 Created
401 Unauthorized
403 Forbidden
404 Not Found
400001 Invalid numeric operator
400002 Invalid string operator
400003 Invalid boolean operator
400004 Invalid list operator
400005 Invalid data operator
400006 Invalid page number
400007 Invalid item per page
401001 Invalid token
401002 Invalid collection name
401003 Invalid output field

Leave a Reply

Your email address will not be published. Required fields are marked *