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.
Authorization Information
Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.
- If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
- If you are using identity policy-based authorization, no identity policy-based permission required for calling this API.
URI
POST /v2/{project_id}/cloudvolumes/resource_instances/action
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
project_id |
Yes |
String |
Definition The project ID. For details, see Obtaining a Project ID. Constraints N/A Range N/A Default Value N/A |
Request Parameters
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
X-Auth-Token |
Yes |
String |
Definition The user token. You can obtain it by calling the IAM API for obtaining a user token. The token is the value of X-Subject-Token in the response header. Constraints N/A Range N/A Default Value N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
action |
Yes |
String |
Definition The operation identifier. Constraints N/A Range To query the details of disks by tag, use filter. Default Value N/A |
|
limit |
No |
Integer |
Definition The maximum number of query records that can be returned. Constraints Minimum value: 1; Maximum value: 1000 Range 1–1000 Default Value 1000 |
|
matches |
No |
Array of Match objects |
Definition The search criteria supported by the resources. Constraints Tag keys in a tag list must be unique. Range N/A Default Value N/A |
|
offset |
No |
Integer |
Definition The offset. Constraints This parameter is used together with *limit when you query EVS disks. Assume that there are 30 disks. If you set offset to 11 and limit to 10, the query starts from the twelfth disk. A maximum of 10 disks can be queried at a time. Range N/A Default Value N/A |
|
tags |
Yes |
Array of TagsForListVolumes objects |
Definition The key-value pairs of tags. Constraints 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. Range N/A Default Value N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
key |
Yes |
String |
Definition The tag key. Constraints N/A Range
Default Value N/A |
|
value |
Yes |
String |
Definition The tag value. Constraints It can contain up to 255 characters. If resource_name is specified for key, the tag value uses fuzzy match. Range N/A Default Value N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
key |
Yes |
String |
Definition The tag key. Constraints Tag keys of a resource must be unique. A tag key can contain a maximum of 36 characters. Range Character set: A-Z, a-z, 0-9, hyphens (-), underscores (_), and Unicode characters (\u4E00-\u9FFF) Default Value N/A |
|
values |
Yes |
Array of strings |
Definition The tag values. Constraints A tag list can contain a maximum of 10 values. Tag values in a tag list must be unique. If the value list is empty, any tag value is matched. When there are multiple values and the key requirements are met, disks that have any of the specified values are queried. Range Character set: A-Z, a-z, 0-9, periods (.), hyphens (-), underscores (_), and Unicode characters (\u4E00-\u9FFF) Default Value N/A |
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
total_count |
Integer |
Definition The number of disks that meet the query criteria. Range N/A |
|
resources |
Array of Resource objects |
Definition The list of resources that meet the query criteria. Range N/A |
|
Parameter |
Type |
Description |
|---|---|---|
|
resource_id |
String |
Definition The resource ID. Range N/A |
|
resource_name |
String |
Definition The resource name. Range N/A |
|
resource_detail |
VolumeDetailForTag object |
Definition The resource details. Range N/A |
|
tags |
Array of Map<String,String> objects |
Definition The tag list. Range N/A |
|
Parameter |
Type |
Description |
|---|---|---|
|
id |
String |
Definition The disk ID. Range N/A |
|
links |
Array of Link objects |
Definition The disk URI. Range N/A |
|
name |
String |
Definition The disk name. Range N/A |
|
status |
String |
Definition The disk status. For details, see EVS Disk Status. Range N/A |
|
attachments |
Array of Attachment objects |
Definition The disk attachment information. Range N/A |
|
availability_zone |
String |
Definition The AZ to which the disk belongs. Range N/A |
|
os-vol-host-attr:host |
String |
Definition The reserved field. Range N/A |
|
source_volid |
String |
Definition The source disk ID. This parameter has a value if the disk is created from a source disk. This field is currently not supported. Range N/A |
|
snapshot_id |
String |
Definition The snapshot ID. This parameter has a value if the disk is created from a snapshot. Range N/A |
|
description |
String |
Definition The disk description. Range N/A |
|
created_at |
String |
Definition The time when the disk was created. Range Time format: UTC YYYY-MM-DDTHH:MM:SS.XXXXXX |
|
os-vol-tenant-attr:tenant_id |
String |
Definition The ID of the tenant to which the disk belongs. The tenant ID is the same as the project ID. Range N/A |
|
volume_image_metadata |
Map<String,Object> |
Definition The metadata of the disk image.
NOTE:
For details about the volume_image_metadata field, see Querying Image Details (Native OpenStack API).
Range N/A |
|
volume_type |
String |
Definition The disk type. Range The value can be SSD, SAS, or SATA.
|
|
size |
Integer |
Definition The disk capacity, in GiB. Range N/A |
|
consistencygroup_id |
String |
Definition The reserved field. Range N/A |
|
bootable |
String |
Definition Whether the disk is bootable. Range true: The disk is bootable. false: The disk is not bootable. |
|
metadata |
VolumeMetadata object |
Definition The disk metadata. Range N/A |
|
updated_at |
String |
Definition The time when the disk was updated. Range Time format: UTC YYYY-MM-DDTHH:MM:SS.XXXXXX |
|
encrypted |
Boolean |
Definition This field is currently not supported. Range N/A |
|
replication_status |
String |
Definition The reserved field. Range N/A |
|
os-volume-replication:extended_status |
String |
Definition The reserved field. Range N/A |
|
os-vol-mig-status-attr:migstat |
String |
Definition The reserved field. Range N/A |
|
os-vol-mig-status-attr:name_id |
String |
Definition The reserved field. Range N/A |
|
shareable |
Boolean |
Definition Whether the disk is shareable. This field has been deprecated. Use multiattach. Range
|
|
user_id |
String |
Definition The reserved field. Range N/A |
|
service_type |
String |
Definition The service type. Range
|
|
multiattach |
Boolean |
Definition Whether the disk is shareable. Range
|
|
dedicated_storage_id |
String |
Definition The ID of the dedicated storage pool housing the disk. Range N/A |
|
dedicated_storage_name |
String |
Definition The name of the dedicated storage pool housing the disk. Range N/A |
|
tags |
Map<String,String> |
Definition The disk tags. This field has values if the disk has tags. Or, it is left empty. Range N/A |
|
wwn |
String |
Definition The unique identifier used when attaching the disk. Range N/A |
|
enterprise_project_id |
String |
Definition The ID of the enterprise project that the disk has been added to. For details about enterprise projects and how to obtain enterprise project IDs, see Enterprise Center Overview. Range N/A |
|
Parameter |
Type |
Description |
|---|---|---|
|
href |
String |
Definition The corresponding shortcut link. Range N/A |
|
rel |
String |
Definition The shortcut link marker name. Range N/A |
|
Parameter |
Type |
Description |
|---|---|---|
|
attached_at |
String |
Definition The time when the disk was attached. Range Time format: UTC YYYY-MM-DDTHH:MM:SS.XXXXXX |
|
attachment_id |
String |
Definition The attachment ID. Range N/A |
|
device |
String |
Definition The device name. Range N/A |
|
host_name |
String |
Definition The name of the physical host housing the cloud server to which the disk is attached. Range N/A |
|
id |
String |
Definition The ID of the attached disk. Range N/A |
|
server_id |
String |
Definition The ID of the server to which the disk is attached. Range N/A |
|
volume_id |
String |
Definition The disk ID. Range N/A |
|
Parameter |
Type |
Description |
|---|---|---|
|
__system__cmkid |
String |
Definition 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. Range N/A |
|
__system__encrypted |
String |
Definition 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. Range
|
|
hw:passthrough |
String |
Definition The disk device type. Range
|
|
orderID |
String |
Definition 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 this parameter is not specified, the disk is billed on a pay-per-use basis. Range N/A |
Status code: 400
|
Parameter |
Type |
Description |
|---|---|---|
|
error |
Error object |
Definition The error code returned if an error occurs. For details about the error code, see Error Codes. Range N/A |
|
Parameter |
Type |
Description |
|---|---|---|
|
code |
String |
Definition The error code returned if an error occurs. Range For details about the error code, see Error Codes. |
|
message |
String |
Definition The error message returned if an error occurs. Range N/A |
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
OK
{
"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.
Java
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 81 82 |
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"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .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()); } } } |
Python
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 |
# coding: utf-8 import os 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.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) 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) |
Go
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 |
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") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). 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) } } |
More
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 |
OK |
|
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