Data Source API
This article provides sample API calls for Data Sources in Metric Insights.
You can use the following Item functions:
- data_source (to fetch a list of Data Sources and their metadata)
- data_source_sql (to create, delete, edit SQL Data Sources and obtain a list of SQL Data Sources)
- data_source_plugin (to obtain a list of Plugin Data Sources)
- data_source_parameter (to query Parameters used for a particular Plugin Data Source)
- data_source_external_report (to obtain a list of External Reports for a particular Plugin Data Source)
PREREQUISITES:
- Set up API access
- Verify that you have API access
- Obtain a token via a get token call since all API calls require a token
- Token: enter the Token that you have previously obtained as noted in the PREREQUISITES
- Item: from the dropdown, select data_source_sql
- Methods: GET
- Run request: click to get a list of all SQL Data Sources and their metadata
Raw response will contain information about SQL Data Sources in Metric Insights.
- Token: enter the Token that you have previously obtained as noted in the PREREQUISITES
- Item: from the dropdown, select data_source_plugin
- Methods: GET
- Run request: click to get a list of all Plugin Data Sources and their metadata
Raw response will contain information about Plugin Data Sources in Metric Insights.
1. Create a Data Source (applicable to SQL Data Sources)
You can use any of the available Data Sources as a model for a new Data Source.
The example provided below shows how create a new Data Source from an existing Data Source.
Currently creating and editing options are supported for SQL Data Sources only.
- Token: enter the Token that you have previously obtained as noted in the PREREQUISITES
- Item: select data_source_sql
- Methods: choose POST
-
ID: input the ID of an existing Data Source that will be used to build a new Data Source
- After you input the Data Source ID, the Request field will display the settings for that Data Source
-
Request:
- If you want to make a copy of an existing Data Source, input a meaningful Name and Password and keep the rest of the settings as they are
- In case you want to use an existing Data Source as a model and query data from your own database, additionally input connection parameters that are relevant to you
- Run request: click to create a new Data SourceAsok
Raw response will contain the new Data Source settings.
The newly created Data Source will be assigned an ID that can be used to Test Connection during a subsequent API call.
2. Test Connection (applicable to SQL Data Sources)
- Token: enter the Token that you have previously obtained as noted in the PREREQUISITES
- Item: select data_source_sql
- Methods: PUT is used
- ID: input the ID of the Data Source whose connection will be tested
- Actions: from the dropdown, select Test Connection
- Run request: click to run the API action call
If the call is successful, the Raw response will display "status: OK" message
3. Obtain a list of Data Source Parameters (applicable to Plugin Data Sources)
- Token: enter the Token that you have previously obtained as noted in the PREREQUISITES
- Item: select data_source_parameter
- Methods: GET is used
- Profile: input the ID of the Data Source (connection profile) whose connection will be tested
- Run request: click to query a list of Data Source Parameters
Raw response will contain information about Parameters for the specified Data Source.
4. Query a list of External Reports (applicable to Plugin Data Sources)
- Token: enter the Token that you have previously obtained as noted in the PREREQUISITES
- Item: select data_source_external_report
- Methods: GET is used
- Profile: input the ID of the Data Source (connection profile) whose connection will be tested
- Run request: click to query a list of External Reports (Data Source Objects)
Raw response will contain information about External Reports for that Data Source.
5. Refresh List (applicable to Plugin Data Sources)
- Token: enter the Token that you have previously obtained as noted in the PREREQUISITES
- Item: select data_source_plugin
- Methods: PUT is used
- Actions: select Refresh List
- Run request: click to make an API action call
If the call is successful, the Raw response field will be empty. Otherwise, an error message will be displayed.