华为云用户手册

  • 请求参数 表2 请求Body参数 参数 是否必选 参数类型 描述 attachment_id 否 String 连接唯一标识 route_policy 否 ImportRoutePolicy object 入方向路由策略 表3 ImportRoutePolicy 参数 是否必选 参数类型 描述 import_policy_id 否 String 入方向Ipv4协议路由策略id 最小长度:0 最大长度:36
  • 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 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 DisablePropagationSolution { 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(); DisablePropagationRequest request = new DisablePropagationRequest(); PropagationRequestBody body = new PropagationRequestBody(); body.withAttachmentId("a5b7d209-dc02-4c46-a51f-805eadd3de64"); request.withBody(body); try { DisablePropagationResponse response = client.disablePropagation(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://{erouter_endpoint}/v3/08d5a9564a704afda6039ae2babbef3c/enterprise-router/ad838a5e-dbef-22cc-b1d9-cb46bef77ae8/route-tables/915a14a6-867b-4af7-83d1-70efceb146f9/disable-propagations { "attachment_id" : "a5b7d209-dc02-4c46-a51f-805eadd3de64" }
  • URI GET /v3/{project_id}/enterprise-router/{er_id}/route-tables 表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 状态 is_default_propagation_table 否 Boolean 是否为默认传播路由表 is_default_association_table 否 Boolean 是否为默认关联路由表 sort_key 否 Array 按关键字排序,默认按照id排序,可选值:id|name|state sort_dir 否 Array 返回结果按照升序或降序排列,默认为asc,降序为desc
  • 响应示例 状态码: 200 OK { "route_tables" : [ { "id" : "4ab54142-7c92-48ad-8288-77727a231052", "is_default_association" : false, "is_default_propagation" : false, "name" : "my-router-table1", "description" : "rtb-for-a", "state" : "available", "tags" : [ { "key" : "key", "value" : "value" } ] }, { "id" : "4ab54142-7c92-48ad-8288-77727a231053", "is_default_association" : false, "is_default_propagation" : false, "name" : "my-router-table2", "description" : "rtb-for-b", "state" : "available", "tags" : [ { "key" : "key", "value" : "value" } ] } ], "page_info" : { "next_marker" : "1", "current_count" : 2 }, "request_id" : "915a14a6-867b-4af7-83d1-70efceb146f9" }
  • 响应参数 状态码: 200 表3 响应Body参数 参数 参数类型 描述 route_tables Array of RouteTable objects 路由表列表 request_id String 请求ID page_info PageInfo object 分页查询的信息 表4 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 表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 当前列表中资源数量
  • 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 39 40 41 42 43 # 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 = BatchCreateResourceTagsRequest() listTagsbody = [ Tag( key="key1", value="value1" ), Tag( key="key2", value="value2" ) ] request.body = BatchOperateResourceTagsRequestBody( tags=listTagsbody, action="create" ) response = client.batch_create_resource_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) 批量删除资源标签。 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 # 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 = BatchCreateResourceTagsRequest() listTagsbody = [ Tag( key="key1" ), Tag( key="key2", value="value3" ) ] request.body = BatchOperateResourceTagsRequestBody( tags=listTagsbody, action="delete" ) response = client.batch_create_resource_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 批量添加资源标签。 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 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.BatchCreateResourceTagsRequest{} keyTags:= "key1" valueTags:= "value1" keyTags1:= "key2" valueTags1:= "value2" var listTagsbody = []model.Tag{ { Key: &keyTags, Value: &valueTags, }, { Key: &keyTags1, Value: &valueTags1, }, } request.Body = &model.BatchOperateResourceTagsRequestBody{ Tags: &listTagsbody, Action: model.GetBatchOperateResourceTagsRequestBodyActionEnum().CREATE, } response, err := client.BatchCreateResourceTags(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } 批量删除资源标签。 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 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.BatchCreateResourceTagsRequest{} keyTags:= "key1" keyTags1:= "key2" valueTags:= "value3" var listTagsbody = []model.Tag{ { Key: &keyTags, }, { Key: &keyTags1, Value: &valueTags, }, } request.Body = &model.BatchOperateResourceTagsRequestBody{ Tags: &listTagsbody, Action: model.GetBatchOperateResourceTagsRequestBodyActionEnum().DELETE, } response, err := client.BatchCreateResourceTags(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • 请求示例 批量添加资源标签。 POST https://{erouter-endpoint}/v3/cfa563efb77d4b6d9960781d82530fd8/instance/3320166e-b937-40cc-a35c-02cd3f2b3ee2/tags/action { "action" : "create", "tags" : [ { "key" : "key1", "value" : "value1" }, { "key" : "key2", "value" : "value2" } ] } 批量删除资源标签。 POST https://{erouter-endpoint}/v3/cfa563efb77d4b6d9960781d82530fd8/instance/3320166e-b937-40cc-a35c-02cd3f2b3ee2/tags/action { "action" : "delete", "tags" : [ { "key" : "key1" }, { "key" : "key2", "value" : "value3" } ] }
  • 请求参数 表2 请求Body参数 参数 是否必选 参数类型 描述 action 是 String 功能说明:操作标识。 取值范围: create(创建) delete(删除) tags 否 Array of Tag objects 标签列表。 表3 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
  • URI POST /v3/{project_id}/{resource_type}/{resource_id}/tags/action 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 项目ID resource_id 是 String 资源ID resource_type 是 String 标签资源类型: instance: 企业路由器实例 route-table: 路由表 vpc-attachment: VPC连接 vgw-attachment: 虚拟网关连接 peering-attachment: 对等连接(Peering)连接 vpn-attachment: VPN网关连接 attachments: 所有连接类型
  • 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.ShowAttachmentRequest{} response, err := client.ShowAttachment(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • 响应示例 状态码: 200 OK { "attachment" : { "id" : "b70aee08-c671-4cad-9fd5-7381d163bcc8", "name" : "vpc attachment", "description" : "vpc prod", "state" : "avaliable", "created_at" : "2020-03-11T15:13:31Z", "updated_at" : "2020-03-11T15:13:31Z", "project_id" : "08d5a9564a704afda6039ae2babbef3c", "resource_id" : "b715e131-3371-4e17-a2de-4f669e24439a", "resource_type" : "vpc" }, "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 = ShowAttachmentRequest() response = client.show_attachment(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 ShowAttachmentSolution { 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(); ShowAttachmentRequest request = new ShowAttachmentRequest(); try { ShowAttachmentResponse response = client.showAttachment(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 表2 响应Body参数 参数 参数类型 描述 attachment AttachmentResponse object 连接基本信息详情 request_id String 请求id 表3 AttachmentResponse 参数 参数类型 描述 name String 连接名字 id String 连接ID description String 描述信息 state String 连接状态:pending|available|modifying|deleting|deleted|failed|pending_acceptance|rejected|initiating_request|freezed created_at String 创建时间,格式:YYYY-MM-DDTHH:mm:ss.sssZ updated_at String 更新时间,格式:YYYY-MM-DDTHH:mm:ss.sssZ tags Array of Tag objects 企业路由器关联tag project_id String 项目ID resource_id String 内部连接关联的资源ID resource_type String 内部连接关联的资源类型: vgw:云专线的虚拟网关 vpn:vpn网关 peering:对等连接,通过云连接CC加载不同区域的企业路由器来创建“对等连接(Peering)”连接 vpc:虚拟私有云 resource_project_id String 资源所属项目ID 表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 46 47 48 49 50 51 52 53 54 55 56 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 CreateFlowLogSolution { 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(); CreateFlowLogRequest request = new CreateFlowLogRequest(); CreateFlowLogRequestBody body = new CreateFlowLogRequestBody(); FlowLogRequest flowLogbody = new FlowLogRequest(); flowLogbody.withName("flow-log") .withDescription("flow log test") .withResourceType(FlowLogRequest.ResourceTypeEnum.fromValue("attachment")) .withResourceId("6f83b848-8331-4271-ac0c-ef94b7686402") .withLogGroupId("0139393c-eeb2-49f0-bbd4-c5faec6b1497") .withLogStreamId("d22c3b44-2f71-470f-83f3-96a8af6956ad") .withLogStoreType(FlowLogRequest.LogStoreTypeEnum.fromValue("LTS")); body.withFlowLog(flowLogbody); request.withBody(body); try { CreateFlowLogResponse response = client.createFlowLog(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()); } } }
  • 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.CreateFlowLogRequest{} descriptionFlowLog:= "flow log test" flowLogbody := &model.FlowLogRequest{ Name: "flow-log", Description: &descriptionFlowLog, ResourceType: model.GetFlowLogRequestResourceTypeEnum().ATTACHMENT, ResourceId: "6f83b848-8331-4271-ac0c-ef94b7686402", LogGroupId: "0139393c-eeb2-49f0-bbd4-c5faec6b1497", LogStreamId: "d22c3b44-2f71-470f-83f3-96a8af6956ad", LogStoreType: model.GetFlowLogRequestLogStoreTypeEnum().LTS, } request.Body = &model.CreateFlowLogRequestBody{ FlowLog: flowLogbody, } response, err := client.CreateFlowLog(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • 请求示例 创建流日志 POST https://{erouter_endpoint}/v3/0605767a9980d5762fbcc00b3537e757/enterprise-router/a43c55e9-4911-4030-90e1-5c2bf6ae6fe2/flow-logs { "flow_log" : { "name" : "flow-log", "description" : "flow log test", "resource_type" : "attachment", "resource_id" : "6f83b848-8331-4271-ac0c-ef94b7686402", "log_group_id" : "0139393c-eeb2-49f0-bbd4-c5faec6b1497", "log_stream_id" : "d22c3b44-2f71-470f-83f3-96a8af6956ad", "log_store_type" : "LTS" } }
  • 响应示例 状态码: 202 Accepted { "flow_log" : { "id" : "b216bc1d-5963-41a7-89f9-779a5128c5ac", "name" : "flow_log", "project_id" : "0605767a9980d5762fbcc00b3537e757", "resource_type" : "attachment", "resource_id" : "6f83b848-8331-4271-ac0c-ef94b7686402", "log_group_id" : "0139393c-eeb2-49f0-bbd4-c5faec6b1497", "log_stream_id" : "d22c3b44-2f71-470f-83f3-96a8af6956ad", "log_store_type" : "LTS", "log_aggregation_interval" : 600, "created_at" : "2020-03-11T15:13:31Z", "updated_at" : "2022-03-11T15:13:31Z", "state" : "available", "enabled" : true, "description" : "ER流日志" }, "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 30 31 32 33 34 35 36 37 38 39 40 41 # 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 = CreateFlowLogRequest() flowLogbody = FlowLogRequest( name="flow-log", description="flow log test", resource_type="attachment", resource_id="6f83b848-8331-4271-ac0c-ef94b7686402", log_group_id="0139393c-eeb2-49f0-bbd4-c5faec6b1497", log_stream_id="d22c3b44-2f71-470f-83f3-96a8af6956ad", log_store_type="LTS" ) request.body = CreateFlowLogRequestBody( flow_log=flowLogbody ) response = client.create_flow_log(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
  • 请求参数 表2 请求Header参数 参数 是否必选 参数类型 描述 X-Client-Token 否 String 幂等性标识 最小长度:1 最大长度:64 表3 请求Body参数 参数 是否必选 参数类型 描述 flow_log 是 FlowLogRequest object 创建流日志请求体 表4 FlowLogRequest 参数 是否必选 参数类型 描述 name 是 String 流日志名称 最小长度:1 最大长度:64 description 否 String 流日志描述 最小长度:0 最大长度:255 resource_type 是 String 流日志采集的资源类型: VPC连接 虚拟网关连接 对等连接 resource_id 是 String 要采集的资源ID log_group_id 是 String 日志组ID。请在 云日志 服务中获取,详情请参见《云日志服务用户指南》。 log_stream_id 是 String 日志主题ID。请在云日志服务中获取,详情请参见《云日志服务用户指南》。 log_store_type 是 String 流日志的存储类型: LTS: 云日志服务器存储
  • 响应参数 状态码: 202 表5 响应Header参数 参数 参数类型 描述 X-Client-Token - 幂等性标识 表6 响应Body参数 参数 参数类型 描述 flow_log FlowLog object 流日志详情 request_id String 请求id 表7 FlowLog 参数 参数类型 描述 id String 流日志ID name String 流日志名称 description String 流日志描述 project_id String 流日志任务创建者项目ID resource_type String 采集的资源类型:attachment resource_id String 采集的资源ID log_group_id String 日志组ID log_stream_id String 日志流ID log_store_type String 流日志存储类型:LTS log_aggregation_interval Integer 日志聚合时间,单位s,取值范围:60-600 created_at String 创建时间,格式:YYYY-MM-DDTHH:mm:ss.sssZ updated_at String 更新时间,格式:YYYY-MM-DDTHH:mm:ss.sssZ state String 日志资源状态:pending|available|modifying|deleting|deleted|failed enabled Boolean 日志开关:true|false
  • 支持的授权项 策略包含系统策略和自定义策略,如果系统策略不满足授权要求,管理员可以创建自定义策略,并通过给用户组授予自定义策略来进行精细的访问控制。策略支持的操作与API相对应,授权项列表说明如下: 权限:允许或拒绝对指定资源在特定条件下进行某项操作。 对应API接口:自定义策略实际调用的API接口。 授权项:自定义策略中支持的Action,在自定义策略中的Action中写入授权项,可以实现授权项对应的权限功能。 依赖的授权项:部分Action存在对其他Action的依赖,需要将依赖的Action同时写入授权项,才能实现对应的权限功能。 IAM 项目(Project)/企业项目(Enterprise Project):自定义策略的授权范围,包括IAM项目与企业项目。授权范围如果同时支持IAM项目和企业项目,表示此授权项对应的自定义策略,可以在IAM和企业管理两个服务中给用户组授权并生效。如果仅支持IAM项目,不支持企业项目,表示仅能在IAM中给用户组授权并生效,如果在企业管理中授权,则该自定义策略不生效。管理员可以在授权项列表中查看授权项是否支持IAM项目或企业项目,“√”表示支持,“×”表示暂不支持。关于IAM项目与企业项目的区别,详情请参见:IAM与企业管理的区别。 ER的支持自定义策略授权项如下所示: 企业路由器 VPC连接 其他连接 路由表 关联 传播 路由 流日志 标签 配额管理
  • 响应示例 状态码: 200 OK { "associations" : [ { "id" : "915a14a6-867b-4af7-83d1-70efceb146f9", "route_table_id" : "91c013e2-d65a-474e-9177-c3e1799ca726", "attachment_id" : "a5b7d209-dc02-4c46-a51f-805eadd3de64", "resource_type" : "vpc", "resource_id" : "4e5fe97c-82bc-432e-87d8-06d7e157dffa", "state" : "pending", "created_at" : "2020-03-11T15:13:31", "updated_at" : "2020-03-11T15:13:31", "route_policy" : { "export_policy_id" : "" } } ], "page_info" : { "next_marker" : "1", "current_count" : 1 }, "request_id" : "915a14a6-867b-4af7-83d1-70efceb146f9" }
  • 请求示例 查询路由表的关联信息 GET https://{erouter_endpoint}/v3/08d5a9564a704afda6039ae2babbef3c/enterprise-router/915a14a6-867b-4af7-83d1-70efceb146f5/route-tables/915a14a6-867b-4af7-83d1-70efceb146f9/associations
  • 响应参数 状态码: 200 表3 响应Body参数 参数 参数类型 描述 associations Array of Association objects 路由表关联列表 数组长度:0 - 2000 request_id String 请求ID page_info PageInfo object 分页查询的信息 表4 Association 参数 参数类型 描述 id String 关联唯一标识 最大长度:36 route_table_id String 路由表唯一标识 最大长度:36 attachment_id String 连接唯一标识 最大长度:36 resource_type String vpc:虚拟私有云 vpn:vpn网关 vgw:云专线的虚拟网关 peering:对等连接,通过云连接CC加载不同区域的企业路由器来创建“对等连接(Peering)”连接 resource_id String 连接的资源唯一标识 state String 状态:pending|available|modifying|deleting|deleted|failed created_at String 资源创建时间 采用UTC时间 格式:YYYY-MM-DDTHH:mm:ss.sssZ updated_at String 资源更新时间 采用UTC时间 格式:YYYY-MM-DDTHH:mm:ss.sssZ route_policy ExportRoutePolicy object 出方向路由策略 表5 ExportRoutePolicy 参数 参数类型 描述 export_policy_id String 出方向Ipv4协议路由策略id 最小长度:0 最大长度:36 表6 PageInfo 参数 参数类型 描述 next_marker String 下一个marker标识,为空时表示最后一页 current_count Integer 当前列表中资源数量
  • URI GET /v3/{project_id}/enterprise-router/{er_id}/route-tables/{route_table_id}/associations 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 项目ID er_id 是 String 企业路由器实例ID route_table_id 是 String 路由表ID 表2 Query参数 参数 是否必选 参数类型 描述 limit 否 Integer 每页返回的个数。 取值范围:0~2000。 最小值:0 最大值:2000 marker 否 String 查询的页码id,为空时为查询第一页。 使用说明:必须与limit一起使用。 最小长度:1 最大长度:128 attachment_id 否 Array 连接ID resource_type 否 Array vpc:虚拟私有云 vpn:vpn网关 vgw:云专线的虚拟网关 peering:对等连接,通过云连接CC加载不同区域的企业路由器来创建“对等连接(Peering)”连接 state 否 Array 状态:pending|available|modifying|deleting|deleted|failed sort_key 否 Array 按关键字排序,默认按照id排序,可选值:id|name|state sort_dir 否 Array 返回结果按照升序或降序排列,默认为asc,降序为desc
  • 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.DisableFlowLogRequest{} response, err := client.DisableFlowLog(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • 响应示例 状态码: 202 Accepted { "flow_log" : { "id" : "b216bc1d-5963-41a7-89f9-779a5128c5ac", "name" : "flow_log_update", "project_id" : "0605767a9980d5762fbcc00b3537e757", "resource_type" : "attachment", "resource_id" : "6f83b848-8331-4271-ac0c-ef94b7686402", "log_group_id" : "0139393c-eeb2-49f0-bbd4-c5faec6b1497", "log_stream_id" : "d22c3b44-2f71-470f-83f3-96a8af6956ad", "log_store_type" : "LTS", "log_aggregation_interval" : 600, "created_at" : "2020-03-11T15:13:31Z", "updated_at" : "2022-03-11T15:13:31Z", "state" : "available", "enabled" : true, "description" : "ER流日志" }, "request_id" : "915a14a6-867b-4af7-83d1-70efceb146f9" }
共100000条