Updated on 2025-01-14 GMT+08:00

Querying All DCS Instances

Function

This API is used to query DCS instances of a tenant, and allows you to specify query criteria.

Calling Method

For details, see Calling APIs.

URI

GET /v2/{project_id}/instances

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Parameter description:

Project ID. For details, see Obtaining a Project ID.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

instance_id

No

String

Parameter description:

Instance ID, which can be viewed on the instance details page on the DCS console.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

include_failure

No

String

Parameter description:

Indicates whether to return the number of instances that fail to be created.

Constraints:

N/A.

Value range:

  • true: yes

  • false: no

Default value:

false

include_delete

No

String

Parameter description:

Whether to return the number of instances that have been deleted.

Constraints:

N/A.

Value range:

  • true: yes

  • false: no

Default value:

false

name

No

String

Parameter description:

Instance name.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

offset

No

Integer

Parameter description:

Offset where the query starts

Constraints:

N/A.

Value range:

≥ 0

Default value:

0

limit

No

Integer

Parameter description:

Number of records displayed on each page.

Constraints:

N/A.

Value range:

1–1000

Default value:

10

status

No

String

Parameter description:

Instance status.

Constraints:

N/A.

Value range:

For details, see DCS Instance Statuses.

Default value:

N/A.

name_equal

No

String

Parameter description:

Whether to search for the instance that precisely matches a specified instance name.

Constraints:

N/A.

Value range:

  • true: yes

  • false: no

Default value:

false

tags

No

String

Parameter description:

Query by instance tag key-value pair. {key} indicates the tag key, and {value} indicates the tag value.

Constraints:

To query instances with multiple tag keys and values, separate key-value pairs with commas (,).

Value range:

N/A.

Default value:

N/A.

ip

No

String

Parameter description:

IP address of a DCS instance, for example, 192.168.7.146 It can be viewed on the instance details page on the DCS console.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

capacity

No

String

Parameter description:

DCS instance memory, in GB.

Constraints:

N/A.

Value range:

N/A.

Default value:

N/A.

Request Parameters

None

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

instance_num

Integer

Parameter description:

Number of instances.

Value range:

N/A.

instances

Array of InstanceListInfo objects

Parameter description:

Instance details array.

Value range:

N/A.

Table 4 InstanceListInfo

Parameter

Type

Description

publicip_id

String

Parameter description:

ID of the EIP bound to a DCS Redis instance.

The value of this parameter is null if public access is disabled.

Value range:

N/A.

vpc_name

String

Parameter description:

VPC name.

Value range:

N/A.

charging_mode

Integer

Parameter description:

Billing mode.

Value range:

  • 0: pay-per-use

  • 1: yearly/monthly

vpc_id

String

Parameter description:

ID of the VPC where the DCS Redis instance is located.

Value range:

N/A.

subnet_id

String

Parameter description:

ID of the subnet bound to a DCS Redis instance.

Value range:

N/A.

security_group_id

String

Parameter description:

ID of the security group bound to the DCS Redis instance.

Value range:

N/A.

created_at

String

Parameter description:

Instance creation time. For example, 2017-03-31T12:24:46.297Z.

Value range:

N/A.

updated_at

String

Parameter description:

Instance update time. Format: 2017-03-31T19:24:46.297Z.

Value range:

N/A.

enable_ssl

Boolean

Parameter description:

Whether SSL is enabled when enabling public access to a DCS Redis instance.

Value range:

  • true: enable

  • false: disable

max_memory

Integer

Parameter description:

Total memory of an instance, in MB.

Value range:

N/A.

used_memory

Integer

Parameter description:

Used memory of an instance, in MB.

Value range:

N/A.

publicip_address

String

Parameter description:

EIP bound to the DCS Redis instance.

The value of this parameter is null if public access is disabled.

Value range:

N/A.

capacity

Integer

Parameter description:

Cache size of the instance, in GB.

Value range:

N/A.

capacity_minor

String

Parameter description:

