DescribeDBInstances

Last updated: 2021-10-28 10:20:36

1. API Description

Domain name for API request: cdb.tencentcloudapi.com.

This API (DescribeDBInstances) is used to query the list of TencentDB instances (which can be primary, disaster recovery, or read-only instances). It supports filtering instances by project ID, instance ID, access address, and instance status.

A maximum of 100 requests can be initiated per second for this API.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common parameter. The value used for this API: DescribeDBInstances.
Version Yes String Common parameter. The value used for this API: 2017-03-20.
Region Yes String Common parameter. For more information, please see the list of regions supported by the product.
ProjectId No Integer Project ID.
InstanceTypes.N No Array of Integer Instance type. Value range: 1 (primary), 2 (disaster recovery), 3 (read-only).
Vips.N No Array of String Private IP address of the instance.
Status.N No Array of Integer Instance status. Value range:
0 - creating
1 - running
4 - isolating
5 - isolated (the instance can be restored and started in the recycle bin)
Offset No Integer Offset. Default value: 0.
Limit No Integer Number of results to be returned for a single request. Default value: 20. Maximum value: 2,000.
SecurityGroupId No String Security group ID. When it is used as a filter, the WithSecurityGroup parameter should be set to 1.
PayTypes.N No Array of Integer Billing method. Value range: 0 (monthly subscribed), 1 (hourly).
InstanceNames.N No Array of String Instance name.
TaskStatus.N No Array of Integer Instance task status. Valid values:
0 - no task
1 - upgrading
2 - importing data
3 - enabling secondary instance access
4 - enabling public network access
5 - batch operation in progress
6 - rolling back
7 - disabling public network access
8 - modifying password
9 - renaming instance
10 - restarting
12 - migrating self-built database
13 - dropping tables
14 - Disaster recovery instance creating sync task
15 - waiting for switch
16 - switching
17 - upgrade and switch completed
19 - parameter settings to be executed
EngineVersions.N No Array of String Version of the instance database engine. Value range: 5.1, 5.5, 5.6, 5.7.
VpcIds.N No Array of Integer VPC ID.
ZoneIds.N No Array of Integer AZ ID.
SubnetIds.N No Array of Integer Subnet ID.
CdbErrors.N No Array of Integer Lock flag.
OrderBy No String Sort by field of the returned result set. Currently, supported values include "InstanceId", "InstanceName", "CreateTime", and "DeadlineTime".
OrderDirection No String Sorting method of the returned result set. Currently, "ASC" or "DESC" is supported.
WithSecurityGroup No Integer Whether security group ID is used as a filter
WithExCluster No Integer Whether dedicated cluster details are included. Value range: 0 (not included), 1 (included)
ExClusterId No String Exclusive cluster ID.
InstanceIds.N No Array of String Instance ID.
InitFlag No Integer Initialization flag. Value range: 0 (not initialized), 1 (initialized).
WithDr No Integer Whether instances corresponding to the disaster recovery relationship are included. Valid values: 0 (not included), 1 (included). Default value: 1. If a primary instance is pulled, the data of the disaster recovery relationship will be in the DrInfo field. If a disaster recovery instance is pulled, the data of the disaster recovery relationship will be in the MasterInfo field. The disaster recovery relationship contains only partial basic data. To get the detailed data, you need to call an API to pull it.
WithRo No Integer Whether read-only instances are included. Valid values: 0 (not included), 1 (included). Default value: 1.
WithMaster No Integer Whether primary instances are included. Valid values: 0 (not included), 1 (included). Default value: 1.
DeployGroupIds.N No Array of String Placement group ID list.
TagKeysForSearch.N No Array of String Whether to use the tag key as a filter condition
CageIds.N No Array of String Financial cage IDs.

3. Output Parameters

Parameter Name Type Description
TotalCount Integer Number of eligible instances.
Items Array of InstanceInfo Instance details.
RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

4. Example

Example1 Querying the list of instances

Input Example

https://cdb.tencentcloudapi.com/?Action=DescribeDBInstances
&InstanceIds.0=cdb-70zdmgg1
&<Common request parameters>

Output Example

