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 | Login account to update. Omit it to keep the current value. When supplied, it must meet the create API account conditions. | root |
| password | String | No | Login password to update. Omit it to keep the current value. When supplied, it has the same conditions as username. | 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 |
| regionId | String | No | Update the data source region. | cn-hangzhou |
| networkType | String | No | Update the connection method. Values: public, gateway, ssh, and private. | public |
| masterName | String | No | Update the primary node name. | master-1 |
| hostAndPorts | String | No | Update comma-separated multi-node host:port pairs. | host1:port1,host2:port2 |
| instanceId | String | No | Update the cloud instance ID. | instance-001 |
| instanceType | String | No | Update the instance type. | RDS |
| cloudInstanceType | String | No | Update the cloud instance access type. | instance |
| vendorRegionId | String | No | Update the cloud vendor region ID. | cn-hangzhou |
| serverVersion | String | No | Update the database server version. | 8.0 |
| gatewayId | String | No | Update the gateway ID. | gateway-001 |
| tunnelId | String | No | Update the private connection ID. | tunnel-001 |
| accessId | String | No | Update the cloud access credential ID. | access-001 |
| env | String | No | Update the environment identifier. | product |
| sshConfig | Object | No | Update SSH connection settings. | {} |
| 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 encrypted-transport configuration. Omit it to disable SSL. The update API does not validate the data source type. | {"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. - When
hostis updated for Redis Sentinel or Redis Cluster, the API also updateshostAndPorts. PasshostAndPortsdirectly when needed. - Updating a DataHub data source does not force the credential selected by
accessIdto replace the existing username and password.
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 | Object | 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.