云服务器内容精选

  • 响应示例 状态码: 200 OK { "snapshots" : [ { "created_at" : "2016-02-16T16:54:14.981520", "description" : null, "id" : "b836dc3d-4e10-4ea4-a34c-8f6b0460a583", "metadata" : { }, "name" : "test01", "size" : 1, "status" : "available", "volume_id" : "ba5730ea-8621-4ae8-b702-ff0ffc12c209", "updated_at" : null }, { "created_at" : "2016-02-16T16:54:19.475397", "description" : null, "id" : "83be494d-329e-4a78-8ac5-9af900f48b95", "metadata" : { }, "name" : "test02", "size" : 1, "status" : "available", "volume_id" : "ba5730ea-8621-4ae8-b702-ff0ffc12c209", "updated_at" : null }, { "created_at" : "2016-02-16T16:54:24.367414", "description" : null, "id" : "dd360f46-7593-4d35-8f2c-5566fd0bd79e", "metadata" : { }, "name" : "test03", "size" : 1, "status" : "available", "volume_id" : "ba5730ea-8621-4ae8-b702-ff0ffc12c209", "updated_at" : null }, { "created_at" : "2016-02-16T16:54:29.766740", "description" : null, "id" : "4c29796a-8cf4-4482-9afc-e66da9a81240", "metadata" : { }, "name" : "test04", "size" : 1, "status" : "available", "volume_id" : "ba5730ea-8621-4ae8-b702-ff0ffc12c209", "updated_at" : null } ], "snapshots_links" : null } 状态码: 400 Bad Request { "error" : { "message" : "XXXX", "code" : "XXX" } }
  • URI GET /v2/{project_id}/snapshots 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 项目ID。 获取方法请参见"获取项目ID"。 表2 Query参数 参数 是否必选 参数类型 描述 marker 否 String 分页查询的起始资源id,取值为上一页最后一条查询记录的资源id。 offset 否 Integer 偏移量。 说明: 分页查询快照时使用,与limit配合使用。假如共有30个快照,设置offset为11,limit为10,即为从第12个快照开始查询,一次最多可读取10个快照 limit 否 Integer 返回结果个数限制。 最小值1,最大值1000,默认为1000。返回的结果中记录数不超过limit值。 当租户所有的快照数量大于50个时,为了提升您的查询效率,建议查询的时候使用limit参数,并且参数值最大设置为50。查询示例: GET /v2/xxx/snapshots?limit=50,表示查询第1~50个快照。GET /v2/xxx/snapshots?offset=50&limit=50,表示查询第51~100个快照。 name 否 String 云硬盘快照名称,不支持模糊匹配。最大支持255个字符。 status 否 String 云硬盘快照状态,具体请参见云硬盘快照状态。 volume_id 否 String 云硬盘快照对应的卷ID。
  • Python 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 # 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("cn-north-4")) \ .build() try: request = DeleteSnapshotRequest() response = client.delete_snapshot(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 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 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("cn-north-4")). WithCredential(auth). Build()) request := &model.DeleteSnapshotRequest{} response, err := client.DeleteSnapshot(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • Java 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 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 DeleteSnapshotSolution { 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("cn-north-4")) .build(); DeleteSnapshotRequest request = new DeleteSnapshotRequest(); try { DeleteSnapshotResponse response = client.deleteSnapshot(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()); } } }
  • 请求示例 POST https://{Endpoint}/v2/0536cdee2200d5912f7cc00b877980f1/snapshots/c719b1a7-c85c-4cb5-a721-7694908c2c11/table-restore-check { "case_sensitive" : true, "database" : "postgres", "restore_table_list" : [ { "schema_name" : "postgres", "table_name" : "public" } ], "target_table_list" : [ { "schema_name" : "postgres", "table_name" : "public" } ] }
  • 响应参数 状态码: 200 表4 响应Body参数 参数 参数类型 描述 check_table_name_result CheckTableNameResult object 检查结果。 表5 CheckTableNameResult 参数 参数类型 描述 database String 数据库名称。 restore_table_list Array of strings 恢复源表信息。 target_table_list Array of strings 恢复目的表信息。
  • 请求参数 表2 请求Body参数 参数 是否必选 参数类型 描述 case_sensitive 是 Boolean 名称是否区分大小写。 database 是 String 数据库名称。 restore_table_list 是 Array of TableDetail objects 源表信息。 target_table_list 是 Array of TableDetail objects 目的表信息。 表3 TableDetail 参数 是否必选 参数类型 描述 schema_name 是 String schema名称。 table_name 是 String 表名称。
  • 状态码 状态码 描述 201 创建类的请求已成功。 400 非法请求。 建议直接修改该请求,不要重试该请求。 403 请求被拒绝访问。返回该状态码,表明请求能够到达服务端,且服务端能够理解用户请求,但是拒绝做更多的事情,因为该请求被设置为拒绝访问,建议直接修改该请求,不要重试该请求。 406 服务器无法根据客户端请求的内容特性完成请求。 500 表明服务端能被请求访问到,但是不能理解用户的请求。 501 服务器不支持请求的功能,无法完成请求。