{
  "Response": {
    "TotalCount": 1,
    "RequestId": "756bb037-a44a-4b4f-abe0-6efd34a6c792",
    "Items": [
      {
        "WanStatus": 0,
        "Zone": "ap-chengdu-1",
        "InitFlag": 1,
        "Memory": 1000,
        "Status": 1,
        "VpcId": 511512,
        "SlaveInfo": {
          "First": {
            "Vip": "",
            "Region": "ap-chengdu",
            "Vport": 0,
            "Zone": "ap-chengdu-1"
          }
        },
        "InstanceId": "cdb-70zdmgg1",
        "Volume": 50,
        "AutoRenew": 0,
        "ProtectMode": 0,
        "RoGroups": [
          {
            "RoInstances": [
              {
                "Status": 1,
                "VpcId": 511512,
                "InstanceType": 3,
                "Zone": "ap-chengdu-1",
                "Qps": 1000,
                "InstanceId": "cdbro-3i70uj0k",
                "Region": "ap-chengdu",
                "DeadlineTime": "0000-00-00 00:00:00",
                "PayType": 1,
                "TaskStatus": 0,
                "Volume": 50,
                "EngineVersion": "5.6",
                "DeviceType": "CUSTOM",
                "Memory": 1000,
                "SubnetId": 115839,
                "Vip": "172.16.0.11",
                "Vport": 3306,
                "InstanceName": "cdb_ro_103608",
                "HourFeeStatus": 1
              }
            ],
            "MinRoInGroup": 1,
            "Vip": "172.16.0.11",
            "RoGroupName": "ro_group_103608",
            "Vport": 3306,
            "WeightMode": "system",
            "RoGroupId": "cdbrg-3i70uj0k",
            "RoMaxDelayTime": 1
          },
          {
            "RoInstances": [
              {
                "Status": 1,
                "VpcId": 511512,
                "InstanceType": 3,
                "Zone": "ap-chengdu-1",
                "Qps": 1000,
                "InstanceId": "cdbro-6scijza8",
                "Region": "ap-chengdu",
                "DeadlineTime": "0000-00-00 00:00:00",
                "PayType": 1,
                "TaskStatus": 0,
                "Volume": 25,
                "EngineVersion": "5.6",
                "DeviceType": "CUSTOM",
                "Memory": 1000,
                "SubnetId": 115839,
                "Vip": "172.16.0.25",
                "Vport": 3306,
                "InstanceName": "cdb_ro_103610",
                "HourFeeStatus": 1
              }
            ],
            "MinRoInGroup": 1,
            "Vip": "172.16.0.25",
            "RoGroupName": "ro_group_103610",
            "Vport": 3306,
            "WeightMode": "system",
            "RoGroupId": "cdbrg-6scijza8",
            "RoMaxDelayTime": 1
          }
        ],
        "SubnetId": 115839,
        "InstanceType": 1,
        "ProjectId": 0,
        "Region": "ap-chengdu",
        "DeadlineTime": "0000-00-00 00:00:00",
        "DeployMode": 0,
        "TaskStatus": 0,
        "DeviceType": "CUSTOM",
        "EngineVersion": "5.6",
        "InstanceName": "jersey_test",
        "DrInfo": [],
        "UniqVpcId": "vpc-5v8wn9mg",
        "WanDomain": "",
        "WanPort": 0,
        "PayType": 1,
        "CreateTime": "2018-05-03 14:53:23",
        "Vip": "172.16.0.16",
        "UniqSubnetId": "subnet-1typ0s7d",
        "Vport": 3306,
        "CdbError": 0,
        "DeployGroupId": "",
        "InstanceNodes": 2,
        "PhysicalId": "",
        "ZoneId": 720001,
        "RoVipInfo": [],
        "DeviceClass": "Z3",
        "Qps": 0,
        "TagList": [],
        "Cpu": 8,
        "ZoneName": "Qingyuan Xin'an Zone 1"
      }
    ]
  }
}

5. Developer Resources

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

Error Code Description
AuthFailure CAM signature/authentication error.
CdbError Backend or process error.
InternalError.DBOperationError Database operation failed.
InternalError.DatabaseAccessError Internal database error.
InternalError.DesError Internal system error.
InternalError.InternalHttpServerError An exception occurred while executing the request.
InternalError.InternalServiceErrorErr An error occurred while accessing internal service.
InternalError.UndefinedError Unknown error
InvalidParameter Parameter error.
InvalidParameter.ExceptionParam Parameter exception.
InvalidParameter.InstanceNotFound The instance does not exist.
InvalidParameterValue.DataConvertError Data conversion failed.
InvalidParameterValue.InvalidParameterValueError Invalid parameter value
OperationDenied.WrongStatus The backend task status is invalid.