Datasource API
Obtain information about the Datasource and execute SQL against the database to which it is connected.
Common parameters
% curl -X POST -H 'content-type: application/json' -d '{"accesskey":"<accesskey>", "secret":"secretkey", "component":"storage", "action":"<action>" ... }' https://<endpoint url>
Parameters
accesskey : Access key
secet:Secret key
component : storage
action : action to execute
endpoint url : URL to send API requests
% curl -X POST -d "{\"accesskey\":\"<accesskey>\", \"secret\":\"<secretkey>\", \"component\":\"function\", \"action\":\"<action>\" ...}" https://<endpoint url>
Note :
When using curl commands under Windows, use only double quotes and escape within JSON data, as in the example at left.
Obtaining a list of datasources
% curl -X POST -d '{"accesskey":"<accesskey>", "secret":"<secretkey>", "component":"datasource", "action":"list"}' https://<endpoint url> | jq
{
"data": [
{
"description": "description1",
"name": "as1",
"registeredAt": "2024-09-03T05:30:18.188Z",
"type": "as",
"value": "as://data1"
},
...
],
"status": "success"
}
Parameters
action : list
Return value
data : List of datasources
Obtaining a list of datasources (with conditions)
% curl -X POST -d '{"accesskey":"<accesskey>", "secret":"<secretkey>", "component":"datasource", "action":"list", "datasource":"orcl", "type":"oc"}' https://<endpoint url> | jq
{
"data": [
{
"description": "Oracle database",
"name": "orcl",
"registeredAt": "2024-09-03T05:30:18.188Z",
"type": "oc",
"value": "<hostname>:1521/orcl"
}
],
"status": "success"
}
Parameters
action : list
datasource : Datasource name
type : Type of datasource
Return value
data : List of datasources
Confirmation of Connection to Database
You can check the availability of the connection from ADP to the database to which you are connecting.
% curl -X POST -d '{"accesskey":"<accesskey>", "secret":"<secretkey>", "component":"datasource", "action":"connect", "datasource":"orcl"}' https://<endpoint url> | jq
{
"data": {
"host": "<hostname>",
"name": "orcl",
"port": "1521",
"service": "orcl",
"type": "oc",
"uname": "admin",
"value": "<hostname>:1521/orcl"
},
"status": "success"
}
Parameters
action : connect
datasource : Datasource name
Return value
data : Details of the datasource
SQL Execution (DDL)
% curl -X POST -d '{"accesskey":"<accesskey>", "secret":"<secretkey>", "component":"datasource", "action":"execute", "datasource":"orcl", "statement":"create table simple(id varchar2(64), num number, dt date)"}' https://<endpoint url> | jq
Parameters
action : execute
datasource : Datasource name
statement : DDL statement
Return value
Execution status of DDL statement
SQL Execution (DML)
% curl -X POST -d '{"accesskey":"<accesskey>", "secret":"<secretkey>", "component":"datasource", "action":"execute", "datasource":"orcl", "statement":"insert into simple values (:1, :2, :3)", "args": ["abcde", 1, "2024/11/12 13:22:00"], "session":{"NLS_DATE_FORMAT":"YYYY/MM/DD HH24:MI:SS"}}' https://<endpoint url> | jq
Parameters
action : execute
datasource : Datasource name
statement : DML statement
Options
args : Binding variables
session : Parameters that affect the database session
NLS_DATE_FORMAT : Date format when inserting or updating data in Oracle
Return value
Execution status of DML statement
SQL Execution (SELECT)
% curl -X POST -d '{"accesskey":"<accesskey>", "secret":"<secretkey>", "component":"datasource", "action":"execute", "datasource":"orcl", "query":"select * from employees","session":{"DATE_FORMAT":"2006-01-02"}}' https://<endpoint url> | jq
{
"data": [
[
"EMPLOYEE_ID",
"FIRST_NAME",
"LAST_NAME",
"EMAIL",
"HIRE_DATE",
"JOB_ID",
"SALARY",
"MANAGER_ID",
"DEPARTMENT_ID"
],
[
"e366",
"Amanda",
"Maldonado",
"amanda.maldonado@example.com",
"2023-01-09",
"IT_PROG",
"73498.98",
"73",
"30"
],
...
"status": "success"
}
Parameters
action : execute
datasource : Datasource name
query : SELECT statement
Options
args : Binding variables
session : Parameters that affect the database session
DATE_FORMAT : Date format for data extraction
Return value
data : List of records extracted by SELECT statement