Register a DataSource
Register a DataSource.
POST /api/open/v1/datasource/createDataSource
Requires the “DataSource Manage” permission.
Send the Idempotency-Key header with 1 to 128 visible ASCII characters.
Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| dataSourceType | String | Yes | DataSource type, such as MySQL or PostgreSQL. |
| envId | Integer | Yes | Environment ID. See listEnvironments. |
| clusterId | Integer | Yes | Execution cluster ID. See listClusters. |
| instanceDesc | String | Yes | Display name, up to 512 characters. |
| host | String | Yes | Hostname or IP address. Omit port if the address already includes it. |
| port | Integer | No | Port, from 1 to 65535. For the default port, see getDataSourceConfigSpec. |
| securityType | String | No | NONE (no authentication), ONLY_USER (username only), USER_PASSWD (username and password). Defaults to USER_PASSWD. |
| userName | String | Conditionally required | Required for ONLY_USER or USER_PASSWD. |
| password | String | Conditionally required | Required for USER_PASSWD. |
Response fields
| Fields in data | Type | Description |
|---|---|---|
| dataSourceId | Integer | DataSource ID. |
| instanceId | String | Instance identifier. |
| lifeCycleState | String | CREATED (registered). |
Request example (MySQL)
{
"dataSourceType": "MySQL",
"envId": 3,
"clusterId": 5,
"instanceDesc": "Sales database",
"host": "sales-db.example.test",
"port": 3306,
"securityType": "USER_PASSWD",
"userName": "sales_reader",
"password": "${DATABASE_PASSWORD}"
}
Response example
{
"requestId": "db26cfe3-8c32-548c-8f41-c15504785fbf",
"code": "OK",
"msg": "Request succeeded.",
"data": {
"dataSourceId": 42,
"instanceId": "my-5samk76gx9hj2tr",
"lifeCycleState": "CREATED"
}
}