CMDBQueryBuilderAPI - Global

  • Release version: Washingtondc
  • Updated February 1, 2024
  • 1 minute to read
  • The CMDBQueryBuilderAPI provides methods to retrieve Query Builder saved query execution details in server-side scripts.

    To access this API you must activate the Configuration Management (CMDB) (com.snc.cmdb) plugin.

    For more information on the CMBD Query Builder, see Querying the CMDB.

    CMDBQueryBuilderAPI - getSavedQueryExecutionDetails(String savedQueryName, Boolean executeQuery, Number timeout)

    Returns the execution details for a specified Configuration Management Database (CMDB) Query Builder saved query.

    Optionally you can specify whether to execute the query or not, in order to return its most recent query execution details. You can also override the default timeout limit for the execution of the query.

    In the event of a timeout or memory issue while executing the query, you can fine tune the query batch size to help alleviate these problems. For additional information, see Batch size for Query Builder saved queries.

    Table 1. Parameters
    Name Type Description
    executeQuery Boolean Optional. Flag that indicates whether to execute the specified query or not.

    Valid values:

    • true: Execute the specified query and return its execution details.
    • false: Do not execute the specified query. Return the most recent execution details of the query.

    Default: False

    savedQueryName String Name of the CMDB Query Builder saved query for which to return query execution details.
    timeout Number Optional. Integer value that overrides the default query execution timeout limit of five minutes.

    Unit: Seconds

    Default: Five minutes

    Table 2. Returns
    Type Description
    Error Error code and message. Returned when the query execution fails or the specified query is not found.

    Error examples:

    • {"error": "QUERY_EXECUTION_NOT_FOUND", "message": "Query execution details not found. Please execute the query."}
    • {"error": "QUERY_NOT_FOUND", "message": "Given saved query not found. Please make sure you are passing the name of a saved query."}
    • {"error": "QUERY_EXECUTION_FAILED", "message": "Query execution failed. Please use a valid query."}
    query_id Saved query Execution ID (sys_id). Obtained from the Query Status [qb_query_status] table.
    table_name Name of the table that contains the execution query details.
    status Status of the query execution.
    • COMPLETE: Execution is complete.
    • FAILED: Error occurred while executing query.
    • TIME_OUT: Query execution timed out.
    • MAX_LIMIT: Maximum number of return results reached.

    This example shows how to call the getSavedQueryExecutionDetails() method.

    SNC.CMDBQueryBuilderAPI.getSavedQueryExecutionDetails('Test', true);
    

    Output:

    {"query_id":"024fd53a7773330033b5270bba106141",
    "table_name":"u_cmdb_qb_result_598918aacb4dbf3f1a8dcf03fce6a5d57151a4e2",
    "status":COMPLETE}

    This example shows how to call the getSavedQueryExecutionDetails() method and override the default query execution timeout value to 10 minutes.

    SNC.CMDBQueryBuilderAPI.getSavedQueryExecutionDetails('Test', true, 600);
    

    Output:

    {"query_id":"024fd53a7773330033b5270bba106141",
    "table_name":"u_cmdb_qb_result_598918aacb4dbf3f1a8dcf03fce6a5d57151a4e2",
    "status":COMPLETE}