Help Center/ Document Database Service/ API Reference/ Examples/ Querying the DB Instance List
Updated on 2022-08-30 GMT+08:00

Querying the DB Instance List

Scenarios

This section describes how to call the API described in Querying Instances and Details to query all DDS DB instances of a tenant using pagination parameters.

Procedure

  1. Configure parameters limit and offset.

    • API information

      URI format: GET https://{Endpoint}/v3/{project_id}/instances?id={id}&name={name}&mode={mode}&datastore_type={datastore_type}&vpc_id={vpc_id}&subnet_id={subnet_id}&offset={offset}&limit={limit}

    • Example request
      • Instance list

        https://dds.ap-southeast-1.myhuaweicloud.com/v3/0483b6b16e954cb88930a360d2c4e663/instances?offset=0&limit=1

    • Response example

      Querying the instance list:

      {
        "instances": [
          {
            "id": "8436a91546294036b75931e879882200in02",
            "name": "dds-efa6",
            "status": "normal",
            "port": 8635,
            "mode": "ReplicaSet",
            "region": "aaa",
            "datastore": {
              "type": "DDS-Community",
              "version": "3.4"
            },
            "engine": "wiredTiger",
            "created": "2019-01-17T07:05:52",
            "updated": "2019-01-17T07:05:47",
            "db_user_name": "rwuser",
            "ssl": "1",
            "vpc_id": "674e9b42-cd8d-4d25-a2e6-5abcc565b961",
            "subnet_id": "f1df08c5-71d1-406a-aff0-de435a51007b",
            "security_group_id": "7aa51dbf-5b63-40db-9724-dad3c4828b58",
            "backup_strategy": {
              "start_time": "16:00-17:00",
              "keep_days": 7
            },
            "pay_mode": "0",
            "maintenance_window": "02:00-06:00",
            "groups": [
              {
                "type": "replica",
                "volume": {
                  "size": "10",
                  "used": "0.33"
                },
                "nodes": [
                  {
                    "id": "233eaac9c6f245c0bb9c2d21eea12d1bno02",
                    "name": "dds-efa6_replica_node_2",
                    "status": "normal",
                    "role": "Primary",
                    "private_ip": "192.168.0.174",
                    "public_ip": "",
                    "spec_code": "dds.mongodb.s2.medium.4.repset",
                    "availability_zone": "bbb"
                  },
                  {
                    "id": "d57d76d6320a4a7b86db82c317550c4ano02",
                    "name": "dds-efa6_replica_node_1",
                    "status": "normal",
                    "role": "Hidden",
                    "private_ip": "192.168.0.39",
                    "public_ip": "",
                    "spec_code": "dds.mongodb.s2.medium.4.repset",
                    "availability_zone": "bbb"
                  },
                  {
                    "id": "f46b0a1cf4d9400e9fd7af17f8742d37no02",
                    "name": "dds-efa6_replica_node_3",
                    "status": "normal",
                    "role": "Secondary",
                    "private_ip": "192.168.0.176",
                    "public_ip": "",
                    "spec_code": "dds.mongodb.s2.medium.4.repset",
                    "availability_zone": "bbb"
                  }
                ]
              }
            ],
            "enterprise_project_id": "0",
            "time_zone": "",
            "actions": [
            ]
          }
        ],
        "total_count": 24
      }

  2. Collect query results.

    1. Repeat 1 until the returned query result is empty or the returned body does not contain the instances field. This indicates that all DDS instances have been queried.
    2. Collect all of the queried DDS instances.