Querying Details of EVS Disks by Tag
Function
This API is used to query the details of EVS disks by tag.
Calling Method
For details, see Calling APIs.
URI
POST /v2/{project_id}/cloudvolumes/resource_instances/action
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
The project ID. For details about how to obtain the project ID, see Obtaining a Project ID. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
The user token. It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
action |
Yes |
String |
The operation identifier. To query the details of disks by tag, use filter. Default: filter Enumeration values:
|
limit |
No |
Integer |
The number of query records. The value ranges from 1 to 1000, and the default value is 1000. The returned value cannot exceed this limit. Minimum: 1 Maximum: 1000 Default: 1000 |
matches |
No |
Array of Match objects |
The search criteria supported by disks. Tag keys in a tag list must be unique. |
offset |
No |
Integer |
The index location. The minimum value is 0, which is also the default value. The first record in the query result is the "offset+1" record that meets the query criteria. For example, there are a total of 30 EVS disk. If you set offset to 11 and limit to 10, the query starts from the twelfth disk, and a maximum of 10 disks can be queried at a time. Default: 0 |
tags |
Yes |
Array of TagsForListVolumes objects |
The key-value pairs of tags. A tag list can contain a maximum of 10 keys. Tag keys in a tag list must be unique. When multiple keys are specified in a tag list, only the disks having all specified keys are queried. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
key |
Yes |
String |
The key. Options are as follows: resource_name service_type Enumeration values:
|
value |
Yes |
String |
The value, which can contain a maximum of 255 characters. If resource_name is specified for key, the tag value uses a fuzzy match. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
key |
Yes |
String |
The tag key. |
values |
Yes |
Array of strings |
The tag value. A tag list can contain a maximum of 10 values. Tag values in a tag list must be unique. If the tag value list is empty, disks that contain any key can be queried. When there are multiple values and the key requirements are met, disks that have any of the specified values are queried. |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
total_count |
Integer |
The number of disks that meet the query criteria. |
resources |
Array of Resource objects |
The list of disks that meet the query criteria. |
Parameter |
Type |
Description |
---|---|---|
resource_id |
String |
The resource ID. |
resource_name |
String |
The resource name. |
resource_detail |
VolumeDetailForTag object |
The resource details. |
tags |
Array of Map<String,String> objects |
The tag list. |
Parameter |
Type |
Description |
---|---|---|
id |
String |
The disk ID. |
links |
Array of Link objects |
The disk URI. |
name |
String |
The disk name. |
status |
String |
The disk status. For details, see EVS Disk Status. |
attachments |
Array of Attachment objects |
The disk attachment information. |
availability_zone |
String |
The AZ to which the disk belongs. |
os-vol-host-attr:host |
String |
The reserved field. |
source_volid |
String |
The source disk ID. This parameter has a value if the disk is created from a source disk. This field is currently not supported. |
snapshot_id |
String |
The snapshot ID. This parameter has a value if the disk is created from a snapshot. |
description |
String |
The disk description. |
created_at |
String |
The time when the disk was created. Time format: UTC YYYY-MM-DDTHH:MM:SS.XXXXXX |
os-vol-tenant-attr:tenant_id |
String |
The ID of the tenant to which the disk belongs. The tenant ID is the same as the project ID. |
volume_image_metadata |
Map<String,Object> |
The metadata of the disk image.
NOTE:
For details about the volume_image_metadata field, see Querying Image Details (Native OpenStack API). |
volume_type |
String |
The disk type. The value can be SSD, SAS, or SATA.
|
size |
Integer |
The disk size, in GiB. |
consistencygroup_id |
String |
The reserved field. |
bootable |
String |
Whether the disk is bootable. true: The disk is bootable. false: The disk is not bootable. |
metadata |
VolumeMetadata object |
The disk metadata. |
updated_at |
String |
The time when the disk was updated. Time format: UTC YYYY-MM-DDTHH:MM:SS.XXXXXX |
encrypted |
Boolean |
This field is currently not supported. |
replication_status |
String |
The reserved field. |
os-volume-replication:extended_status |
String |
The reserved field. |
os-vol-mig-status-attr:migstat |
String |
The reserved field. |
os-vol-mig-status-attr:name_id |
String |
The reserved field. |
shareable |
Boolean |
Whether the disk is shareable. The value can be true (shareable) or false (non-shareable). This field has been deprecated. Use multiattach. |
user_id |
String |
The reserved field. |
service_type |
String |
The service type. Supported services are EVS, DSS, and DESS. |
multiattach |
Boolean |
Whether the disk is shareable. |
dedicated_storage_id |
String |
The ID of the dedicated storage pool housing the disk. |
dedicated_storage_name |
String |
The name of the dedicated storage pool housing the disk. |
tags |
Map<String,String> |
The disk tags. This field has values if the disk has tags. Or, it is left empty. |
wwn |
String |
The unique identifier used when attaching the disk. |
enterprise_project_id |
String |
The ID of the enterprise project that the disk has been added to. For more details about enterprise projects and how to obtain enterprise project IDs, see . Overview.. |
Parameter |
Type |
Description |
---|---|---|
href |
String |
The corresponding shortcut link. |
rel |
String |
The shortcut link marker name. |
Parameter |
Type |
Description |
---|---|---|
attached_at |
String |
The time when the disk was attached. Time format: UTC YYYY-MM-DDTHH:MM:SS.XXXXXX |
attachment_id |
String |
The attachment ID. |
device |
String |
The device name. |
host_name |
String |
The name of the physical host housing the cloud server to which the disk is attached. |
id |
String |
The ID of the attached disk. |
server_id |
String |
The ID of the server to which the disk is attached. |
volume_id |
String |
The disk ID. |
Parameter |
Type |
Description |
---|---|---|
__system__cmkid |
String |
The encryption CMK ID in metadata. This parameter is used together with __system__encrypted for encryption. The length of cmkid is fixed at 36 bytes. For details about how to obtain the key ID, see Querying the Key List. |
__system__encrypted |
String |
The encryption field in metadata. The value can be 0 (no encryption) or 1 (encryption). If this parameter is not specified, the encryption attribute of the disk is the same as that of the data source. If the disk is not created from a data source, the disk is not encrypted by default. |
full_clone |
String |
The creation method when the disk is created from a snapshot.
|
hw:passthrough |
String |
|
orderID |
String |
The parameter that describes the disk billing mode in metadata. If this parameter has a value, the disk is billed on a yearly/monthly basis. If not, the disk is billed on a pay-per-use basis. |
Status code: 400
Parameter |
Type |
Description |
---|---|---|
error |
Error object |
The error message returned if an error occurs. For details, seeParameters in the error field. |
Parameter |
Type |
Description |
---|---|---|
code |
String |
The error code returned if an error occurs. For the error codes and their meanings, see Error Codes. |
message |
String |
The error message returned if an error occurs. |
Example Requests
Querying details of disk shared01 using tags key_string,value_string and key_string02,value_string02 (The query starts from the tenth record. The number of records returned cannot exceed 100.)
POST https://{endpoint}/v2/{project_id}/cloudvolumes/resource_instances/action { "offset" : 9, "limit" : 100, "action" : "filter", "tags" : [ { "key" : "key_string", "values" : [ "value_string" ] }, { "key" : "key_string02", "values" : [ "value_string02" ] } ], "matches" : [ { "key" : "resource_name", "value" : "shared01" }, { "key" : "service_type", "value" : "EVS" } ] }
Example Responses
Status code: 200
The disk information is returned.
{ "total_count" : 1, "resources" : [ { "resource_name" : "resource1", "resource_detail" : { "attachments" : [ { "server_id" : "2080869e-ba46-4ea5-b45e-3191ac0f1d54", "attachment_id" : "1335f039-7a42-4d1e-be49-ac584db0ba0b", "attached_at" : "2019-08-06T07:00:21.842812", "volume_id" : "7fa6b592-ac75-460d-a28a-bb17429d1eb2", "device" : "/dev/vda", "id" : "7fa6b592-ac75-460d-a28a-bb17429d1eb2" } ], "links" : [ { "href" : "https://volume.Region.dc1.domainname.com/v2/051375756c80d5eb2ff0c014498645fb/volumes/7fa6b592-ac75-460d-a28a-bb17429d1eb2", "rel" : "self" }, { "href" : "https://volume.Region.dc1.domainname.com/051375756c80d5eb2ff0c014498645fb/volumes/7fa6b592-ac75-460d-a28a-bb17429d1eb2", "rel" : "bookmark" } ], "availability_zone" : "kvmxen.dc1", "os-vol-host-attr:host" : "az21.dc1#2", "enterprise_project_id" : "0", "updated_at" : "2019-08-09T06:19:35.874737", "replication_status" : "disabled", "id" : "7fa6b592-ac75-460d-a28a-bb17429d1eb2", "size" : 40, "user_id" : "75f26e17348643bfb7718578b04635c2", "os-vol-tenant-attr:tenant_id" : "051375756c80d5eb2ff0c014498645fb", "service_type" : "EVS", "metadata" : { }, "status" : "in-use", "volume_image_metadata" : { "size" : "0", "__quick_start" : "False", "container_format" : "bare", "min_ram" : "0", "image_name" : "test-hua-centos7.3-0725", "image_id" : "c6c153a6-dde8-4bac-8e40-3d7619436934", "__os_type" : "Linux", "min_disk" : "20", "__support_kvm" : "true", "virtual_env_type" : "FusionCompute", "__description" : "", "__os_version" : "CentOS 7.3 64bit", "__os_bit" : "64", "__image_source_type" : "uds", "__support_xen" : "true", "file_format" : "zvhd2", "checksum" : "d41d8cd98f00b204e9800998ecf8427e", "__imagetype" : "gold", "disk_format" : "zvhd2", "__image_cache_type" : "Not_Cache", "__isregistered" : "true", "__image_location" : "192.149.46.200:5443:pcsimssouthchina:c6c153a6-dde8-4bac-8e40-3d7619436934", "__image_size" : "911269888", "__platform" : "CentOS" }, "description" : "", "multiattach" : false, "name" : "resource1", "bootable" : "true", "created_at" : "2019-08-06T06:59:03.056682", "volume_type" : "SAS", "shareable" : false }, "tags" : [ { "key" : "key1", "value" : "value1" }, { "key" : "key1", "value" : "value2" } ], "resource_id" : "7fa6b592-ac75-460d-a28a-bb17429d1eb2" } ] }
Status code: 400
Bad Request
{ "error" : { "message" : "XXXX", "code" : "XXX" } }
SDK Sample Code
The SDK sample code is as follows.
Querying details of disk shared01 using tags key_string,value_string and key_string02,value_string02 (The query starts from the tenth record. The number of records returned cannot exceed 100.)
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
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.evs.v2.region.EvsRegion; import com.huaweicloud.sdk.evs.v2.*; import com.huaweicloud.sdk.evs.v2.model.*; import java.util.List; import java.util.ArrayList; public class ListVolumesByTagsSolution { 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"); ICredential auth = new BasicCredentials() .withAk(ak) .withSk(sk); EvsClient client = EvsClient.newBuilder() .withCredential(auth) .withRegion(EvsRegion.valueOf("<YOUR REGION>")) .build(); ListVolumesByTagsRequest request = new ListVolumesByTagsRequest(); ListVolumesByTagsRequestBody body = new ListVolumesByTagsRequestBody(); List<String> listTagsValues = new ArrayList<>(); listTagsValues.add("value_string02"); List<String> listTagsValues1 = new ArrayList<>(); listTagsValues1.add("value_string"); List<TagsForListVolumes> listbodyTags = new ArrayList<>(); listbodyTags.add( new TagsForListVolumes() .withKey("key_string") .withValues(listTagsValues1) ); listbodyTags.add( new TagsForListVolumes() .withKey("key_string02") .withValues(listTagsValues) ); List<Match> listbodyMatches = new ArrayList<>(); listbodyMatches.add( new Match() .withKey(Match.KeyEnum.fromValue("resource_name")) .withValue("shared01") ); listbodyMatches.add( new Match() .withKey(Match.KeyEnum.fromValue("service_type")) .withValue("EVS") ); body.withTags(listbodyTags); body.withOffset(9); body.withMatches(listbodyMatches); body.withLimit(100); body.withAction(ListVolumesByTagsRequestBody.ActionEnum.fromValue("filter")); request.withBody(body); try { ListVolumesByTagsResponse response = client.listVolumesByTags(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()); } } } |
Querying details of disk shared01 using tags key_string,value_string and key_string02,value_string02 (The query starts from the tenth record. The number of records returned cannot exceed 100.)
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkevs.v2.region.evs_region import EvsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkevs.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.getenv("CLOUD_SDK_AK") sk = os.getenv("CLOUD_SDK_SK") credentials = BasicCredentials(ak, sk) \ client = EvsClient.new_builder() \ .with_credentials(credentials) \ .with_region(EvsRegion.value_of("<YOUR REGION>")) \ .build() try: request = ListVolumesByTagsRequest() listValuesTags = [ "value_string02" ] listValuesTags1 = [ "value_string" ] listTagsbody = [ TagsForListVolumes( key="key_string", values=listValuesTags1 ), TagsForListVolumes( key="key_string02", values=listValuesTags ) ] listMatchesbody = [ Match( key="resource_name", value="shared01" ), Match( key="service_type", value="EVS" ) ] request.body = ListVolumesByTagsRequestBody( tags=listTagsbody, offset=9, matches=listMatchesbody, limit=100, action="filter" ) response = client.list_volumes_by_tags(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
Querying details of disk shared01 using tags key_string,value_string and key_string02,value_string02 (The query starts from the tenth record. The number of records returned cannot exceed 100.)
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" evs "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/evs/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/evs/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/evs/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") auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). Build() client := evs.NewEvsClient( evs.EvsClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ListVolumesByTagsRequest{} var listValuesTags = []string{ "value_string02", } var listValuesTags1 = []string{ "value_string", } var listTagsbody = []model.TagsForListVolumes{ { Key: "key_string", Values: listValuesTags1, }, { Key: "key_string02", Values: listValuesTags, }, } var listMatchesbody = []model.Match{ { Key: model.GetMatchKeyEnum().RESOURCE_NAME, Value: "shared01", }, { Key: model.GetMatchKeyEnum().SERVICE_TYPE, Value: "EVS", }, } offsetListVolumesByTagsRequestBody:= int32(9) limitListVolumesByTagsRequestBody:= int32(100) request.Body = &model.ListVolumesByTagsRequestBody{ Tags: listTagsbody, Offset: &offsetListVolumesByTagsRequestBody, Matches: &listMatchesbody, Limit: &limitListVolumesByTagsRequestBody, Action: model.GetListVolumesByTagsRequestBodyActionEnum().FILTER, } response, err := client.ListVolumesByTags(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 |
The disk information is returned. |
400 |
Bad Request |
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