Skip to main content

Modify Data Source

Update the connection information of the data sources already entered in NineData. You can modify the name, account, password, connection address, port, and environment of the data source.

Request URL: /openapi/v1/datasource/update

Request Method: POST

Request Parameters

ParameterTypeRequiredDescriptionExample
datasourceIdStringYesData source ID. You can query by calling the List Data Sources interface.ds-d92lj22cb03k
nameStringNoModify the name of the data source.Datasource-updated
usernameStringNoModify the login account of the data source.root
passwordStringNoModify the login password of the data source.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. You can call the List Environments interface to get envId.aliyun-cn-hangzhou
extraConfigObjectNoData-source-specific configuration. The fields you pass are incrementally merged into the existing configuration, so you only need to pass fields to be changed.{"readPreference":"primary"}
sslConfigObjectNoSSL configuration. Currently supported only for MySQL, SQLServer, and PostgreSQL. Do not pass this parameter for MongoDB.{"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.

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
dataArrayData 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
}
}