Skip to main content

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

ParameterTypeRequiredDescriptionExample
datasourceIdStringYesData source ID. Query it by calling the List Data Sources interface.ds-d92lj22cb03k
nameStringNoModify the name of the data source.Datasource-updated
usernameStringNoLogin account to update. Omit it to keep the current value. When supplied, it must meet the create API account conditions.root
passwordStringNoLogin password to update. Omit it to keep the current value. When supplied, it has the same conditions as username.root
hostStringNoModify 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
portIntegerNoModify 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
envIdStringNoModify the environment of the data source. Call the List Environments interface to get envId.aliyun-cn-hangzhou
regionIdStringNoUpdate the data source region.cn-hangzhou
networkTypeStringNoUpdate the connection method. Values: public, gateway, ssh, and private.public
masterNameStringNoUpdate the primary node name.master-1
hostAndPortsStringNoUpdate comma-separated multi-node host:port pairs.host1:port1,host2:port2
instanceIdStringNoUpdate the cloud instance ID.instance-001
instanceTypeStringNoUpdate the instance type.RDS
cloudInstanceTypeStringNoUpdate the cloud instance access type.instance
vendorRegionIdStringNoUpdate the cloud vendor region ID.cn-hangzhou
serverVersionStringNoUpdate the database server version.8.0
gatewayIdStringNoUpdate the gateway ID.gateway-001
tunnelIdStringNoUpdate the private connection ID.tunnel-001
accessIdStringNoUpdate the cloud access credential ID.access-001
envStringNoUpdate the environment identifier.product
sshConfigObjectNoUpdate SSH connection settings.{}
extraConfigObjectNoData-source-specific configuration. The fields you pass are incrementally merged into the existing configuration, so pass only fields to change.{"readPreference":"primary"}
sslConfigObjectNoSSL encrypted-transport configuration. Omit it to disable SSL. The update API does not validate the data source type.{"securityConfig":"PREFERRED"}
multiTagStringNoMulti-active mark.active

MongoDB Update Notes

  • Fields in extraConfig are incrementally merged into the existing configuration. Fields that are not passed remain unchanged.
  • If mongoDBDeploymentType contains an invalid value, the API validates and rejects the request.
  • When host is updated, the API verifies that each node is DNS-resolvable.
  • When host is updated for Redis Sentinel or Redis Cluster, the API also updates hostAndPorts. Pass hostAndPorts directly when needed.
  • Updating a DataHub data source does not force the credential selected by accessId to 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.

ParameterTypeRequiredApplicable Data SourcesDescriptionExample
securityConfigStringNoMySQL, PostgreSQLSSL security mode. MySQL values: REQUIRED, PREFERRED; PostgreSQL values: Prefer, Require, Verify-CA, Verify-Full.PREFERRED
sslCipherStringNoMySQLSSL cipher suite.TLS_AES_256_GCM_SHA384
sslCAStringNoMySQL, SQLServer, PostgreSQLCA certificate content.-----BEGIN CERTIFICATE-----
sslCAFileNameStringNoMySQL, SQLServer, PostgreSQLCA certificate file name.ca.pem
sslClientCertStringNoMySQL, PostgreSQLClient certificate content.-----BEGIN CERTIFICATE-----
sslClientCertFileNameStringNoMySQL, PostgreSQLClient certificate file name.client-cert.pem
sslClientKeyStringNoMySQL, PostgreSQLClient private key content.-----BEGIN PRIVATE KEY-----
sslClientKeyFileNameStringNoMySQL, PostgreSQLClient private key file name.client-key.pem
sslIndentifyBooleanNoMySQLWhether to verify the server identity. Use the field name sslIndentify as required by the API.false
hostNameInCertificateStringNoSQLServerHost name in the server certificate.db.example.com
trustServerCertificateBooleanNoSQLServerWhether 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

ParameterTypeDescriptionExample
successBoolWhether the interface call is successful. Return values: true, false.true
requestIdStringRequest ID.Iq0s6SPI-HNKKaLTnINGt1JEdOLc7DSH
dataObjectData 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.