Updated on 2024-10-25 GMT+08:00

Modifying a Connection

Function

This API is used to modify a connection.

URI

PUT /v5/{project_id}/connections/{connection_id}

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID of a tenant in a region.

For details about how to obtain the project ID, see Obtaining a Project ID.

connection_id

Yes

String

Connection ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

Content-Type

Yes

String

MIME type of the request body. Use the default value application/json. For APIs used to upload objects or images, the value varies depending on the flow type.

X-Auth-Token

Yes

String

User token obtained from IAM. It is a response to the API for obtaining a user token. This API is the only one that does not require authentication. The token is the value of X-Subject-Token in the response header.

X-Language

No

String

Request language type.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

name

No

String

Name of a connection.

db_type

No

String

Database type.

config

No

ConnectionConfig object

Connection configuration. The configuration varies with the connection type.

description

No

String

Connection description.

endpoint

No

BaseEndpoint object

Basic information about the database connection.

vpc

No

CloudVpcInfo object

Information about the VPC, subnet, and security group where a DB instance resides.

ssl

No

EndpointSslConfig object

Information of the database SSL certificate.

cloud

No

CloudBaseInfo object

Region and project where a DB instance is located.

enterprise_project_id

No

String

Enterprise project ID.

Table 4 ConnectionConfig

Parameter

Mandatory

Type

Description

driver_name

No

String

Driver name.

Table 5 BaseEndpoint

Parameter

Mandatory

Type

Description

id

No

String

Database information ID.

endpoint_name

Yes

String

Database scenario type. Values:

  • oracle: On-premises Oracle database.
  • ecs_oracle: Oracle database built on Huawei Cloud ECSs.
  • cloud_gaussdbv5: Huawei Cloud distributed GaussDB database.
  • mysql: MySQL database on other clouds or on-premises MySQL database.
  • ecs_mysql: MySQL database built on Huawei Cloud ECSs.
  • cloud_mysql: Huawei Cloud RDS for MySQL database.
  • redis: On-premises Redis database.
  • ecs_redis: Redis database built on Huawei Cloud ECSs.
  • rediscluster: On-premises Redis Cluster database.
  • ecs_rediscluster: Redis Cluster database built on Huawei Cloud ECSs.
  • cloud_gaussdb_redis: Huawei Cloud GeminiDB Redis database.
  • postgresql: On-premises PostgreSQL database.
  • ecs_postgresql: PostgreSQL database built on Huawei Cloud ECSs.
  • cloud_postgresql: Huawei Cloud RDS for PostgreSQL database.
  • mongodb: On-premises MongoDB database.
  • ecs_mongodb: MongoDB database built on Huawei Cloud ECSs.
  • cloud_mongodb: Huawei Cloud DDS database.

ip

No

String

Database IP address. If an on-premises MongoDB database is used, use colons (:) to separate the database IP address and port number, and use commas (,) to separate multiple values. A maximum of three IP addresses or domain names can be entered. If a DDS instance is used, use colons (:) to separate the database IP address and port number, and use commas (,) to separate multiple values. If a Redis Cluster database is used, enter the IP addresses and port numbers of all shards in the source Redis Cluster database. Use colons (:) to separate a database IP address and port number. Use commas (,) to separate multiple values. You are advised to enter the IP address of the slave node of a cluster shard. Up to 32 IP addresses or domain names can be entered. Use commas (,) to separate multiple IP addresses or domain names. Example: MySQL: ip; MongoDB: ip:port,ip:port,ip:port; DDS: ip:port,ip:port; Cluster Redis: ip:port,ip:port

db_port

No

String

Database port.

The value is an integer ranging from 1 to 65535.

db_user

Yes

String

Database username.

db_password

Yes

String

Database password.

instance_id

No

String

ID of a Huawei Cloud DB instance.

instance_name

No

String

Name of a Huawei Cloud DB instance.

db_name

No

String

Database name. For example:

  • oracle: serviceName.orcl.

source_sharding

No

Array of BaseEndpoint objects

Information about the physical source database.

Table 6 CloudVpcInfo

Parameter

Mandatory

Type

Description

vpc_id

Yes

String

ID of the VPC where a DB instance is located. To obtain the ID, perform the following steps:

Method 1: Log in to the VPC console and view the VPC ID on the VPC details page.

Method 2: Query the VPC ID through the VPC API. For details, see "Querying VPCs".

subnet_id

Yes

String

ID of the subnet where a DB instance is located. To obtain the ID, perform the following steps:

Method 1: Log in to the VPC console and click the target subnet on the Subnets page to view the network ID on the displayed page.

Method 2: Query the subnet ID through the VPC API. For details, see "Querying Subnets".

security_group_id

No

String

ID of the security group where a DB instance is located. To obtain the ID, perform the following steps:

Method 1: Log in to the VPC console. Choose Access Control > Security Groups in the navigation pane on the left. On the displayed page, click the target security group. You can view the security group ID on the displayed page.

Method 2: Query the security group through the VPC API. For details, see "Querying Security Groups".

Table 7 EndpointSslConfig

Parameter

Mandatory

Type

Description

ssl_link

No

Boolean

Whether SSL is enabled. If SSL is enabled, the value of this parameter is true.

ssl_cert_name

No

String

SSL certificate name.

ssl_cert_key

No

String

SSL certificate content, which is encrypted using Base64.

ssl_cert_check_sum

No

String

The checksum value of an SSL certificate, which is used for backend verification. This parameter is mandatory for secure connection to a source database.

ssl_cert_password

No

String

SSL certificate password. This parameter is mandatory if the certificate file name extension is .p12.

Table 8 CloudBaseInfo

Parameter

Mandatory

Type

Description

region

Yes

String

Region ID. This parameter is mandatory when DB Instance Type is set to ecs (database built on Huawei Cloud ECSs) or cloud (Huawei Clouddatabase). For details, see "Regions and Endpoints".

Note: If there are subprojects in a region, the region ID is the combination of regional project ID and subproject ID, which are combined using an underscore (_), for example, cn-north-4_abc.

project_id

Yes

String

Project ID of a tenant in a region. For details about how to obtain the project ID, see "Obtaining a Project ID".

az_code

No

String

Name of the AZ where the database is located.

Response Parameters

Status code: 400

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Example Request

Modifying a specified connection

https://{endpoint}/v5/5237e10fe9aa4ad5b16b6a5245248314/connections/835e1d79-24ac-411d-a1c8-22c000280659
{
  "name" : "DRS-mysql-newName",
  "db_type" : "mysql",
  "description" : "description-new",
  "endpoint" : {
    "endpoint_name" : "mysql",
    "ip" : "127.0.0.1",
    "db_port" : "3306",
    "db_user" : "root",
    "db_password" : "password"
  },
  "ssl" : {
    "ssl_link" : false
  },
  "enterprise_project_id" : "0"
}

Example Response

Status code: 200

OK

{ }

Status code: 400

Bad Request

{
  "error_code" : "DRS.10010065",
  "error_msg" : "Connection manager name is already exists."
}

Status Code

Status Code

Description

200

OK

400

Bad Request

Error Code

For details, see Error Code.