华为云用户手册

  • 响应参数 状态码: 200 表4 响应Body参数 参数 参数类型 描述 data Array of DailyData objects 24小时内的流量数据 数组长度:288 - 288 表5 DailyData 参数 参数类型 描述 period_start Long 开始时间 最小值:1 最大值:9999999999999 bps_in Integer 入流量(bit/s) 最小值:0 最大值:2147483647 bps_attack Long 攻击流量(bit/s) 最小值:0 最大值:2147483647 total_bps Long 总流量 最小值:0 最大值:2147483647 pps_in Long 入报文速率(个/s) 最小值:0 最大值:2147483647 pps_attack Long 攻击文速率(个/s) 最小值:0 最大值:2147483647 total_pps Long 总报文速率 最小值:0 最大值:2147483647
  • 请求参数 表3 请求Header参数 参数 是否必选 参数类型 描述 X-Auth-Token 是 String 用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 最小长度:32 最大长度:2097152 Content-Type 是 String Content-Type请求头 缺省值:application/json;charset=utf8 最小长度:1 最大长度:255
  • 响应示例 状态码: 200 请求已成功 { "data" : [ { "period_start" : 1606188642720, "bps_in" : 0, "bps_attack" : 0, "total_bps" : 0, "pps_in" : 0, "pps_attack" : 0, "total_pps" : 0 } ] }
  • URI GET /v1/{project_id}/antiddos/{floating_ip_id}/daily 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 项目id 最小长度:32 最大长度:64 floating_ip_id 是 String 用户EIP对应的ID 最小长度:32 最大长度:64 表2 Query参数 参数 是否必选 参数类型 描述 ip 否 String 用户EIP 最小长度:7 最大长度:128
  • 修订记录 发布日期 修改说明 2023-01-08 第五次正式发布。 新增上传/修改域名对应证书接口。 新增修改域名WEB基础防护开关/CC防护开关接口。 新增查询高防回源IP段列表接口。 新增高防实例添加黑白名单接口。 新增高防实例删除黑白名单接口。 2022-06-17 第四次正式发布。 修改参数: 查询Anti-DDoS任务 更新Anti-DDoS服务 配置Anti-DDoS默认防护策略 查询Anti-DDoS默认防护策略 参数“traffic_pos_id”取值范围修改为“1~9或取值99”;参数“cleaning_access_pos_id”取值范围修改为“1~9或取值99” 2021-12-06 第三次正式发布。 “查询Anti-DDoS任务”章节,修改内容描述。 2021-04-19 第二次正式发布。 修改章节标题。 2020-12-31 第一次正式发布。
  • 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 huaweicloudsdkantiddos.v1.region.antiddos_region import AntiDDoSRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkantiddos.v1 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 = AntiDDoSClient.new_builder() \ .with_credentials(credentials) \ .with_region(AntiDDoSRegion.value_of("cn-north-4")) \ .build() try: request = ListNewConfigsRequest() response = client.list_new_configs(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" antiddos "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/antiddos/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/antiddos/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/antiddos/v1/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 := antiddos.NewAntiDDoSClient( antiddos.AntiDDoSClientBuilder(). WithRegion(region.ValueOf("cn-north-4")). WithCredential(auth). Build()) request := &model.ListNewConfigsRequest{} response, err := client.ListNewConfigs(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.antiddos.v1.region.AntiDDoSRegion; import com.huaweicloud.sdk.antiddos.v1.*; import com.huaweicloud.sdk.antiddos.v1.model.*; public class ListNewConfigsSolution { 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); AntiDDoSClient client = AntiDDoSClient.newBuilder() .withCredential(auth) .withRegion(AntiDDoSRegion.valueOf("cn-north-4")) .build(); ListNewConfigsRequest request = new ListNewConfigsRequest(); try { ListNewConfigsResponse response = client.listNewConfigs(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 表3 响应Body参数 参数 参数类型 描述 traffic_limited_list Array of TriggerBpsDict objects 流量限制列表 http_limited_list Array of TriggerQpsDict objects HTTP限制列表 connection_limited_list Array of CleanLimitDict objects 连接数限制列表 extend_ddos_config Array of ExtendDDoSSet objects 扩展配置列表 表4 TriggerBpsDict 参数 参数类型 描述 traffic_pos_id Long 流量分段ID traffic_per_second Long 每秒流量(Mbit/s)阈值 packet_per_second Long 每秒报文数(个/s)阈值 表5 TriggerQpsDict 参数 参数类型 描述 http_request_pos_id Long HTTP请求数分段ID http_packet_per_second Long 每秒HTTP请求数(个/s)阈值 表6 CleanLimitDict 参数 参数类型 描述 cleaning_access_pos_id Long 清洗时访问限制分段ID new_connection_limited Long 单一源IP新建连接个数 total_connection_limited Long 单一源IP连接数总个数 表7 ExtendDDoSSet 参数 参数类型 描述 SetID Long 配置分段ID new_connection_limited Long 单一源IP新建连接个数 total_connection_limited Long 单一源IP连接数总个数 http_packet_per_second Long 每秒HTTP请求数(个/s)阈值 traffic_per_second Long 每秒流量(Mbit/s)阈值 packet_per_second Long 每秒报文数(个/s)阈值
  • 响应示例 状态码: 200 请求已成功 { "traffic_limited_list" : [ { "traffic_pos_id" : 1, "traffic_per_second" : 10, "packet_per_second" : 2000 }, { "traffic_pos_id" : 2, "traffic_per_second" : 30, "packet_per_second" : 6000 }, { "traffic_pos_id" : 3, "traffic_per_second" : 50, "packet_per_second" : 10000 }, { "traffic_pos_id" : 4, "traffic_per_second" : 70, "packet_per_second" : 15000 }, { "traffic_pos_id" : 5, "traffic_per_second" : 100, "packet_per_second" : 20000 }, { "traffic_pos_id" : 6, "traffic_per_second" : 150, "packet_per_second" : 25000 }, { "traffic_pos_id" : 7, "traffic_per_second" : 200, "packet_per_second" : 35000 }, { "traffic_pos_id" : 8, "traffic_per_second" : 250, "packet_per_second" : 50000 }, { "traffic_pos_id" : 9, "traffic_per_second" : 300, "packet_per_second" : 70000 }, { "traffic_pos_id" : 88, "traffic_per_second" : 1000, "packet_per_second" : 300000 } ], "http_limited_list" : [ { "http_request_pos_id" : 1, "http_packet_per_second" : 100 }, { "http_request_pos_id" : 2, "http_packet_per_second" : 150 }, { "http_request_pos_id" : 3, "http_packet_per_second" : 240 }, { "http_request_pos_id" : 4, "http_packet_per_second" : 350 }, { "http_request_pos_id" : 5, "http_packet_per_second" : 480 }, { "http_request_pos_id" : 6, "http_packet_per_second" : 550 }, { "http_request_pos_id" : 7, "http_packet_per_second" : 700 }, { "http_request_pos_id" : 8, "http_packet_per_second" : 850 }, { "http_request_pos_id" : 9, "http_packet_per_second" : 1000 }, { "http_request_pos_id" : 10, "http_packet_per_second" : 1500 }, { "http_request_pos_id" : 11, "http_packet_per_second" : 2000 }, { "http_request_pos_id" : 12, "http_packet_per_second" : 3000 }, { "http_request_pos_id" : 13, "http_packet_per_second" : 5000 }, { "http_request_pos_id" : 14, "http_packet_per_second" : 10000 }, { "http_request_pos_id" : 15, "http_packet_per_second" : 20000 } ], "connection_limited_list" : [ { "cleaning_access_pos_id" : 1, "new_connection_limited" : 10, "total_connection_limited" : 30 }, { "cleaning_access_pos_id" : 2, "new_connection_limited" : 20, "total_connection_limited" : 100 }, { "cleaning_access_pos_id" : 3, "new_connection_limited" : 30, "total_connection_limited" : 200 }, { "cleaning_access_pos_id" : 4, "new_connection_limited" : 40, "total_connection_limited" : 250 }, { "cleaning_access_pos_id" : 5, "new_connection_limited" : 50, "total_connection_limited" : 300 }, { "cleaning_access_pos_id" : 6, "new_connection_limited" : 60, "total_connection_limited" : 500 }, { "cleaning_access_pos_id" : 7, "new_connection_limited" : 70, "total_connection_limited" : 600 }, { "cleaning_access_pos_id" : 8, "new_connection_limited" : 80, "total_connection_limited" : 700 } ], "extend_ddos_config" : [ ] }
  • 请求参数 表2 请求Header参数 参数 是否必选 参数类型 描述 X-Auth-Token 是 String 用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 最小长度:32 最大长度:2097152 Content-Type 是 String Content-Type请求头 缺省值:application/json;charset=utf8 最小长度:1 最大长度:255
  • 响应示例 状态码: 200 Domain Information { "count" : 2, "items" : [ { "cname" : "8bacXXXX73fd.huaweisafedns.cn", "protocol" : [ "HTTP" ], "domain_id" : "0d3eXXXX6c42", "domain_name" : "www.test2.com", "waf_status" : 1, "real_server_type" : 1, "real_servers" : "*.test2.com", "enterprise_project_id" : "0" }, { "cname" : "1604XXXXc833.huaweisafedns.cn", "protocol" : [ "HTTPS", "HTTP" ], "domain_id" : "a115XXXXfafe", "domain_name" : "test1.com", "waf_status" : 1, "real_server_type" : 1, "real_servers" : "test1.com", "enterprise_project_id" : "51bcXXXX-XXXX-XXXX-XXXX-XXXXa06b" } ] }
  • 响应参数 状态码: 200 表2 响应Body参数 参数 参数类型 描述 count Integer 域名总数 items Array of DomainInfo objects 域名列表 表3 DomainInfo 参数 参数类型 描述 domain_id String 域名ID domain_name String 域名 cname String 域名cname protocol Array of strings 域名协议 real_server_type Integer 源站类型 real_servers String 源站 waf_status Integer waf防护状态 enterprise_project_id String 企业项目ID
  • Anti-DDoS错误码 更多服务错误码请参见API错误中心。 状态码 错误码 错误信息 描述 处理措施 200 Anti-DDoS.0 Succeeded 成功 无需处理 200 Anti-DDoS.10000000 The task has been received and is being handled 任务已接收,正在处理 无需处理 400 Anti-DDoS.10000001 Enter a valid request message 请求消息格式非法 检查参数 400 Anti-DDoS.10001008 An incorrect task ID is used 不正确的任务ID 检查参数 400 Anti-DDoS.10001010 Invalid time 时间非法 检查参数 401 Anti-DDoS.10000004 Public test service denied 公测服务被拒绝 申请公测 403 Anti-DDoS.10000002 Failed to authenticate the token in the request 请求所带的Token认证失败 重新申请Token 403 Anti-DDoS.10000009 The account is restricted 账户受限 申请权限 403 Anti-DDoS.10000010 The account is frozen 账户冻结 申请解冻 403 Anti-DDoS.10000012 Unknown user type 未知用户类型 申请权限 403 Anti-DDoS.10000016 VPC access failed or EIP is not exist 访问VPC平台异常或EIP不存在 联系管理员 403 Anti-DDoS.10000030 You have not been authenticated. Perform real-name authentication first. 您尚未认证,请先进行实名认证。 实名认证 403 Anti-DDoS.10001009 The operation permission is restricted 操作权限受限 申请权限 403 Anti-DDoS.11000001 Access to the database is rejected 数据库访问被拒绝 联系管理员 500 Anti-DDoS.11000000 Internal system exception. Contact technical support engineers 系统内部异常,请联系技术支持人员 联系管理员 父主题: 附录
  • 响应示例 状态码: 200 OK { "total" : 1, "blocking_list" : [ { "ip" : "100.93.15.45", "status" : "blocking", "blocking_time" : 1672110604844, "estimated_unblocking_time" : 1672114204823 } ] }
  • 响应参数 状态码: 200 表3 响应Body参数 参数 参数类型 描述 blocking_list Array of blocking_list objects 封堵列表响应体 数组长度:0 - 2000 total Integer 总数 最小值:0 最大值:2000 表4 blocking_list 参数 参数类型 描述 ip String ip地址 最小长度:7 最大长度:128 blocking_time Long 封堵时间 最小值:0 最大值:9223372036854775807 estimated_unblocking_time Long 预计解封时间 最小值:0 最大值:9223372036854775807 status String 状态。unblocking:解封中;success:成功;failed:失败
  • 请求参数 表2 请求Header参数 参数 是否必选 参数类型 描述 X-Auth-Token 是 String 用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 最小长度:32 最大长度:2097152 Content-Type 是 String Content-Type 缺省值:application/json;charset=utf8 最小长度:1 最大长度:255 表3 请求Body参数 参数 是否必选 参数类型 描述 name 是 String 名字 最小长度:1 最大长度:255
  • Token认证 Token的有效期为24小时,需要使用一个Token鉴权时,可以先缓存起来,避免频繁调用。 Token在计算机系统中代表令牌(临时)的意思,拥有Token就代表拥有某种权限。Token认证就是在调用API的时候将Token加到请求消息头,从而通过身份认证,获得操作API的权限。 Token可通过调用获取用户Token接口获取,调用本服务API需要project级别的Token,即调用获取用户Token接口时,请求body中auth.scope的取值需要选择project,如下所示。 { "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "name": "username", "password": "********", "domain": { "name": "domainname" } } } }, "scope": { "project": { "name": "xxxxxxxx" } } } } 获取Token后,再调用其他接口时,您需要在请求消息头中添加“X-Auth-Token”,其值即为Token。例如Token值为“ABCDEFJ....”,则调用接口时将“X-Auth-Token: ABCDEFJ....”加到请求消息头即可,如下所示。 Content-Type: application/json X-Auth-Token: ABCDEFJ....
  • AK/SK认证 AK/SK签名认证方式仅支持消息体大小12MB以内,12MB以上的请求请使用Token认证。 AK/SK认证就是使用AK/SK对请求进行签名,在请求时将签名信息添加到消息头,从而通过身份认证。 AK(Access Key ID):访问密钥ID。与私有访问密钥关联的唯一标识符;访问密钥ID和私有访问密钥一起使用,对请求进行加密签名。 SK(Secret Access Key):与访问密钥ID结合使用的密钥,对请求进行加密签名,可标识发送方,并防止请求被修改。 使用AK/SK认证时,您可以基于签名算法使用AK/SK对请求进行签名,也可以使用专门的签名SDK对请求进行签名。详细的签名方法和SDK使用方法请参见API签名指南。 签名SDK只提供签名功能,与服务提供的SDK不同,使用时请注意。
  • 请求参数 表2 请求Header参数 参数 是否必选 参数类型 描述 X-Auth-Token 是 String 用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 最小长度:32 最大长度:2097152 Content-Type 是 String Content-Type 缺省值:application/json;charset=utf8 最小长度:1 最大长度:255 表3 请求Body参数 参数 是否必选 参数类型 描述 type 是 String 类型。white:白名单,black:黑名单 ip_list 是 Array of strings ip列表 最小长度:7 最大长度:128 数组长度:0 - 2147483647
  • 请求参数 表2 请求Header参数 参数 是否必选 参数类型 描述 X-Auth-Token 是 String token 最小长度:32 最大长度:2097152 Content-Type 是 String Content-Type 缺省值:application/json;charset=utf8 最小长度:1 最大长度:128 表3 请求Body参数 参数 是否必选 参数类型 描述 rules 否 Array of TransferRuleBody objects 批量转发规则 表4 TransferRuleBody 参数 是否必选 参数类型 描述 forward_protocol 否 String 转发协议,tcp或udp forward_port 否 Integer 转发端口 最小值:1 最大值:65536 source_port 否 Integer 源站端口 最小值:1 最大值:65536 source_ip 否 String 源站IP,多个IP用逗号隔开,限制20个IP 最小值:1 最大值:256
  • 请求示例 为指定高防实例IP创建两个TCP转发协议。 POST https://{endpoint}/v1/aad/instances/{instance_id}/{ip}/rules/batch-create { "rules" : [ { "forward_protocol" : "tcp", "forward_port" : 66, "source_port" : 66, "source_ip" : "6.6.1.1" }, { "forward_protocol" : "tcp", "forward_port" : 33, "source_port" : 33, "source_ip" : "3.3.1.1" } ] }
  • 响应示例 状态码: 200 高防实例列表 { "count" : 2, "items" : [ { "ips" : [ { "ip" : "103.239.246.6", "ip_id" : "4f1XXXX-XXXX-XXXX-XXXX-XXXXd4b1", "basic_bandwidth" : 10, "elastic_bandwidth" : 20, "ip_status" : 0 } ], "instance_id" : "74acXXXX-XXXX-XXXX-XXXX-XXXXd012", "instance_name" : "example 1", "expire_time" : 1675926787000, "service_bandwidth" : 0, "instance_status" : 0, "enterprise_project_id" : "0" }, { "ips" : [ { "ip" : "103.239.246.156", "ip_id" : "d6f9XXXX-XXXX-XXXX-XXXX-XXXXd4b1", "basic_bandwidth" : 20, "elastic_bandwidth" : 30, "ip_status" : 0 } ], "instance_id" : "6a7fXXXX-XXXX-XXXX-XXXX-XXXXd4a6", "instance_name" : "example 2", "expire_time" : 1674909266000, "service_bandwidth" : 0, "instance_status" : 0, "enterprise_project_id" : "0" } ] }
  • 响应参数 状态码: 200 表2 响应Body参数 参数 参数类型 描述 count Integer 实例总数 items Array of InstanceInfo objects 实例 表3 InstanceInfo 参数 参数类型 描述 instance_id String 实例ID instance_name String 实例名 ips Array of InstanceIpInfo objects 实例IP expire_time Long 实例过期时间 service_bandwidth Integer 业务带宽 instance_status Integer 实例状态 enterprise_project_id String 企业项目ID overseas_type Integer 实例类型,0-大陆,1-海外 表4 InstanceIpInfo 参数 参数类型 描述 ip_id String IP ID ip String IP basic_bandwidth Integer 保底带宽 elastic_bandwidth Integer 弹性带宽 ip_status Integer IP状态
  • 响应示例 状态码: 200 请求已成功 { "total" : 1, "ddosStatus" : [ { "floating_ip_id" : "18e6ace5-eb36-4196-a15e-1e000c24e026", "floating_ip_address" : "139.9.116.167", "network_type" : "EIP", "status" : "normal", "blackhole_endtime" : 0, "protect_type" : "default", "traffic_threshold" : 99, "http_threshold" : 0 } ] }
  • URI GET /v1/{project_id}/antiddos 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 项目id 最小长度:32 最大长度:64 表2 Query参数 参数 是否必选 参数类型 描述 status 否 String 可选范围: normal:表示正常 configging:表示设置中 notConfig:表示未设置 packetcleaning:表示清洗 packetdropping:表示黑洞 不带此参数默认所有列表,以neutron查询到的顺序为准。 limit 否 String 返回结果个数限制,取值范围:1~100 最小长度:1 最大长度:3 offset 否 String 偏移量,取值范围:0~2147483647 最小长度:1 最大长度:10 ip 否 String IP地址,支持IPv4格式和IPv6格式输入,支持部分查询。例如“?ip=192.168”,会返回192.168.111.1和10.192.168.8所对应的EIP防护状态。
  • 请求参数 表3 请求Header参数 参数 是否必选 参数类型 描述 X-Auth-Token 是 String 用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 最小长度:32 最大长度:2097152 Content-Type 是 String Content-Type请求头 缺省值:application/json;charset=utf8 最小长度:1 最大长度:255
  • 响应参数 状态码: 200 表4 响应Body参数 参数 参数类型 描述 total Integer 弹性IP总数 最小值:0 最大值:2147483647 ddosStatus Array of DDosStatus objects 防护状态列表 表5 DDosStatus 参数 参数类型 描述 floating_ip_id String EIP的ID floating_ip_address String 浮动IP地址 network_type String EIP所属类型,可选范围: EIP:未绑定到ECS的EIP或绑定到ECS的EIP ELB:绑定到ELB的EIP status String 防护状态,可选范围: normal:表示正常 configging:表示设置中 notConfig:表示未设置 packetcleaning:表示清洗 packetdropping:表示黑洞 blackhole_endtime Long 黑洞结束时间 protect_type String 防护类型 traffic_threshold Long 流量阈值 http_threshold Long http流量阈值
  • 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" antiddos "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/antiddos/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/antiddos/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/antiddos/v1/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 := antiddos.NewAntiDDoSClient( antiddos.AntiDDoSClientBuilder(). WithRegion(region.ValueOf("cn-north-4")). WithCredential(auth). Build()) request := &model.ShowAlertConfigRequest{} response, err := client.ShowAlertConfig(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 huaweicloudsdkantiddos.v1.region.antiddos_region import AntiDDoSRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkantiddos.v1 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 = AntiDDoSClient.new_builder() \ .with_credentials(credentials) \ .with_region(AntiDDoSRegion.value_of("cn-north-4")) \ .build() try: request = ShowAlertConfigRequest() response = client.show_alert_config(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
共100000条