How Can We Help?

< All Topics

Lucidum API Manual

1. Lucidum APIs

1.1 API Access Token Generation

There are two types of tokens to access the Lucidum API. Users will need to generate either one of them for the programmatic API access.

  • Basic authorization with Client ID and Secret: Users can generate the Client ID and Secret by clicking the “edit” user link under the “User Management” page then clicking the “Generate ClientID/Secret” button. The Client ID and secret will expire in 30 days or after a system restart, whichever is earlier.

  • Permanent API token: Users can generate the permanent API token by clicking the “Generate Token” on the same page. The token will not expire unless it is re-generated by the user. This token can be used directly in the API request header, for example, “Authorization: Bearer {token}”.

1.2 Web API 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.

Lucidum also provides a Swagger API interface so users can quickly access and test the API requests. The Swagger API URL is:

https://{LUCIDUM_HOST}/CMDB/swagger-ui/index.html#!/Lucidum32API/cmdbUsingPOST

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 different from the operators on the Explore page as the API interface is implemented in a different way. Also, all values used in the API call are case sensitive.
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

1.3 Lab API Query

Lucidum also provides API access for the Lab tables. Users can use the Lab API to find the file upload histories, compare two file uploads, and save the comparison results.

API for querying file upload history under a single Lab table

Below is an example of this API call:

Endpoint: /CMDB/api/upload/customer/collection_history

REST method: GET

Request body:

{

    “sort”:”__lucidum__uploadtime__, asc”,

    “tableName”: “_TableName_”

}

  • Sort: Upload history sorting order
  • TableName: Lab table name with the file upload history

Below is an example of the API response:

{

    “content”: [{

        “_id”: “5f68cbf1adf81c00016d5a75”,

        “__lucidum__uploadtime__”: 1600703472,

        “table_name”: “MyCSVTable”,

        “model”: “create”,

        “creator”: “admin”,

        “file_name”: “user1_table.csv”,

        “table_description”: “MyCSVTable”,

        “upload_remark”: “upload user1_table”,

        “version”: 1.0,

        “upload_id”: 61

    }, {

        “_id”: “5f68cc49adf81c00016d5a7c”,

        “__lucidum__uploadtime__”: 1600703561,

        “table_name”: “MyCSVTable”,

        “model”: “updateAppend”,

        “creator”: “admin”,

        “file_name”: “user2_table.csv”,

        “table_description”: “MyCSVTable”,

        “upload_remark”: “1600703561#user2_table.csv”,

        “version”: 2.0,

        “upload_id”: 62

    }]

API for comparing file upload histories and getting comparison results

Below is an example of this API call. The API response includes the comparison results, which can be saved as an Excel spreadsheet if needed.

Endpoint: /CMDB/api/upload/customer/collection_history/export?params=

REST method: GET

Request body: none

params: URL encoded string of json as following

{

    compareModel: “ALL”

    firstId: “first upload id”

    lastId: “last upload id”

    groupBys: {

        “field1”: “field2”

    }

}

  • CompareModel: Comparison filter. Valid values are “ALL” (including all records in comparison), “DELETED” (including records not from lastId only), “MODIFIED” (including records changed from lastId only), and “ADDED” (including new records from lastId only)
  • FirstId: First file upload history (as the base for comparison)
  • LastId: Second file upload history
  • GroupBys: field1 is the “Compared by” field from the first file upload, and field2 is the “Compared by” field from the second file upload, which are the internal keys to link these two file uploads
Next Lucidum Installation Manual
Table of Contents