华为云用户手册

  • 响应示例 状态码: 200 OK { "attachments" : [ { "id" : "6f83b848-8331-4271-ac0c-ef94b7686402", "name" : "vpc-001", "description" : "vpc attachment", "resource_id" : "b715e131-3371-4e17-a2de-4f669e24439a", "resource_type" : "vpc", "project_id" : "0605767a9980d5762fbcc00b3537e757", "state" : "available", "created_at" : "2020-03-11T15:13:31Z", "updated_at" : "2020-03-11T15:13:31Z" }, { "id" : "6f83b848-8331-4271-ac0c-ef94b7686403", "name" : "vpc-002", "description" : "for test", "resource_id" : "4b8567f6-358f-4a7f-8cd3-3cbb82c0b25f", "resource_type" : "vpc", "project_id" : "0605767a9980d5762fbcc00b3537e757", "state" : "available", "created_at" : "2020-03-11T15:13:31Z", "updated_at" : "2020-03-11T15:13:31Z" } ], "page_info" : { "next_marker" : "1", "current_count" : 2 }, "request_id" : "b715e131-3371-4e17-a2de-4f669e24439a" }
  • URI GET /v3/{project_id}/enterprise-router/{er_id}/attachments 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 项目ID er_id 是 String 企业路由器实例ID 表2 Query参数 参数 是否必选 参数类型 描述 limit 否 Integer 每页返回的个数。 取值范围:0~2000。 最小值:0 最大值:2000 marker 否 String 查询的页码id,为空时为查询第一页。 使用说明:必须与limit一起使用。 最小长度:1 最大长度:128 state 否 Array 连接状态:pending|available|modifying|deleting|deleted|failed|pending_acceptance|rejected|initiating_request resource_type 否 Array vpc:虚拟私有云 vpn:vpn网关 vgw:云专线的虚拟网关 peering:对等连接,通过云连接CC加载不同区域的企业路由器来创建“对等连接(Peering)”连接 resource_id 否 Array 连接对应的资源ID列表 sort_key 否 Array 按关键字排序,默认按照id排序,可选值:id|name|state sort_dir 否 Array 返回结果按照升序或降序排列,默认为asc,降序为desc
  • 响应示例 状态码: 200 OK { "vpc_attachments" : [ { "id" : "6f83b848-8331-4271-ac0c-ef94b7686402", "name" : "vpc-attach-01", "vpc_id" : "b715e131-3371-4e17-a2de-4f669e24439a", "virsubnet_id" : "aacdc21d-90f9-45ef-ab48-80ec1bbe15b8", "project_id" : "08d5a9564a704afda6039ae2babbef3c", "state" : "available", "created_at" : "2020-03-11T15:13:31Z", "updated_at" : "2020-03-11T15:13:31Z" }, { "id" : "6f83b848-8331-4271-ac0c-ef94b7686402", "name" : "vpc-attach-01", "vpc_id" : "4b8567f6-358f-4a7f-8cd3-3cbb82c0b25f", "virsubnet_id" : "2b55f334-a15e-43a9-ab11-b34c2dbb6fac", "project_id" : "08d5a9564a704afda6039ae2babbef3c", "state" : "available", "created_at" : "2020-03-11T15:13:31Z", "updated_at" : "2020-03-11T15:13:31Z" } ], "page_info" : { "next_marker" : "1", "current_count" : 2 }, "request_id" : "915a14a6-867b-4af7-83d1-70efceb146f9" }
  • 响应参数 状态码: 200 表3 响应Body参数 参数 参数类型 描述 vpc_attachments Array of VpcAttachmentDetails objects VPC连接列表 page_info PageInfo object 分页查询的信息 request_id String 请求ID 表4 VpcAttachmentDetails 参数 参数类型 描述 id String VPC连接ID name String VPC连接名称 vpc_id String VPC id virsubnet_id String VPC子网id auto_create_vpc_routes Boolean 默认为false,当设置true时,会自动为VPC配置10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16三条路由,下一跳指向企业路由器。 缺省值:false state String VPC连接状态:pending|available|modifying|deleting|deleted|failed|initiating_request|rejected|pending_acceptance|freezed created_at String 创建时间,格式:YYYY-MM-DDTHH:mm:ss.sssZ updated_at String 更新时间,格式:YYYY-MM-DDTHH:mm:ss.sssZ tags Array of Tag objects 标签信息 description String VPC连接描述信息 project_id String 项目ID vpc_project_id String vpc所属项目ID 表5 Tag 参数 参数类型 描述 key String 标签键,规则: 1.可用 UTF-8 格式表示的字母(包含中文)、数字和空格,以及字符:下划线“_”,点“.”,冒号“:”,等号“=”,加号“+”,中划线“-”,“@”。 2._sys_开头属于系统标签,租户不能输入。 3.标签key不能为空(长度不能为0)。 4.长度在1-128之间。 最小长度:1 最大长度:128 value String 标签值,规则: 1.可用 UTF-8 格式表示的字母(包含中文)、数字和空格,以及字符:下划线“_”,点“.”,冒号“:”,等号“=”,加号“+”,中划线“-”,“@”。 2.资源标签值可以为空(empty or null)。 3.长度在0-255之间。 最小长度:0 最大长度:255 表6 PageInfo 参数 参数类型 描述 next_marker String 下一个marker标识,为空时表示最后一页 current_count Integer 当前列表中资源数量
  • 请求示例 分页查询VPC连接信息 GET https://{erouter_endpoint}/v3/08d5a9564a704afda6039ae2babbef3c/enterprise-router/vpc-attachments?limit=10 查询全量VPC连接信息 GET https://{erouter_endpoint}/v3/08d5a9564a704afda6039ae2babbef3c/enterprise-router/vpc-attachments
  • URI GET /v3/{project_id}/enterprise-router/{er_id}/vpc-attachments 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 项目ID er_id 是 String 企业路由器实例ID 表2 Query参数 参数 是否必选 参数类型 描述 limit 否 Integer 每页返回的个数。 取值范围:0~2000。 最小值:0 最大值:2000 marker 否 String 查询的页码id,为空时为查询第一页。 使用说明:必须与limit一起使用。 最小长度:1 最大长度:128 state 否 Array 连接状态:pending|available|modifying|deleting|deleted|failed|pending_acceptance|rejected|initiating_request id 否 Array 根据资源ID查询,可同时查询多个。 sort_key 否 Array 按关键字排序,默认按照id排序,可选值:id|name|state sort_dir 否 Array 返回结果按照升序或降序排列,默认为asc,降序为desc vpc_id 否 Array VPC 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 30 31 32 33 34 35 36 37 38 # coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdker.v3.region.er_region import ErRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdker.v3 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 = ErClient.new_builder() \ .with_credentials(credentials) \ .with_region(ErRegion.value_of("cn-north-4")) \ .build() try: request = UpdateEnterpriseRouterRequest() instancebody = UpdateEnterpriseRouter( enable_default_propagation=True, enable_default_association=True, default_propagation_route_table_id="94c2b814-99dc-939a-e811-ae84c61ea3ff", default_association_route_table_id="94c2b814-99dc-939a-e811-ae84c61ea3ff" ) request.body = UpdateEnterpriseRouterRequestBody( instance=instancebody ) response = client.update_enterprise_router(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 36 37 38 39 40 41 42 43 44 45 46 47 48 package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" er "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/er/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/er/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/er/v3/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 := er.NewErClient( er.ErClientBuilder(). WithRegion(region.ValueOf("cn-north-4")). WithCredential(auth). Build()) request := &model.UpdateEnterpriseRouterRequest{} enableDefaultPropagationInstance:= true enableDefaultAssociationInstance:= true defaultPropagationRouteTableIdInstance:= "94c2b814-99dc-939a-e811-ae84c61ea3ff" defaultAssociationRouteTableIdInstance:= "94c2b814-99dc-939a-e811-ae84c61ea3ff" instancebody := &model.UpdateEnterpriseRouter{ EnableDefaultPropagation: &enableDefaultPropagationInstance, EnableDefaultAssociation: &enableDefaultAssociationInstance, DefaultPropagationRouteTableId: &defaultPropagationRouteTableIdInstance, DefaultAssociationRouteTableId: &defaultAssociationRouteTableIdInstance, } request.Body = &model.UpdateEnterpriseRouterRequestBody{ Instance: instancebody, } response, err := client.UpdateEnterpriseRouter(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 46 47 48 49 50 51 52 53 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.er.v3.region.ErRegion; import com.huaweicloud.sdk.er.v3.*; import com.huaweicloud.sdk.er.v3.model.*; public class UpdateEnterpriseRouterSolution { 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); ErClient client = ErClient.newBuilder() .withCredential(auth) .withRegion(ErRegion.valueOf("cn-north-4")) .build(); UpdateEnterpriseRouterRequest request = new UpdateEnterpriseRouterRequest(); UpdateEnterpriseRouterRequestBody body = new UpdateEnterpriseRouterRequestBody(); UpdateEnterpriseRouter instancebody = new UpdateEnterpriseRouter(); instancebody.withEnableDefaultPropagation(true) .withEnableDefaultAssociation(true) .withDefaultPropagationRouteTableId("94c2b814-99dc-939a-e811-ae84c61ea3ff") .withDefaultAssociationRouteTableId("94c2b814-99dc-939a-e811-ae84c61ea3ff"); body.withInstance(instancebody); request.withBody(body); try { UpdateEnterpriseRouterResponse response = client.updateEnterpriseRouter(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()); } } }
  • 响应参数 状态码: 200 表4 响应Body参数 参数 参数类型 描述 instance EnterpriseRouter object 企业路由器 request_id String 请求ID 表5 EnterpriseRouter 参数 参数类型 描述 id String 企业路由器实例的ID name String 企业路由器实例名称 description String 企业路由器实例描述信息 state String 运行状态:pending|available|modifying|deleting|deleted|failed tags Array of Tag objects 标签信息 charge_mode String 计费模式 按需 缺省值:postPaid created_at String 创建时间,格式:YYYY-MM-DDTHH:mm:ss.sssZ updated_at String 更新时间,格式:YYYY-MM-DDTHH:mm:ss.sssZ enterprise_project_id String 企业项目ID project_id String 项目ID asn Long 企业路由器实例的BGP AS号 enable_default_propagation Boolean 是否开启默认路由表传播,默认false不开启 enable_default_association Boolean 是否开启默认路由表关联,默认false不开启 default_propagation_route_table_id String 默认传播路由表id default_association_route_table_id String 默认关联路由表id availability_zone_ids Array of strings 企业路由器所在可用区信息 auto_accept_shared_attachments Boolean 是否自动接受共享连接创建,默认false不开启 表6 Tag 参数 参数类型 描述 key String 标签键,规则: 1.可用 UTF-8 格式表示的字母(包含中文)、数字和空格,以及字符:下划线“_”,点“.”,冒号“:”,等号“=”,加号“+”,中划线“-”,“@”。 2._sys_开头属于系统标签,租户不能输入。 3.标签key不能为空(长度不能为0)。 4.长度在1-128之间。 最小长度:1 最大长度:128 value String 标签值,规则: 1.可用 UTF-8 格式表示的字母(包含中文)、数字和空格,以及字符:下划线“_”,点“.”,冒号“:”,等号“=”,加号“+”,中划线“-”,“@”。 2.资源标签值可以为空(empty or null)。 3.长度在0-255之间。 最小长度:0 最大长度:255
  • 响应示例 状态码: 200 OK { "instance" : { "id" : "94c2b814-99dc-939a-e811-ae84c61ea3ff", "name" : "my_er", "description" : "this is my first enterprise router", "project_id" : "08d5a9564a704afda6039ae2babbef3c", "state" : "pending", "asn" : 64512, "enable_default_association" : true, "enable_default_propagation" : true, "default_propagation_route_table_id" : "94c2b814-99dc-939a-e811-ae84c61ea3ff", "default_association_route_table_id" : "94c2b814-99dc-939a-e811-ae84c61ea3ff", "auto_accept_shared_attachments" : false, "availability_zone_ids" : [ "az1" ], "created_at" : "2019-09-06 02:11:13Z", "updated_at" : "2019-09-06 02:11:13Z" }, "request_id" : "14c2b814-99dc-939b-e81c-ae84c61ea3f7" }
  • 请求示例 更新企业路由器,开启默认路由表关联和默认路由表传播功能,并指定对应的路由表 PUT https://{erouter_endpoint}/v3/08d5a9564a704afda6039ae2babbef3c/enterprise-router/instances/94c2b814-99dc-939a-e811-ae84c61ea3ff { "instance" : { "enable_default_association" : true, "enable_default_propagation" : true, "default_propagation_route_table_id" : "94c2b814-99dc-939a-e811-ae84c61ea3ff", "default_association_route_table_id" : "94c2b814-99dc-939a-e811-ae84c61ea3ff" } }
  • 请求参数 表2 请求Body参数 参数 是否必选 参数类型 描述 instance 否 UpdateEnterpriseRouter object 更新企业路由器请求体 表3 UpdateEnterpriseRouter 参数 是否必选 参数类型 描述 name 否 String 企业路由器实例名称,取值范围:1-64个字符,支持数字、字母、中文、_(下划线)、-(中划线)、.(点) 最小长度:1 最大长度:64 description 否 String 企业路由器实例描述信息 最小长度:0 最大长度:255 enable_default_propagation 否 Boolean 是否开启默认传播 enable_default_association 否 Boolean 是否开启默认关联 default_propagation_route_table_id 否 String 默认传播路由表ID default_association_route_table_id 否 String 默认关联路由表ID auto_accept_shared_attachments 否 Boolean 是否自动接受共享连接创建,默认false不开启
  • Python 在企业路由器的路由表中创建静态路由,该路由不是黑洞路由,目的地址为192.168.0.0/16,下一跳为指定连接 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 # coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdker.v3.region.er_region import ErRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdker.v3 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 = ErClient.new_builder() \ .with_credentials(credentials) \ .with_region(ErRegion.value_of("cn-north-4")) \ .build() try: request = CreateStaticRouteRequest() routebody = CreateRoute( destination="192.168.0.0/16", attachment_id="b70aee08-c671-4cad-9fd5-7381d163bcc8", is_blackhole=False ) request.body = CreateRouteRequestBody( route=routebody ) response = client.create_static_route(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 在企业路由器的路由表中创建静态路由,该路由不是黑洞路由,目的地址为192.168.0.0/16,下一跳为指定连接 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 main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" er "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/er/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/er/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/er/v3/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 := er.NewErClient( er.ErClientBuilder(). WithRegion(region.ValueOf("cn-north-4")). WithCredential(auth). Build()) request := &model.CreateStaticRouteRequest{} attachmentIdRoute:= "b70aee08-c671-4cad-9fd5-7381d163bcc8" isBlackholeRoute:= false routebody := &model.CreateRoute{ Destination: "192.168.0.0/16", AttachmentId: &attachmentIdRoute, IsBlackhole: &isBlackholeRoute, } request.Body = &model.CreateRouteRequestBody{ Route: routebody, } response, err := client.CreateStaticRoute(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • 请求示例 在企业路由器的路由表中创建静态路由,该路由不是黑洞路由,目的地址为192.168.0.0/16,下一跳为指定连接 POST https://{erouter_endpoint}/v3/08d5a9564a704afda6039ae2babbef3c/enterprise-router/route-tables/0d1748a0-5188-11e5-b86f-a51b5f125b84/static-routes { "route" : { "destination" : "192.168.0.0/16", "is_blackhole" : false, "attachment_id" : "b70aee08-c671-4cad-9fd5-7381d163bcc8" } }
  • 响应参数 状态码: 202 表5 响应Header参数 参数 参数类型 描述 X-Client-Token - 幂等性标识 表6 响应Body参数 参数 参数类型 描述 route Route object 路由表项 request_id String 请求ID 表7 Route 参数 参数类型 描述 id String 路由id type String 路由类型:static state String 路由状态:pending|available|modifying|deleting|deleted|failed is_blackhole Boolean 是否为黑洞路由 destination String 路由目的地址 attachments Array of RouteAttachment objects 下一跳列表 route_table_id String 路由表id created_at String 创建时间,格式:YYYY-MM-DDTHH:mm:ss.sssZ updated_at String 更新时间,格式:YYYY-MM-DDTHH:mm:ss.sssZ 表8 RouteAttachment 参数 参数类型 描述 resource_id String 连接关联的资源ID resource_type String 连接关联的资源类型: vpc:虚拟私有云 vpn:vpn网关 vgw:云专线的虚拟网关 peering:对等连接,通过云连接CC加载不同区域的企业路由器来创建“对等连接(Peering)”连接 attachment_id String 连接ID
  • Java 在企业路由器的路由表中创建静态路由,该路由不是黑洞路由,目的地址为192.168.0.0/16,下一跳为指定连接 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 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.er.v3.region.ErRegion; import com.huaweicloud.sdk.er.v3.*; import com.huaweicloud.sdk.er.v3.model.*; public class CreateStaticRouteSolution { 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); ErClient client = ErClient.newBuilder() .withCredential(auth) .withRegion(ErRegion.valueOf("cn-north-4")) .build(); CreateStaticRouteRequest request = new CreateStaticRouteRequest(); CreateRouteRequestBody body = new CreateRouteRequestBody(); CreateRoute routebody = new CreateRoute(); routebody.withDestination("192.168.0.0/16") .withAttachmentId("b70aee08-c671-4cad-9fd5-7381d163bcc8") .withIsBlackhole(false); body.withRoute(routebody); request.withBody(body); try { CreateStaticRouteResponse response = client.createStaticRoute(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()); } } }
  • 请求参数 表2 请求Header参数 参数 是否必选 参数类型 描述 X-Client-Token 否 String 幂等性标识 最小长度:1 最大长度:64 表3 请求Body参数 参数 是否必选 参数类型 描述 route 是 CreateRoute object 创建路由请求体 表4 CreateRoute 参数 是否必选 参数类型 描述 destination 是 String 路由目的地址 最小长度:0 最大长度:256 attachment_id 否 String 路由下一跳指向的连接ID is_blackhole 否 Boolean 是否为黑洞路由,默认为false
  • 响应示例 状态码: 202 Accepted { "route" : { "id" : "9b3b38a9-1c9d-4f01-9429-81af6b545289", "type" : "static", "destination" : "192.168.0.0/16", "description" : "static route", "attachments" : [ { "resource_id" : "9c4ab06a-0ab4-4fad-93a8-f733f3a4433d", "resource_type" : "vpc", "attachment_id" : "b70aee08-c671-4cad-9fd5-7381d163bcc8" } ], "route_table_id" : "0d1748a0-5188-11e5-b86f-a51b5f125b84", "is_blackhole" : false, "state" : "pending", "created_at" : "2020-03-11T15:13:31Z", "updated_at" : "2020-03-11T15:13:31Z" }, "request_id" : "915a14a6-867b-4af7-83d1-70efceb146f9" }
  • 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" er "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/er/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/er/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/er/v3/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 := er.NewErClient( er.ErClientBuilder(). WithRegion(region.ValueOf("cn-north-4")). WithCredential(auth). Build()) request := &model.ShowRouteTableRequest{} response, err := client.ShowRouteTable(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • 响应参数 状态码: 200 表2 响应Body参数 参数 参数类型 描述 route_table RouteTable object 路由表 request_id String 请求ID 表3 RouteTable 参数 参数类型 描述 id String 路由表的id name String 路由表名字 description String 描述信息 is_default_association Boolean 是否为默认关联的路由表 缺省值:false is_default_propagation Boolean 是否为默认传递路由表 state String 路由表状态,支持的状态有pending | available | deleting | deleted | failed tags Array of Tag objects 标签 created_at String 创建时间,格式:YYYY-MM-DDTHH:mm:ss.sssZ updated_at String 更新时间,格式:YYYY-MM-DDTHH:mm:ss.sssZ 表4 Tag 参数 参数类型 描述 key String 标签键,规则: 1.可用 UTF-8 格式表示的字母(包含中文)、数字和空格,以及字符:下划线“_”,点“.”,冒号“:”,等号“=”,加号“+”,中划线“-”,“@”。 2._sys_开头属于系统标签,租户不能输入。 3.标签key不能为空(长度不能为0)。 4.长度在1-128之间。 最小长度:1 最大长度:128 value String 标签值,规则: 1.可用 UTF-8 格式表示的字母(包含中文)、数字和空格,以及字符:下划线“_”,点“.”,冒号“:”,等号“=”,加号“+”,中划线“-”,“@”。 2.资源标签值可以为空(empty or null)。 3.长度在0-255之间。 最小长度:0 最大长度:255
  • 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.er.v3.region.ErRegion; import com.huaweicloud.sdk.er.v3.*; import com.huaweicloud.sdk.er.v3.model.*; public class ShowRouteTableSolution { 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); ErClient client = ErClient.newBuilder() .withCredential(auth) .withRegion(ErRegion.valueOf("cn-north-4")) .build(); ShowRouteTableRequest request = new ShowRouteTableRequest(); try { ShowRouteTableResponse response = client.showRouteTable(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()); } } }
  • 响应示例 状态码: 200 OK { "route_table" : { "id" : "4ab54142-7c92-48ad-8288-77727a231052", "name" : "my-route-table", "description" : "rtb-for-a", "is_default_association" : false, "is_default_propagation" : false, "state" : "available", "created_at" : "2020-03-11T15:13:31Z", "updated_at" : "2020-03-11T15:13:31Z" }, "request_id" : "915a14a6-867b-4af7-83d1-70efceb146f9" }
  • 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 huaweicloudsdker.v3.region.er_region import ErRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdker.v3 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 = ErClient.new_builder() \ .with_credentials(credentials) \ .with_region(ErRegion.value_of("cn-north-4")) \ .build() try: request = ShowRouteTableRequest() response = client.show_route_table(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
  • 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.er.v3.region.ErRegion; import com.huaweicloud.sdk.er.v3.*; import com.huaweicloud.sdk.er.v3.model.*; public class ShowEnterpriseRouterSolution { 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); ErClient client = ErClient.newBuilder() .withCredential(auth) .withRegion(ErRegion.valueOf("cn-north-4")) .build(); ShowEnterpriseRouterRequest request = new ShowEnterpriseRouterRequest(); try { ShowEnterpriseRouterResponse response = client.showEnterpriseRouter(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()); } } }
  • 响应示例 状态码: 200 OK { "instance" : { "id" : "94c2b814-99dc-939a-e811-ae84c61ea3ff", "name" : "my_er", "description" : "this is my first enterprise router", "project_id" : "08d5a9564a704afda6039ae2babbef3c", "state" : "pending", "asn" : 64512, "enable_default_association" : true, "enable_default_propagation" : true, "default_association_route_table_id" : "7f7f738f-453c-40b1-be26-28e7b9e390c1", "default_propagation_route_table_id" : "7f7f738f-453c-40b1-be26-28e7b9e390c1", "auto_accept_shared_attachments" : false, "availability_zone_ids" : [ "az1" ], "created_at" : "2019-09-06 02:11:13Z", "updated_at" : "2019-09-06 02:11:13Z" }, "request_id" : "14c2b814-99dc-939b-e81c-ae84c61ea3f7" }
  • 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" er "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/er/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/er/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/er/v3/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 := er.NewErClient( er.ErClientBuilder(). WithRegion(region.ValueOf("cn-north-4")). WithCredential(auth). Build()) request := &model.ShowEnterpriseRouterRequest{} response, err := client.ShowEnterpriseRouter(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • 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 huaweicloudsdker.v3.region.er_region import ErRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdker.v3 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 = ErClient.new_builder() \ .with_credentials(credentials) \ .with_region(ErRegion.value_of("cn-north-4")) \ .build() try: request = ShowEnterpriseRouterRequest() response = client.show_enterprise_router(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
  • 响应参数 状态码: 200 表2 响应Body参数 参数 参数类型 描述 instance EnterpriseRouter object 企业路由器 request_id String 请求ID 表3 EnterpriseRouter 参数 参数类型 描述 id String 企业路由器实例的ID name String 企业路由器实例名称 description String 企业路由器实例描述信息 state String 运行状态:pending|available|modifying|deleting|deleted|failed tags Array of Tag objects 标签信息 charge_mode String 计费模式 按需 缺省值:postPaid created_at String 创建时间,格式:YYYY-MM-DDTHH:mm:ss.sssZ updated_at String 更新时间,格式:YYYY-MM-DDTHH:mm:ss.sssZ enterprise_project_id String 企业项目ID project_id String 项目ID asn Long 企业路由器实例的BGP AS号 enable_default_propagation Boolean 是否开启默认路由表传播,默认false不开启 enable_default_association Boolean 是否开启默认路由表关联,默认false不开启 default_propagation_route_table_id String 默认传播路由表id default_association_route_table_id String 默认关联路由表id availability_zone_ids Array of strings 企业路由器所在可用区信息 auto_accept_shared_attachments Boolean 是否自动接受共享连接创建,默认false不开启 表4 Tag 参数 参数类型 描述 key String 标签键,规则: 1.可用 UTF-8 格式表示的字母(包含中文)、数字和空格,以及字符:下划线“_”,点“.”,冒号“:”,等号“=”,加号“+”,中划线“-”,“@”。 2._sys_开头属于系统标签,租户不能输入。 3.标签key不能为空(长度不能为0)。 4.长度在1-128之间。 最小长度:1 最大长度:128 value String 标签值,规则: 1.可用 UTF-8 格式表示的字母(包含中文)、数字和空格,以及字符:下划线“_”,点“.”,冒号“:”,等号“=”,加号“+”,中划线“-”,“@”。 2.资源标签值可以为空(empty or null)。 3.长度在0-255之间。 最小长度:0 最大长度:255
共100000条