云服务器内容精选

  • 响应示例 状态码: 200 List AvailableZone Info Success { "availability_zone" : [ { "region_id" : "cn-north-4", "id" : "cn-north-4a", "type" : "Core", "display_name" : "可用区1", "status" : "Running" }, { "region_id" : "cn-north-4", "id" : "cn-north-4b", "type" : "Core", "display_name" : "可用区2", "status" : "Running" }, { "region_id" : "cn-north-4", "id" : "cn-north-4c", "type" : "Core", "display_name" : "可用区3", "status" : "Running" } ] }
  • 响应参数 状态码: 200 表3 响应Body参数 参数 参数类型 描述 availability_zone Array of AvailabilityZones objects 可用区信息 表4 AvailabilityZones 参数 参数类型 描述 region_id String 可用区ID。 id String 可用分区ID。 display_name String 可用分区显示名称。 status String 可用分区状态。 Running:运行中 type String 可用分区类型。 Core:核心可用区 Dedicated:专属可用区,只对内部客户开放 状态码: 400 表5 响应Body参数 参数 参数类型 描述 error_code String 错误码 error_description String 请求参数错误。 状态码: 401 表6 响应Body参数 参数 参数类型 描述 error_code String 错误码 error_description String 校验TOKEN失败。 状态码: 403 表7 响应Body参数 参数 参数类型 描述 error_code String 错误码 error_description String 租户无权限操作。 状态码: 404 表8 响应Body参数 参数 参数类型 描述 error_code String 错误码 error_description String 没有找到CBH资源。
  • 响应示例 状态码: 200 可用分区的信息。 { "availabilityZoneInfo" : [ { "zoneState" : { "available" : true }, "zoneName" : "az-dc-1" } ] } 状态码: 400 Bad Request { "error" : { "message" : "XXXX", "code" : "XXX" } }
  • 响应参数 状态码: 200 表3 响应Body参数 参数 参数类型 描述 availabilityZoneInfo Array of AzInfo objects 查询请求返回的可用分区列表。 表4 AzInfo 参数 参数类型 描述 zoneName String 可用分区的名字。 zoneState ZoneState object 可用分区的状态。 表5 ZoneState 参数 参数类型 描述 available Boolean 可用分区是否可用。 状态码: 400 表6 响应Body参数 参数 参数类型 描述 error Error object 出现错误时,返回的错误信息。 表7 Error 参数 参数类型 描述 code String 出现错误时,返回的错误码。 错误码和其对应的含义请参考错误码说明。 message String 出现错误时,返回的错误消息。
  • 响应示例 状态码: 200 List AvailableZone Info Success { "availability_zone" : [ { "region_id" : "cn-north-4", "id" : "cn-north-4a", "type" : "Core", "display_name" : "可用区1", "status" : "Running" }, { "region_id" : "cn-north-4", "id" : "cn-north-4b", "type" : "Core", "display_name" : "可用区2", "status" : "Running" }, { "region_id" : "cn-north-4", "id" : "cn-north-4c", "type" : "Core", "display_name" : "可用区3", "status" : "Running" } ] }
  • 响应参数 状态码: 200 表3 响应Body参数 参数 参数类型 描述 availability_zone Array of AvailabilityZones objects 可用区信息 表4 AvailabilityZones 参数 参数类型 描述 region_id String 可用区ID。 id String 可用分区ID。 display_name String 可用分区显示名称。 status String 可用分区状态。 Running:运行中 type String 可用分区类型。 Core:核心可用区 Dedicated:专属可用区,只对内部客户开放 状态码: 400 表5 响应Body参数 参数 参数类型 描述 error_code String 错误码 error_description String 请求参数错误。 状态码: 401 表6 响应Body参数 参数 参数类型 描述 error_code String 错误码 error_description String 校验TOKEN失败。 状态码: 403 表7 响应Body参数 参数 参数类型 描述 error_code String 错误码 error_description String 租户无权限操作。 状态码: 404 表8 响应Body参数 参数 参数类型 描述 error_code String 错误码 error_description String 没有找到CBH资源。
  • 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 = CinderListAvailabilityZonesRequest() response = client.cinder_list_availability_zones(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.CinderListAvailabilityZonesRequest{} response, err := client.CinderListAvailabilityZones(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 CinderListAvailabilityZonesSolution { 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(); CinderListAvailabilityZonesRequest request = new CinderListAvailabilityZonesRequest(); try { CinderListAvailabilityZonesResponse response = client.cinderListAvailabilityZones(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()); } } }