Modify Data Source
Use this API to update connection information for an existing NineData data source. Modify the name, account, password, connection address, port, environment, SSL settings, and type-specific configuration.
Request URL: /openapi/v1/datasource/update
Request Method: POST
Request Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| datasourceId | String | Yes | Data source ID. Query it by calling the List Data Sources interface. | ds-d92lj22cb03k |
| name | String | No | Modify the name of the data source. | Datasource-updated |
| username | String | No | Modify the login account of the data source. | root |
| password | String | No | Modify the login password of the data source. | root |
| host | String | No | Modify the connection address of the data source. For a MongoDB replica set or sharded cluster, pass a comma-separated string in the host1:port1,host2:port2 format. | 127.0.0.1 |
| port | Integer | No | Modify the port of the data source. Pass null to keep this field unchanged. Do not pass this parameter for a MongoDB replica set or sharded cluster. | 3306 |
| envId | String | No | Modify the environment of the data source. Call the List Environments interface to get envId. | aliyun-cn-hangzhou |
| extraConfig | Object | No | Data-source-specific configuration. The fields you pass are incrementally merged into the existing configuration, so pass only fields to change. | {"readPreference":"primary"} |
| sslConfig | Object | No | SSL configuration. Currently supported only for MySQL, SQLServer, and PostgreSQL. Do not pass this parameter for MongoDB. | {"securityConfig":"PREFERRED"} |
| multiTag | String | No | Multi-active mark. | active |
MongoDB Update Notes
- Fields in
extraConfigare incrementally merged into the existing configuration. Fields that are not passed remain unchanged. - If
mongoDBDeploymentTypecontains an invalid value, the API validates and rejects the request. - When
hostis updated, the API verifies that each node is DNS-resolvable.
SSL Configuration Parameters
Only MySQL, SQLServer, and PostgreSQL data sources support sslConfig. Supported fields vary by data source type.
| Parameter | Type | Required | Applicable Data Sources | Description | Example |
|---|---|---|---|---|---|
| securityConfig | String | No | MySQL, PostgreSQL | SSL security mode. MySQL values: REQUIRED, PREFERRED; PostgreSQL values: Prefer, Require, Verify-CA, Verify-Full. | PREFERRED |
| sslCipher | String | No | MySQL | SSL cipher suite. | TLS_AES_256_GCM_SHA384 |
| sslCA | String | No | MySQL, SQLServer, PostgreSQL | CA certificate content. | -----BEGIN CERTIFICATE----- |
| sslCAFileName | String | No | MySQL, SQLServer, PostgreSQL | CA certificate file name. | ca.pem |
| sslClientCert | String | No | MySQL, PostgreSQL | Client certificate content. | -----BEGIN CERTIFICATE----- |
| sslClientCertFileName | String | No | MySQL, PostgreSQL | Client certificate file name. | client-cert.pem |
| sslClientKey | String | No | MySQL, PostgreSQL | Client private key content. | -----BEGIN PRIVATE KEY----- |
| sslClientKeyFileName | String | No | MySQL, PostgreSQL | Client private key file name. | client-key.pem |
| sslIndentify | Boolean | No | MySQL | Whether to verify the server identity. Use the field name sslIndentify as required by the API. | false |
| hostNameInCertificate | String | No | SQLServer | Host name in the server certificate. | db.example.com |
| trustServerCertificate | Boolean | No | SQLServer | Whether to trust the server certificate. | false |
Request Example
Update MongoDB read preference:
{
"datasourceId": "ds-d92lj22cb03k",
"name": "renamed-mongo",
"extraConfig": {
"readPreference": "primary"
}
}
Update MySQL SSL configuration and multi-active mark:
{
"datasourceId": "ds-d92lj22cb03k",
"sslConfig": {
"securityConfig": "PREFERRED",
"sslIndentify": false
},
"multiTag": "active"
}
Response Parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
| success | Bool | Whether the interface call is successful. Return values: true, false. | true |
| requestId | String | Request ID. | Iq0s6SPI-HNKKaLTnINGt1JEdOLc7DSH |
| data | Array | Data source update details, including whether the update is successful (success). Return values: true, false. | { "success": true } |
Successful Call Example
{
"success": true,
"requestId": "Iq0s6SPI-HNKKaLTnINGt1JEdOLc7DSH",
"data": {
"success": true
}
}
Result
A successful response returns true in data.success, which means the update request was accepted. Query the data source list afterward to confirm the latest connection metadata.