Memory of a DCS instance whose size is less than 1 GB, in GB.

Value range:

N/A.

order_id

String

Parameter description:

Order ID. The value is null when a pay-per-use instance is created.

Value range:

N/A.

maintain_begin

String

Parameter description:

UTC time when the maintenance time window starts. The format is HH:mm:ss.

Value range:

N/A.

maintain_end

String

Parameter description:

UTC time when the maintenance time window ends. The format is HH:mm:ss.

Value range:

N/A.

engine

String

Parameter description:

Cache engine.

Value range:

  • Redis

  • Memcached

engine_version

String

Parameter description:

Engine version.

Value range:

The engine version of a DCS Redis instance can be:

  • 3.0

  • 4.0

  • 5.0

  • 6.0

If the cache engine is Memcached, this parameter is blank.

service_upgrade

Boolean

Parameter description:

Whether an upgrade task has been created for an instance.

Value range:

  • true: yes

  • false: no

no_password_access

String

Parameter description:

Indicates whether password-protected access is enabled for the instance.

Value range:

  • true: no

  • false: yes

service_task_id

String

Parameter description:

ID of an upgrade task.

  • This parameter is valid when service_upgrade is set to true.

  • This parameter is blank when service_upgrade is set to false.

Value range:

N/A.

ip

String

Parameter description:

IP address of the DCS instance. For a cluster instance, multiple IP addresses are returned and separated by commas (,). For example, 192.168.0.1, 192.168.0.2.

Value range:

N/A.

access_user

String

Parameter description:

Username for accessing a password-protected DCS instance.

Value range:

N/A.

instance_id

String

Parameter description:

Instance ID.

Value range:

N/A.

enable_publicip

Boolean

Parameter description:

Whether public access is enabled for a DCS Redis 3.0 instance.

Value range:

  • true: enable

  • false: disable

port

Integer

Parameter description:

Port of a DCS instance.

Value range:

N/A.

user_id

String

Parameter description:

ID of the user to which the instance belongs.

Value range:

N/A.

user_name

String

Parameter description:

Username of the instance.

Value range:

N/A.

domain_name

String

Parameter description:

Domain name of a instance.

Value range:

N/A.

readonly_domain_name

String

Parameter description:

Read-only domain name of the instance. This parameter is available only for master/standby instances.

Value range:

N/A.

name

String

Parameter description:

Instance name.

Value range:

N/A.

spec_code

String

Parameter description:

Product flavor code.

Value range:

N/A.

status

String

Parameter description:

Instance status.

Value range:

For details, see DCS Instance Statuses.

tags

Array of ResourceTag objects

Parameter description:

Instance tag key and value.

Value range:

N/A.

enterprise_project_id

String

Parameter description:

Enterprise project ID.

Value range:

N/A.

description

String

Parameter description:

Instance description.

Value range:

N/A.

cpu_type

String

Parameter description:

CPU type of the instance.

Value range:

  • x86_64: x86-based

  • aarch64: Arm-based

az_codes

Array of strings

Parameter description:

AZs where there are available resources.

Value range:

N/A.

features

Features object

Parameter description:

Features supported by the instance.

Value range:

N/A.

sub_status

String

Parameter description:

Instance sub-status.

Value range:

N/A.

Table 5 ResourceTag

Parameter

Type

Description

key

String

Parameter description:

Tag key.

  • Cannot be left blank.

  • Must be unique for each resource.

  • Can contain a maximum of 36 characters.

  • Must be unique and cannot be empty.

Value range:

N/A.

value

String

Parameter description:

Tag value.

  • This parameter is mandatory when action is set to create and is optional when action is set to delete.

  • It can contain a maximum of 43 characters.

Value range:

N/A.

Table 6 Features

Parameter

Type

Description

support_acl

Boolean

Parameter description:

Whether ACL is supported.

Value range:

  • true: Yes

  • false: No

support_transparent_client_ip

Boolean

Parameter description:

