Skip to main content

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​

ParameterTypeRequiredDescription
dataSourceTypeStringYesDataSource type, such as MySQL or PostgreSQL.
envIdIntegerYesEnvironment ID. See listEnvironments.
clusterIdIntegerYesExecution cluster ID. See listClusters.
instanceDescStringYesDisplay name, up to 512 characters.
hostStringYesHostname or IP address. Omit port if the address already includes it.
portIntegerNoPort, from 1 to 65535. For the default port, see getDataSourceConfigSpec.
securityTypeStringNoNONE (no authentication), ONLY_USER (username only), USER_PASSWD (username and password). Defaults to USER_PASSWD.
userNameStringConditionally requiredRequired for ONLY_USER or USER_PASSWD.
passwordStringConditionally requiredRequired for USER_PASSWD.

Response fields​

Fields in dataTypeDescription
dataSourceIdIntegerDataSource ID.
instanceIdStringInstance identifier.
lifeCycleStateStringCREATED (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"
}
}