查询云硬盘快照详情列表
功能介绍
查询云硬盘快照详情列表。
调用方法
请参见如何调用API。
URI
GET /v2/{project_id}/cloudsnapshots/detail
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
项目ID。 获取方法请参见"获取项目ID"。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
offset |
否 |
Integer |
偏移量。 说明:分页查询快照时使用,与limit配合使用。假如共有30个快照,设置offset为11,limit为10,即为从第12个快照开始查询,一次最多可读取10个快照。 |
limit |
否 |
Integer |
返回结果个数限制,值为大于0的整数。默认值为1000。 |
name |
否 |
String |
云硬盘快照名称。最大支持64个字符。 |
status |
否 |
String |
云硬盘快照状态,具体请参见云硬盘快照状态。 |
volume_id |
否 |
String |
快照所属云硬盘的ID。 |
availability_zone |
否 |
String |
快照所属云硬盘的可用区。 |
id |
否 |
String |
指定快照id进行过滤。可以传入多个id过滤查询,格式:id=id1&id=id2&id=id3 |
dedicated_storage_name |
否 |
String |
专属存储的名称。 |
dedicated_storage_id |
否 |
String |
专属存储ID。 |
service_type |
否 |
String |
服务类型。仅支持EVS、DSS、DESS。 |
enterprise_project_id |
否 |
String |
指定企业项目id进行过滤。 传入“all_granted_eps”,代表查询权限范围内的所有企业项目下的云硬盘。
说明:
关于企业项目ID的获取及企业项目特性的详细信息,请参考:"企业管理用户指南"。 |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 |
响应参数
状态码: 200
参数 |
参数类型 |
描述 |
---|---|---|
count |
Integer |
快照的总数量,不受limi参数的影响。 |
snapshots |
Array of SnapshotList objects |
快照信息。 |
snapshots_links |
Array of Link objects |
云硬盘快照列表查询位置标记。当查询时指定limit时会返回该字段,返回该字段表示本次查询只查出了部分云硬盘快照信息。 |
参数 |
参数类型 |
描述 |
---|---|---|
id |
String |
云硬盘快照ID。 |
status |
String |
云硬盘快照的状态。 |
name |
String |
云硬盘快照名称。 |
description |
String |
云硬盘快照描述信息。 |
created_at |
String |
云硬盘快照创建时间。 |
updated_at |
String |
云硬盘快照更新时间。 |
metadata |
Map<String,String> |
云硬盘快照的元数据信息。 |
volume_id |
String |
快照所属的云硬盘。 |
size |
Integer |
云硬盘快照大小。 |
os-extended-snapshot-attributes:project_id |
String |
项目ID。 |
os-extended-snapshot-attributes:progress |
String |
快照进度。 |
dedicated_storage_id |
String |
专属存储ID。 |
dedicated_storage_name |
String |
专属存储名称。 |
service_type |
String |
服务类型。 |
状态码: 400
请求示例
-
查询快照id为c311bb8d-17f1-4e99-aaf9-e132c0391a73和c7691083-15fa-4045-956c-2bcbfe1b9976的快照详情,从第1条记录开始查询,返回结果中的记录数不超过100个。
GET https://{endpoint}/v2/{project_id}/cloudsnapshots/detail?id=c311bb8d-17f1-4e99-aaf9-e132c0391a73&id=c7691083-15fa-4045-956c-2bcbfe1b9976&offset=0&limit=100
-
查询id为f8c7cce6-ec47-43ca-9297-b5604668b08f的云硬盘的所有快照详情。
GET https://{endpoint}/v2/{project_id}/cloudsnapshots/detail?volume_id=f8c7cce6-ec47-43ca-9297-b5604668b08f&service_type=EVS
响应示例
状态码: 200
OK
{ "count" : 3, "snapshots_links" : [ { "href" : "https://{endpoint}/v2/20a68d6b7a124ae2b6b8a22046ee5966/cloudsnapshots/detail?limit=1&marker=fc05d5d7-7e99-42fb-b6f2-9ddd1b990e67", "rel" : "next" } ], "snapshots" : [ { "status" : "available", "updated_at" : "2018-06-06T10:58:47.349051", "volume_id" : "f687bd70-37b3-4f00-a900-0ba1cfaa5196", "id" : "fc05d5d7-7e99-42fb-b6f2-9ddd1b990e67", "size" : 1, "os-extended-snapshot-attributes:progress" : "100%", "name" : "test03", "os-extended-snapshot-attributes:project_id" : "20a68d6b7a124ae2b6b8a22046ee5966", "service_type" : "EVS", "created_at" : "2018-05-30T03:14:44.457975", "metadata" : { } } ] }
状态码: 400
Bad Request
{ "error" : { "message" : "XXXX", "code" : "XXX" } }
SDK代码示例
SDK代码示例如下。
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.evs.v2.region.EvsRegion; import com.huaweicloud.sdk.evs.v2.*; import com.huaweicloud.sdk.evs.v2.model.*; public class ListSnapshotsSolution { 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(); ListSnapshotsRequest request = new ListSnapshotsRequest(); try { ListSnapshotsResponse response = client.listSnapshots(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 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 = ListSnapshotsRequest() response = client.list_snapshots(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" 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.ListSnapshotsRequest{} response, err := client.ListSnapshots(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
OK |
400 |
Bad Request |
错误码
请参见错误码。