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
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. |
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:
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:
Default value: false |
name |
No |
String |
Parameter description: Instance name. Constraints: N/A. Value range: N/A. Default value: N/A. |
offset |
No |
Integer |
Definition: Offset, which indicates that the generated list is displayed from this offset. For example, if the offset is 3, the generated list is displayed from the fourth record. Constraints: N/A 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: Exact query by instance name. Constraints: N/A Value range: N/A Default value: N/A |
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. |
is_recycle |
No |
Boolean |
Definition: Whether to query instances in the recycle bin. Constraints: N/A Range:
Default Value: false |
Request Parameters
None
Response Parameters
Status code: 200
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. |
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:
|
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 |
Definition: Whether SSL is enabled when enabling public access to a DCS Redis instance. Range:
|
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:
|
engine_version |
String |
Definition: Cache version. Range: The engine version of a DCS Redis instance can be:
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:
|
no_password_access |
String |
Parameter description: Indicates whether password-protected access is enabled for the instance. Value range:
|
service_task_id |
String |
Parameter description: ID of an upgrade task.
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:
|
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 ResourceTags 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:
|
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. |
deleted_time |
String |
Definition: Time when an instance is deleted. This parameter is displayed only for instances in the recycle bin. Format: 2017-03-31T19:24:46.297Z. Range: N/A |
release_time |
String |
Definition: Estimated time when an instance in the recycle bin will be released. This parameter is displayed only for instances in the recycle bin. Format: 2017-03-31T19:24:46.297Z. Range: N/A |
available_zones |
Array of strings |
Definition: ID of the AZ where resources are available. This parameter is displayed only for instances in the recycle bin. |
backup_id |
String |
Definition: Backup ID. This parameter is displayed only for instances in the recycle bin. Range: N/A |
instance_backup_policy |
InstanceBackupPolicy object |
Definition: Backup policy. This parameter is supported when the instance type is master/standby or cluster. This parameter is displayed only for instances in the recycle bin. Range: N/A |
cache_mode |
String |
Definition: DCS instance type. This parameter is displayed only for instances in the recycle bin. Range:
|
enable_ipv6 |
Boolean |
Definition: Whether IPv4/IPv6 dual-stack access is enabled. This parameter is displayed only for instances in the recycle bin. Range: true: Yes false: No |
rename_commands |
RenameCommandResp object |
Definition: Command renaming list, which is displayed only for instances in the recycle bin. |
Parameter |
Type |
Description |
---|---|---|
key |
String |
Parameter description: Tag key. Value range: N/A |
value |
String |
Definition: Tag value. Range: N/A |
Parameter |
Type |
Description |
---|---|---|
support_acl |
Boolean |
Parameter description: Whether ACL is supported. Value range:
|
support_transparent_client_ip |
Boolean |
Parameter description: Whether client IP pass-through is enabled. Value range:
|
support_ssl |
Boolean |
Parameter description: Whether SSL is supported. Value range:
|
support_acl_read_policy |
Boolean |
Definition: Whether the instance supports the ACL read-only routing policy. Range:
|
support_audit_log |
Boolean |
Parameter description: Whether audit logs are supported. Value range:
|
Parameter |
Type |
Description |
---|---|---|
backup_policy_id |
String |
Parameter description: Backup policy ID. Value range: N/A. |
created_at |
String |
Parameter description: Creation time, in the format of 2022-04-11T09:45:24.790Z. Value range: N/A. |
updated_at |
String |
Parameter description: Update time, in the format of 2022-04-12T02:22:03.269Z. Value range: N/A. |
policy |
BackupPolicyResp object |
Parameter description: Backup policy. Value range: N/A. |
tenant_id |
String |
Parameter description: Tenant ID. Value range: N/A. |
Parameter |
Type |
Description |
---|---|---|
backup_type |
String |
Parameter description: Backup type. Value range:
|
save_days |
Integer |
Parameter description: Retention period, in days. The automatic backup policy is retained when automatic backup is switched to manual backup. Value range: 1–7 |
periodical_backup_plan |
BackupPlan object |
Parameter description: Backup plan. The automatic backup policy is retained when automatic backup is switched to manual backup. Value range: N/A. |
Parameter |
Type |
Description |
---|---|---|
timezone_offset |
String |
Parameter description: Time zone of the backup. This parameter is no longer used. Value range: N/A. |
backup_at |
Array of integers |
Parameter description: Day on which the backup starts every week. The automatic backup policy is retained when automatic backup is switched to manual backup. Value range: 1–7: Monday to Sunday |
period_type |
String |
Parameter description: Interval at which backup is performed, which supports only weekly currently. The automatic backup policy is retained when automatic backup is switched to manual backup. Value range: N/A. |
begin_at |
String |
Parameter description: UTC time when the backup starts. For example, 00:00–01:00 indicates that the backup starts at 00:00 (UTC time). The value must be on the hour. The backup interval is 1 hour. The automatic backup policy is retained when automatic backup is switched to manual backup. Value range: N/A. |
Parameter |
Type |
Description |
---|---|---|
command |
String |
Definition: Command COMMAND that can be renamed. Range: N/A |
flushall |
String |
Definition: Command FLUSHALL that can be renamed. Range: N/A |
flushdb |
String |
Definition: Command FLUSHDB that can be renamed. Range: N/A |
hgetall |
String |
Definition: Command HGETALL that can be renamed. Range: N/A |
keys |
String |
Definition: Command KEYS that can be renamed. Range: N/A |
Status code: 400
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
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
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
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
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
-
Querying instances in the recycle bin
GET https://{dcs_endpoint}/v2/{project_id}/instances?is_recycle=true
Example Responses
Status code: 200
All instances are listed successfully.
{ "instance_num" : 1, "instances" : [ { "publicip_id" : { }, "vpc_name" : "dcs-beta", "charging_mode" : 0, "vpc_id" : "5e37b3be-950a-48e1-b498-65b63d336481", "subnet_id" : "a4112635-3ec0-471c-95c3-5cf49b9533af", "user_name" : "clouduser", "created_at" : "2022-08-29T09:00:34.335Z", "updated_at" : "2022-08-29T09:00:34.335Z", "enable_ssl" : false, "max_memory" : 128, "publicip_address" : null, "capacity" : 0, "order_id" : null, "maintain_begin" : "18:00:00", "engine" : "Redis", "maintain_end" : "19:00:00", "capacity_minor" : ".125", "service_upgrade" : false, "no_password_access" : true, "service_task_id" : "", "ip" : "192.168.0.195", "used_memory" : 2, "access_user" : null, "instance_id" : "c830053e-d5a3-4bc0-b6d6-ca37d1ea9dd5", "enable_publicip" : false, "port" : 6379, "user_id" : "d53977d1adfb49c5b025ba7d33a13fd7", "domain_name" : "redis-c830053e-d5a3-4bc0-b6d6-ca37d1ea9dd5.dcs.**cloud.com", "name" : "dcs-lpvo0829", "spec_code" : "redis.ha.xu1.tiny.r2.128", "engine_version" : "5.0", "status" : "RUNNING", "security_group_id" : "securityGroupId", "enterprise_project_id" : 0, "tags" : [ { "key" : 1, "value" : "DCS" } ], "az_codes" : [ "region01", "region02" ], "description" : "Instance description.", "cpu_type" : "x86_64", "features" : { "support_acl" : true, "support_transparent_client_ip" : true, "support_ssl" : false, "support_audit_log" : false }, "sub_status" : "normal" } ] }
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.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot