华为云用户手册

  • 响应参数 状态码: 200 表4 响应Body参数 参数 参数类型 描述 result String 响应状态 状态码: 400 表5 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表6 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。 状态码: 403 表7 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表8 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。
  • 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 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.dbss.v1.region.DbssRegion; import com.huaweicloud.sdk.dbss.v1.*; import com.huaweicloud.sdk.dbss.v1.model.*; public class SwitchAgentSolution { 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); DbssClient client = DbssClient.newBuilder() .withCredential(auth) .withRegion(DbssRegion.valueOf("cn-north-4")) .build(); SwitchAgentRequest request = new SwitchAgentRequest(); AgentSwitchRequest body = new AgentSwitchRequest(); body.withStatus(1); body.withAgentId("ASWDSDSDSWEWDSDSD"); request.withBody(body); try { SwitchAgentResponse response = client.switchAgent(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 请求已成功。 { "result" : "SUCCESS" } 状态码: 400 请求参数有误。 { "error" : { "error_code" : "DBSS.XXX", "error_msg" : "XXX" } } 状态码: 403 认证失败。 { "error" : { "error_code" : "DBSS.XXX", "error_msg" : "XXX" } }
  • 响应参数 状态码: 200 表4 响应Body参数 参数 参数类型 描述 scopes Array of RuleScopeInfo objects 审计范围规则列表 total Integer 总数 表5 RuleScopeInfo 参数 参数类型 描述 id String 审计范围规则ID name String 审计范围名称 action String 审计范围动作 status String 审计范围规则状态 exception_ips String 审计范围例外IP source_ips String 审计范围规则源IP source_ports String 审计范围源端口 db_ids String 数据库ID db_names String 数据库名称 db_users String 数据库用户 all_audit Boolean 是否全审计 状态码: 400 表6 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表7 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。 状态码: 403 表8 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表9 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。 状态码: 500 表10 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表11 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。
  • 响应示例 状态码: 200 成功 { "scopes" : [ { "id" : "zX4W2ngBo47GiyUSBuNs", "name" : "全审计规则", "action" : "", "status" : "ON", "exception_ips" : "", "source_ips" : "", "source_ports" : "", "db_ids" : "", "db_names" : "", "db_users" : "", "all_audit" : true } ], "total" : 1 } 状态码: 400 请求参数错误 { "error" : { "error_code" : "DBSS.XXXX", "error_msg" : "XXX" } } 状态码: 500 服务器内部错误 { "error" : { "error_code" : "DBSS.XXXX", "error_msg" : "XXX" } }
  • URI GET /v1/{project_id}/{instance_id}/dbss/audit/rule/scopes 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 项目ID instance_id 是 String 实例ID 表2 Query参数 参数 是否必选 参数类型 描述 offset 否 String 偏移量 limit 否 String 查询记录数
  • 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 54 package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" dbss "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dbss/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dbss/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dbss/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 := dbss.NewDbssClient( dbss.DbssClientBuilder(). WithRegion(region.ValueOf("cn-north-4")). WithCredential(auth). Build()) request := &model.BatchAddResourceTagRequest{} var listSysTagsbody = []model.KeyValueBean{ { Key: "_sys_enterprise_project_id", Value: "5aa119a8-d25b-45a7-8d1b-88e127885635", }, } var listTagsbody = []model.KeyValueBean{ { Key: "key1", }, { Key: "key2", Value: "value3", }, } request.Body = &model.ResourceTagRequest{ SysTags: &listSysTagsbody, Tags: &listTagsbody, } response, err := client.BatchAddResourceTag(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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 # coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkdbss.v1.region.dbss_region import DbssRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkdbss.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 = DbssClient.new_builder() \ .with_credentials(credentials) \ .with_region(DbssRegion.value_of("cn-north-4")) \ .build() try: request = BatchAddResourceTagRequest() listSysTagsbody = [ KeyValueBean( key="_sys_enterprise_project_id", value="5aa119a8-d25b-45a7-8d1b-88e127885635" ) ] listTagsbody = [ KeyValueBean( key="key1" ), KeyValueBean( key="key2", value="value3" ) ] request.body = ResourceTagRequest( sys_tags=listSysTagsbody, tags=listTagsbody ) response = client.batch_add_resource_tag(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-Auth-Token 是 String 用户Token 表3 请求Body参数 参数 是否必选 参数类型 描述 tags 否 Array of KeyValueBean objects 标签列表 租户权限时该字段必选,op_service权限时和sys_tags二选一 sys_tags 否 Array of KeyValueBean objects 系统标签列表 op_service权限可以访问,和tags二选一。 目前TMS调用时只包含一个resource_tag结构体 ,key固定为:_sys_enterprise_project_id value是UUID或0,value为0表示默认企业项目 表4 KeyValueBean 参数 是否必选 参数类型 描述 key 是 String 键 value 是 String 值
  • 响应参数 状态码: 400 表5 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表6 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。 状态码: 403 表7 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表8 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。 状态码: 500 表9 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表10 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。
  • 请求示例 /v1/{project_id}/{resource_type}/{resource_id}/tags/create { "tags" : [ { "key" : "key1" }, { "key" : "key2", "value" : "value3" } ], "sys_tags" : [ { "key" : "_sys_enterprise_project_id", "value" : "5aa119a8-d25b-45a7-8d1b-88e127885635" } ] }
  • 错误码 当您调用API时,如果遇到“APIGW”开头的错误码,请参见API网关错误码进行处理。 状态码 错误码 错误信息 描述 处理措施 400 DBSS.10000001 Enter a valid request message 请求消息格式非法 检查参数 400 DBSS.10020101 Enter a valid request message 获取规格列表失败 检查参数 400 DBSS.10020102 Enter a valid request message 操作数据库失败 检查参数 400 DBSS.10020118 Failed to add database, exceeding the limit 添加数据库失败,超出数量限制 删除不需要的数据库或购买新实例 400 DBSS.10020140 Illegal order ID 订单ID不符合要求 检查订单ID 400 DBSS.100210016 Insufficient quota 配额不足 联系管理员 401 DBSS.10020100 Failed to authenticate the token in the request 请求所带的Token认证失败 检查token 404 DBSS.10021004 ECS can not found the request page ECS服务器无法找到被请求页面 检查ecs路径配置 500 DBSS.11000000 Internal system exception. Contact technical support engineers 系统内部异常,请联系技术支持人员 联系管理员 父主题: 附录
  • 响应消息体(可选) 响应消息体通常以结构化格式返回,与响应消息头中Content-type对应,传递除响应消息头之外的内容。 对于获取用户Token接口,返回如下消息体。为篇幅起见,这里只展示部分内容。 { "token": { "expires_at": "2019-02-13T06:52:13.855000Z", "methods": [ "password" ], "catalog": [ { "endpoints": [ { "region_id": "xxxxxxxx", ...... 当接口调用出错时,会返回错误码及错误信息说明,错误响应的Body体格式如下所示。 { "error": { "message": "The request you have made requires authentication.", "title": "Unauthorized" } } 其中,error_code表示错误码,error_msg表示错误描述信息。
  • 状态码 正常 返回值 说明 200 请求成功。 异常 状态码 编码 说明 400 Bad Request 服务器未能处理请求。 401 Unauthorized 被请求的页面需要用户名和密码。 403 Forbidden 对被请求页面的访问被禁止。 404 Not Found 服务器无法找到被请求的页面。 405 Method Not Allowed 请求中指定的方法不被允许。 406 Not Acceptable 服务器生成的响应无法被客户端所接受。 407 Proxy Authentication Required 用户必须首先使用代理服务器进行验证,这样请求才会被处理。 408 Request Timeout 请求超出了服务器的等待时间。 409 Conflict 由于冲突,请求无法被完成。 500 Internal Server Error 请求未完成,服务异常。 501 Not Implemented 请求未完成,服务器不支持所请求的功能。 502 Bad Gateway 请求未完成,服务器从上游服务器收到一个无效的响应。 503 Service Unavailable 请求未完成,系统暂时异常。 504 Gateway Timeout 网关超时。 父主题: 附录
  • 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" dbss "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dbss/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dbss/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dbss/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 := dbss.NewDbssClient( dbss.DbssClientBuilder(). WithRegion(region.ValueOf("cn-north-4")). WithCredential(auth). Build()) request := &model.ListAvailabilityZoneInfosRequest{} response, err := client.ListAvailabilityZoneInfos(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • 响应示例 状态码: 200 成功 { "azs" : [ { "zone_name" : "cn-north-7b", "zone_number" : 2, "az_type" : "normal", "alias" : "可用区2", "alias_us" : "AZ2" }, { "zone_name" : "cn-north-7a", "zone_number" : 1, "az_type" : "normal", "alias" : "可用区1", "alias_us" : "AZ1" }, { "zone_name" : "cn-north-7c", "zone_number" : 3, "az_type" : "normal", "alias" : "可用区3", "alias_us" : "AZ3" } ] } 状态码: 400 客户端错误 { "error" : { "error_code" : "DBSS.XXXX", "error_msg" : "XXX" } }
  • 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 huaweicloudsdkdbss.v1.region.dbss_region import DbssRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkdbss.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 = DbssClient.new_builder() \ .with_credentials(credentials) \ .with_region(DbssRegion.value_of("cn-north-4")) \ .build() try: request = ListAvailabilityZoneInfosRequest() response = client.list_availability_zone_infos(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.dbss.v1.region.DbssRegion; import com.huaweicloud.sdk.dbss.v1.*; import com.huaweicloud.sdk.dbss.v1.model.*; public class ListAvailabilityZoneInfosSolution { 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); DbssClient client = DbssClient.newBuilder() .withCredential(auth) .withRegion(DbssRegion.valueOf("cn-north-4")) .build(); ListAvailabilityZoneInfosRequest request = new ListAvailabilityZoneInfosRequest(); try { ListAvailabilityZoneInfosResponse response = client.listAvailabilityZoneInfos(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参数 参数 参数类型 描述 azs Array of AzInfo objects az列表 表4 AzInfo 参数 参数类型 描述 zone_name String 可用区名称 zone_number Integer 可用区编号 az_type String 可用区类型 alias String 可用区别名 alias_us String 可用区别名英文 状态码: 400 表5 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表6 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。 状态码: 403 表7 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表8 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。 状态码: 500 表9 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表10 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。
  • 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 # coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkdbss.v1.region.dbss_region import DbssRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkdbss.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 = DbssClient.new_builder() \ .with_credentials(credentials) \ .with_region(DbssRegion.value_of("cn-north-4")) \ .build() try: request = ListSqlInjectionRulesRequest() request.body = SqlRuleRequest( risk_levels="HIGH" ) response = client.list_sql_injection_rules(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 package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" dbss "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dbss/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dbss/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dbss/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 := dbss.NewDbssClient( dbss.DbssClientBuilder(). WithRegion(region.ValueOf("cn-north-4")). WithCredential(auth). Build()) request := &model.ListSqlInjectionRulesRequest{} riskLevelsSqlRuleRequest:= "HIGH" request.Body = &model.SqlRuleRequest{ RiskLevels: &riskLevelsSqlRuleRequest, } response, err := client.ListSqlInjectionRules(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • 响应示例 状态码: 200 成功 { "rules" : [ { "id" : "zX4W2ngBo47GiyUSBuNs", "name" : "MYSQL报错型SQL注入", "status" : "ON", "type" : "SYSTEM", "risk_level" : "HIGH", "rank" : 1, "feature" : "正则表达式", "regex" : "((.*)?(select)\\s+[0-9]+\\s+from\\s+\\(\\s*select\\s+count(.*)?(concat)\\s*(.*)?(from)\\s*(information_schema.tables)(.*)?(group)\\s+(by)(.*)?)" } ], "total" : 1 } 状态码: 400 请求参数错误 { "error" : { "error_code" : "DBSS.XXXX", "error_msg" : "XXX" } } 状态码: 500 服务器内部错误 { "error" : { "error_code" : "DBSS.XXXX", "error_msg" : "XXX" } }
  • 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.dbss.v1.region.DbssRegion; import com.huaweicloud.sdk.dbss.v1.*; import com.huaweicloud.sdk.dbss.v1.model.*; public class ListSqlInjectionRulesSolution { 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); DbssClient client = DbssClient.newBuilder() .withCredential(auth) .withRegion(DbssRegion.valueOf("cn-north-4")) .build(); ListSqlInjectionRulesRequest request = new ListSqlInjectionRulesRequest(); SqlRuleRequest body = new SqlRuleRequest(); body.withRiskLevels("HIGH"); request.withBody(body); try { ListSqlInjectionRulesResponse response = client.listSqlInjectionRules(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参数 参数 参数类型 描述 rules Array of rules objects SQL规则列表 total Integer 当前范围总数 表5 rules 参数 参数类型 描述 id String SQL规则ID name String SQL规则名称 status String 规则的状态:  ON  OFF risk_level String 风险级别  HIGH  MEDIUM  LOW type String 类型 rank Integer 等级 feature String SQL命令特征 regex String 正则表达式 状态码: 400 表6 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表7 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。 状态码: 403 表8 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表9 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。 状态码: 500 表10 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表11 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。
  • 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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" dbss "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dbss/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dbss/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dbss/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 := dbss.NewDbssClient( dbss.DbssClientBuilder(). WithRegion(region.ValueOf("cn-north-4")). WithCredential(auth). Build()) request := &model.CountResourceInstanceByTagRequest{} var listValuesNotTagsAny = []string{ "value1", "value2", } var listNotTagsAnybody = []model.TagKeyValuesBean{ { Key: "key1", Values: listValuesNotTagsAny, }, } var listValuesTagsAny = []string{ "value1", "value2", } var listTagsAnybody = []model.TagKeyValuesBean{ { Key: "key1", Values: listValuesTagsAny, }, } var listValuesTags = []string{ "*value1", "value2", } var listTagsbody = []model.TagKeyValuesBean{ { Key: "key1", Values: listValuesTags, }, } var listValuesNotTags = []string{ "*value1", "value2", } var listNotTagsbody = []model.TagKeyValuesBean{ { Key: "key1", Values: listValuesNotTags, }, } keyMatches:= "resource_name" valueMatches:= "resource1" var listMatchesbody = []model.ResourceInstanceTagRequestMatches{ { Key: &keyMatches, Value: &valueMatches, }, } var sysTagsSysTags interface{} = "[{\"values\":[\"5aa119a8-d25b-45a7-8d1b-88e127885635\"],\"key\":\"_sys_enterprise_project_id\"}]" request.Body = &model.ResourceInstanceTagRequest{ SysTags: &sysTagsSysTags, NotTagsAny: &listNotTagsAnybody, TagsAny: &listTagsAnybody, Tags: &listTagsbody, NotTags: &listNotTagsbody, Matches: &listMatchesbody, } response, err := client.CountResourceInstanceByTag(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 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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 # coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkdbss.v1.region.dbss_region import DbssRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkdbss.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 = DbssClient.new_builder() \ .with_credentials(credentials) \ .with_region(DbssRegion.value_of("cn-north-4")) \ .build() try: request = CountResourceInstanceByTagRequest() listValuesNotTagsAny = [ "value1", "value2" ] listNotTagsAnybody = [ TagKeyValuesBean( key="key1", values=listValuesNotTagsAny ) ] listValuesTagsAny = [ "value1", "value2" ] listTagsAnybody = [ TagKeyValuesBean( key="key1", values=listValuesTagsAny ) ] listValuesTags = [ "*value1", "value2" ] listTagsbody = [ TagKeyValuesBean( key="key1", values=listValuesTags ) ] listValuesNotTags = [ "*value1", "value2" ] listNotTagsbody = [ TagKeyValuesBean( key="key1", values=listValuesNotTags ) ] listMatchesbody = [ ResourceInstanceTagRequestMatches( key="resource_name", value="resource1" ) ] request.body = ResourceInstanceTagRequest( sys_tags="[{\"values\":[\"5aa119a8-d25b-45a7-8d1b-88e127885635\"],\"key\":\"_sys_enterprise_project_id\"}]", not_tags_any=listNotTagsAnybody, tags_any=listTagsAnybody, tags=listTagsbody, not_tags=listNotTagsbody, matches=listMatchesbody ) response = client.count_resource_instance_by_tag(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 表6 响应Body参数 参数 参数类型 描述 resources Array of resources objects 资源实例列表 total_count Integer 总记录数 表7 resources 参数 参数类型 描述 resource_detail Object 资源详情。 资源对象,用于扩展。默认为空 resource_id String 资源ID resource_name String 资源名称,资源没有名称时默认为空字符串,eip返回ip地址 tags Array of tags objects 标签列表,没有标签默认为空数组 sys_tags Array of sys_tags objects 仅op_service权限才可以可以获取此字段: 目前只包含一个resource_tag 结构体 key:_sys_enterprise_project_id value:企业项目id,0表示默认企业项目 非op_service场景不能返回此字段 表8 tags 参数 参数类型 描述 key String 键 value String 值 表9 sys_tags 参数 参数类型 描述 key String 键 value String 值 状态码: 400 表10 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表11 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。 状态码: 403 表12 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表13 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。 状态码: 500 表14 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表15 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。
  • 请求示例 /v1/{project_id}/{resource_type}/resource-instances/count { "matches" : [ { "key" : "resource_name", "value" : "resource1" } ], "not_tags" : [ { "key" : "key1", "values" : [ "*value1", "value2" ] } ], "tags" : [ { "key" : "key1", "values" : [ "*value1", "value2" ] } ], "tags_any" : [ { "key" : "key1", "values" : [ "value1", "value2" ] } ], "not_tags_any" : [ { "key" : "key1", "values" : [ "value1", "value2" ] } ], "sys_tags" : [ { "key" : "_sys_enterprise_project_id", "values" : [ "5aa119a8-d25b-45a7-8d1b-88e127885635" ] } ] }
  • 请求参数 表2 请求Header参数 参数 是否必选 参数类型 描述 X-Auth-Token 是 String 用户Token 表3 请求Body参数 参数 是否必选 参数类型 描述 matches 否 Array of matches objects 搜索字段,key为要匹配的字段,如resource_name等。value为匹配的值。key为固定字典值,不能包含重复的key或不支持的key。 根据key的值确认是否需要模糊匹配,如resource_name默认为模糊搜索(不区分大小写),如果value为空字符串精确匹配(多数服务不存在资源名称为空的情况,因此此类情况返回空列表)。resource_id为精确匹配。第一期只做resource_name,后续再扩展。 not_tags 否 Array of TagKeyValuesBean objects 不包含标签,最多包含50个key,每个key下面的value最多10个, 每个key对应的value可以为空数组但结构体不能缺失。Key不能重复,同一个key中values不能重复。结果返回不包含标签的资源列表,key之间是与的关系,key-value结构中value是或的关系。无过滤条件时返回全量数据 tags 否 Array of TagKeyValuesBean objects 包含标签,最多包含50个key,每个key下面的value最多10个,每个key对应的value可以为空数组但结构体不能缺失。Key不能重复,同一个key中values不能重复。结果返回包含所有标签的资源列表,key之间是与的关系,key-value结构中value是或的关系。无tag过滤条件时返回全量数据 tags_any 否 Array of TagKeyValuesBean objects 包含任意标签,最多包含50个key,每个key下面的value最多10个, 每个key对应的value可以为空数组但结构体不能缺失。Key不能重复,同一个key中values不能重复。结果返回包含标签的资源列表,key之间是或的关系,key-value结构中value是或的关系。无过滤条件时返回全量数据 not_tags_any 否 Array of TagKeyValuesBean objects 不包含任意标签,最多包含50个key,每个key下面的value最多10个, 每个key对应的value可以为空数组但结构体不能缺失。Key不能重复,同一个key中values不能重复。结果返回不包含标签的资源列表,key之间是或的关系,key-value结构中value是或的关系。无过滤条件时返回全量数据 sys_tags 否 TagKeyValuesBean object 仅op_service权限可以使用此字段做资源实例过滤条件。目前TMS调用时只包含一个tag结构体。key:_sys_enterprise_project_idvalue:企业项目id列表目前TMS调用时,key下面只包含一个value。0表示默认企业项目sys_tags和租户标签过滤条件(without_any_tag 、tags、tags_any、not_tags、not_tags_any)不能同时使用无sys_tags时按照tag接口处理,无tag过滤条件时返回全量数据 without_any_tag 否 Boolean 不包含任意一个标签,该字段为true时查询所有不带标签的资源,此时忽略 “tags”、“tags_any”、“not_tags”、“not_tags_any”字段 表4 matches 参数 是否必选 参数类型 描述 key 否 String 键 value 否 String 值 表5 TagKeyValuesBean 参数 是否必选 参数类型 描述 key 是 String 键。最大长度128个unicode字符。 key不能为空。(搜索时不对此参数做字符集校验),key不能为空或者空字符串,不能为空格,校验和使用之前先trim 前后半角空格 values 是 Array of strings 值列表。每个值最大长度255个unicode字符,校验和使用之前先trim 前后半角空格。 value可为空数组但不可缺省。 如果values为空列表,则表示any_value(查询任意value)。value之间为或的关系
  • 响应参数 状态码: 200 表4 响应Body参数 参数 参数类型 描述 rules Array of rules objects 规则列表 total Integer 总数 表5 rules 参数 参数类型 描述 id String 规则ID name String 规则名称 type String 规则类型 regex String 规则正则表达式 mask_value String 替换值 status String 规则状态 operate_time String 操作时间 状态码: 400 表6 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表7 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。 状态码: 403 表8 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表9 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。 状态码: 500 表10 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表11 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。
共100000条