Whether client IP pass-through is enabled.

Value range:

  • true: Yes

  • false: No

support_ssl

Boolean

Parameter description:

Whether SSL is supported.

Value range:

  • true: Yes

  • false: No

support_audit_log

Boolean

Parameter description:

Whether audit logs are supported.

Value range:

  • true: Yes

  • false: No

Status code: 400

Table 7 Response body parameters

Parameter

Type

Description

error_msg

String

Parameter description:

Error message.

Value range:

N/A.

error_code

String

Parameter description:

Error code.

Value range:

For details, see Error Codes.

error_ext_msg

String

Parameter description:

Extended error information. This parameter is not used currently and is set to null.

Value range:

N/A.

Status code: 401

Table 8 Response body parameters

Parameter

Type

Description

error_msg

String

Parameter description:

Error message.

Value range:

N/A.

error_code

String

Parameter description:

Error code.

Value range:

For details, see Error Codes.

error_ext_msg

String

Parameter description:

Extended error information. This parameter is not used currently and is set to null.

Value range:

N/A.

Status code: 403

Table 9 Response body parameters

Parameter

Type

Description

error_msg

String

Parameter description:

Error message.

Value range:

N/A.

error_code

String

Parameter description:

Error code.

Value range:

For details, see Error Codes.

error_ext_msg

String

Parameter description:

Extended error information. This parameter is not used currently and is set to null.

Value range:

N/A.

Status code: 404

Table 10 Response body parameters

Parameter

Type

Description

error_msg

String

Parameter description:

Error message.

Value range:

N/A.

error_code

String

Parameter description:

Error code.

Value range:

For details, see Error Codes.

error_ext_msg

String

Parameter description:

Extended error information. This parameter is not used currently and is set to null.

Value range:

N/A.

Status code: 500

Table 11 Response body parameters

Parameter

Type

Description

error_msg

String

Parameter description:

Error message.

Value range:

N/A.

error_code

String

Parameter description:

Error code.

Value range:

For details, see Error Codes.

error_ext_msg

String

Parameter description:

Extended error information. This parameter is not used currently and is set to null.

Value range:

N/A.

Example Requests

GET https://{dcs_endpoint}/v2/{project_id}/instances?offset=0&limit=10&name={name}&status={status}&id={id}&include_failure=true&include_delete=true&name_equal=false

Example Responses

Status code: 400

Invalid request.

{
  "error_code" : "DCS.4800",
  "error_msg" : "Invalid offset in the request."
}

SDK Sample Code

The SDK sample code is as follows.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.dcs.v2.region.DcsRegion;
import com.huaweicloud.sdk.dcs.v2.*;
import com.huaweicloud.sdk.dcs.v2.model.*;


public class ListInstancesSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");
        String projectId = "{project_id}";

        ICredential auth = new BasicCredentials()
                .withProjectId(projectId)
                .withAk(ak)
                .withSk(sk);

        DcsClient client = DcsClient.newBuilder()
                .withCredential(auth)
                .withRegion(DcsRegion.valueOf("<YOUR REGION>"))
                .build();
        ListInstancesRequest request = new ListInstancesRequest();
        try {
            ListInstancesResponse response = client.listInstances(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdcs.v2.region.dcs_region import DcsRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkdcs.v2 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]
    projectId = "{project_id}"

    credentials = BasicCredentials(ak, sk, projectId)

    client = DcsClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(DcsRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ListInstancesRequest()
        response = client.list_instances(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    dcs "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dcs/v2"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dcs/v2/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dcs/v2/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")
    projectId := "{project_id}"

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        Build()

    client := dcs.NewDcsClient(
        dcs.DcsClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.ListInstancesRequest{}
	response, err := client.ListInstances(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Status Codes

Status Code

Description

200

All instances are listed successfully.

400

Invalid request.

401

Invalid authentication information.

403

The request is rejected.

404

The requested resource is not found.

500

Internal service error.

Error Codes

See Error Codes.