You can call the SwitchDBInstanceNetType operation to switch an ApsaraDB RDS instance between its internal and public endpoints.
To save endpoint resources, you can call this operation to switch an instance between its internal and public endpoints. After the endpoint that is used to connect to the instance is changed, you must update the endpoint information in the code of your application and restart the application.
Before you call this operation, make sure that the following requirements are met:
- The instance is connected by using its internal or public endpoint.
- The instance is in the Running state.
- The number of times that you have switched the instance between its internal and public endpoints within the last 24 hours does not reach 20.
- The instance resides in the classic network.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | SwitchDBInstanceNetType |
The operation that you want to perform. Set the value to SwitchDBInstanceNetType. |
ClientToken | String | No | ETnLKlblzczshOTUbOCzxxxxxx |
The client token that is used to ensure the idempotence of the request. You can use the client to generate the value, but you must ensure that it is unique among different requests. The token can only contain ASCII characters and cannot exceed 64 characters in length. |
DBInstanceId | String | Yes | rm-bp1************** |
The ID of the instance. |
ConnectionStringPrefix | String | Yes | new********** |
The prefix of the custom endpoint. The prefix must be 8 to 64 characters in length and can contain letters and digits. It must start with a lowercase letter. A valid endpoint is in the following format: Prefix.Database engine.rds.aliyuncs.com. Example: test1234.mysql.rds.aliyuncs.com. |
Port | String | No | 3306 |
The port associated with the endpoint. Valid values: 3001 to 3999. |
ConnectionStringType | String | No | Normal |
The type of the endpoint. Valid values:
By default, the system returns both types of endpoints. |
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
NewConnectionString | String | new**********.mysql.rds.aliyuncs.com |
The endpoint that is used to connect to the instance after the switch of endpoints. |
RequestId | String | 65BDA532-28AF-4122-AA39-B382721EEE64 |
The ID of the request. |
OldConnectionString | String | rm-bp1**************.mysql.rds.aliyuncs.com |
The endpoint that is used to connect to the instance before the switch of endpoints. |
Examples
Sample requests
http(s)://rds.aliyuncs.com/?Action=SwitchDBInstanceNetType
&DBInstanceId=rm-uf6wjk5xxxxxxx
&ConnectionStringPrefix=rm-xxxxxx
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<SwitchDBInstanceNetTypeResponse>
<RequestId>94D5FC3C-1314-5883-9127-61D2105515AF</RequestId>
<OldConnectionString>rm-bp1qp11x5**************.rds.aliyuncs.com</OldConnectionString>
<NewConnectionString>new**********.rds.aliyuncs.com</NewConnectionString>
</SwitchDBInstanceNetTypeResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "94D5FC3C-1314-5883-9127-61D2105515AF",
"OldConnectionString" : "rm-bp1qp11x5**************.rds.aliyuncs.com",
"NewConnectionString" : "new**********.rds.aliyuncs.com"
}
Error codes
For a list of error codes, visit the Error Center.