Overview
This API promotes the specified standby instance to the primary instance. You can perform the switchover only when both the primary and standby instances are running normally.
API details
Constraints
An AccessKey is required to call the multi-cloud API. For information about how to obtain an AccessKey ID and AccessKey Secret, see Manage AccessKeys.
Request path
POST /api/v2/instances/{instanceId}/switchoverInstance
Request parameters
Path
Parameter |
Type |
Required |
Description |
Example value |
|---|---|---|---|---|
| instanceId | String | Yes | Original primary instance ID. | obcluster-***** |
Query
Parameter |
Type |
Required |
Description |
Example value |
|---|---|---|---|---|
| requestId | String | Yes | Request ID used for tracking. | d04eabba**** |
Body
A JSON request body is required.
Parameter |
Type |
Required |
Description |
Example value |
|---|---|---|---|---|
| instanceId | String | Yes | Original primary instance ID. Must match instanceId in the path and be explicitly included in the request body. |
obcluster-***** |
| targetInstanceId | String | Yes | ID of the standby instance to promote to the primary instance. | obcluste**** |
| UID | String | No | User ID. | 20000600**** |
| User_ID | String | No | User ID. | 20000600**** |
| requestId | String | No | Request ID used for tracking. | d04eabba**** |
| callerType | String | No | Caller type. | sub |
| accessKeyId | String | No | AccessKey ID. | ak-xxxxx**** |
| securityToken | String | No | Security token. | sts-token-xxxxxxxx |
| callerUid | String | No | Caller ID. | 20000600**** |
| callerBid | String | No | Caller BID. | xxxxxx |
| stsTokenCallerUid | String | No | UID of the STS token caller. | 20000600**** |
| stsTokenCallerBid | String | No | BID of the STS token caller. | xxxxxx |
| acceptLanguage | String | No | Language used in the request or response. | zh-CN |
| pageNumber | Integer | No | Page number. | 1 |
| pageSize | Integer | No | Page size. | 10 |
| mergedCallerBid | String | No | Merged caller business identity ID. | xxxxxx |
Response parameters
Field |
Type |
Description |
Example value |
|---|---|---|---|
| success | Boolean | Whether the request succeeded. | true |
| errorCode | String | Error code. | INVALID_PARAMETER |
| errorMessage | String | Error message. | Invalid parameter |
| data | Object | Response data. | None |
| data.Success | Boolean | Whether the request succeeded. | true |
| data.Message | String | Response message or error message. Empty if the request succeeds. | "" |
| cost | Number | Elapsed time. | 1.0 |
| server | String | Server address, typically the IP address of an OBServer node. | 10.0.0.10 |
| requestId | String | Request ID. | d04eabba**** |
| totalCount | Number | Total number of records. | 100.0 |
| extra | Object | Additional information. | {} |
HTTP status codes
Status code |
Description |
|---|---|
| 200 | Request succeeded. |
| 400 | Invalid request parameters. |
| 401 | Authentication failed or authentication information is missing. |
| 403 | Access to the resource is denied. |
| 404 | Resource not found. |
| 429 | Too many requests. |
| 500 | Internal server error. |
Examples
Request example
The following example uses the API endpoint for the international site. Replace the AccessKey ID, AccessKey Secret, and instance IDs with your actual values. Use the service endpoint for your service site.
curl --digest -u '<AccessKey ID>:<AccessKey Secret>' -X POST \
'https://api-cloud.oceanbase.com/api/v2/instances/obcluster-*****/switchoverInstance?requestId=d04eabba****' \
-H 'Content-Type: application/json' \
-d '{
"instanceId": "obcluster-*****",
"targetInstanceId": "obcluste****",
"requestId": "d04eabba****"
}'
Response example
JSON format:
{
"success": true,
"data": {
"Success": true,
"Message": ""
},
"cost": 1.0,
"server": "xxx.xxx.x.xxx:xxx",
"requestId": "d04eabba****",
"totalCount": 100.0,
"extra": {}
}