华为云用户手册

  • 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) } }
  • 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)
  • 响应示例 状态码: 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" } }
  • 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) } }
  • 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 成功 { "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" } }
  • 响应参数 状态码: 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)
  • 请求示例 /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" ] } ] }
  • 响应参数 状态码: 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 错误请求返回的错误信息。
  • 请求参数 表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 成功 { "rules" : [ { "id" : "n34W2ngBo47GiyUSKOVl", "name" : "Passport NO.", "type" : "BUILD_IN", "regex" : "-", "mask_value" : "###", "status" : "ON", "operate_time" : "2030-01-01 00:00:06" }, { "id" : "nn4W2ngBo47GiyUSKOVP", "name" : "Military officer card NO.", "type" : "BUILD_IN", "regex" : "-", "mask_value" : "###", "status" : "ON", "operate_time" : "2030-01-01 00:00:05" }, { "id" : "nX4W2ngBo47GiyUSKOU9", "name" : "Ethnicity", "type" : "BUILD_IN", "regex" : "-", "mask_value" : "###", "status" : "ON", "operate_time" : "2030-01-01 00:00:04" }, { "id" : "mn4W2ngBo47GiyUSKOUO", "name" : "GPS Information", "type" : "BUILD_IN", "regex" : "-", "mask_value" : "###", "status" : "ON", "operate_time" : "2030-01-01 00:00:01" } ], "total" : 6 } 状态码: 400 请求参数错误 { "error" : { "error_code" : "DBSS.XXXX", "error_msg" : "XXX" } } 状态码: 500 服务器内部错误 { "error" : { "error_code" : "DBSS.XXXX", "error_msg" : "XXX" } }
  • 响应参数 状态码: 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 错误请求返回的错误信息。
  • URI GET /v1/{project_id}/{instance_id}/dbss/audit/sensitive/masks 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 项目ID instance_id 是 String 实例ID 表2 Query参数 参数 是否必选 参数类型 描述 offset 否 String 偏移量 limit 否 String 查询记录数
  • 概述 欢迎使用数据库安全服务(Database Security Service,DBSS)。数据库安全服务是一个智能的数据库安全服务,基于大数据分析技术,提供数据库审计,SQL注入攻击检测,风险操作识别等功能,保障云上数据库的安全。 您可以使用本文档提供的API对实例、规则进行相关操作,如创建、查询、删除等。支持的全部操作请参见API。 在调用数据库安全服务API之前,请确保已经充分了解数据库安全服务相关概念,详细信息请参见产品介绍。 父主题: 使用前必读
  • 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.ListAuditInstanceJobsRequest{} response, err := client.ListAuditInstanceJobs(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 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 = ListAuditInstanceJobsRequest() response = client.list_audit_instance_jobs(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 成功 { "jobs" : [ { "ha_id" : "2c154fdd-0d43-47b7-9cf1-5236bf6a2ca7", "ha_name" : null, "status" : "SUCCESS", "job_type" : null, "job_id" : "8abf9647852a1daa01852e517e1a1a0b", "begin_time" : 1671519371000, "end_time" : 1671519417000, "error_code" : null, "fail_reason" : null, "charge_mode" : "Demand", "server_name" : "DBSS-qct-1220", "server_id" : "0aa8f621-bc19-4822-b66d-7ab9ae3c8693" } ] } 状态码: 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 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 ListAuditInstanceJobsSolution { 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(); ListAuditInstanceJobsRequest request = new ListAuditInstanceJobsRequest(); try { ListAuditInstanceJobsResponse response = client.listAuditInstanceJobs(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参数 参数 参数类型 描述 jobs Array of JobBean objects 实例创建任务列表 表4 JobBean 参数 参数类型 描述 job_id String 任务ID,异步查询标识 status String 状态 job_type String 类型 server_id String 虚拟机ID server_name String 虚拟机名称 begin_time Long 开始时间 end_time Long 结束时间 charge_mode String 计费模式 error_code String 错误码 fail_reason String 失败原因 ha_id String 双机实例HA共用的id ha_name String HA别名 状态码: 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 错误请求返回的错误信息。
  • 请求消息体 请求消息体通常以结构化格式发出,与请求消息头中Content-type对应,传递除请求消息头之外的内容。若请求消息体中参数支持中文,则中文字符必须为UTF-8编码。 每个接口的请求消息体内容不同,也并不是每个接口都需要有请求消息体(或者说消息体为空),GET、DELETE操作类型的接口就不需要消息体,消息体具体内容需要根据具体接口而定。 对于获取用户Token接口,您可以从接口的请求部分看到所需的请求参数及参数说明。将消息体加入后的请求如下所示,加粗的斜体字段需要根据实际值填写,其中username为用户名,domainname为用户所属的账号名称,********为用户登录密码,xxxxxxxxxxxxxxxxxx为project的名称,如“cn-north-4”,您可以从地区和终端节点获取,对应地区和终端节点页面的“区域”字段的值。 scope参数定义了Token的作用域,下面示例中获取的Token仅能访问project下的资源。您还可以设置Token作用域为某个账号下所有资源或账号的某个project下的资源,详细定义请参见获取用户Token。 POST https://iam.cn-north-4.myhuaweicloud.com/v3/auth/tokens Content-Type: application/json { "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "name": "username", "password": "********", "domain": { "name": "domainname" } } } }, "scope": { "project": { "name": "xxxxxxxxxxxxxxxxxx" } } } } 到这里为止这个请求需要的内容就具备齐全了,您可以使用curl、Postman或直接编写代码等方式发送请求调用API。对于获取用户Token接口,返回的响应消息头中“x-subject-token”就是需要获取的用户Token。有了Token之后,您就可以使用Token认证调用其他API。
  • 请求消息头 附加请求头字段,如指定的URI和HTTP方法所要求的字段。例如定义消息体类型的请求头“Content-Type”,请求鉴权信息等。 如下公共消息头需要添加到请求中。 Content-Type:消息体的类型(格式),必选,默认取值为“application/json”,有其他取值时会在具体接口中专门说明。 X-Auth-Token:用户Token,可选,当使用Token方式认证时,必须填充该字段。用户Token也就是调用获取用户Token接口的响应值,该接口是唯一不需要认证的接口。 API同时支持使用AK/SK认证,AK/SK认证是使用SDK对请求进行签名,签名过程会自动往请求中添加Authorization(签名认证信息)和X-Sdk-Date(请求发送的时间)请求头。 AK/SK认证的详细说明请参见AK/SK认证。 对于获取用户Token接口,由于不需要认证,所以只添加“Content-Type”即可,添加消息头后的请求如下所示。 POST https://iam.cn-north-4.myhuaweicloud.com/v3/auth/tokens Content-Type: application/json
  • 请求URI 请求URI由如下部分组成。 {URI-scheme} :// {Endpoint} / {resource-path} ? {query-string} 尽管请求URI包含在请求消息头中,但大多数语言或框架都要求您从请求消息中单独传递它,所以在此单独强调。 URI-scheme: 表示用于传输请求的协议,当前所有API均采用HTTPS协议。 Endpoint: 指定承载REST服务端点的服务器域名或IP,不同服务不同区域的Endpoint不同,您可以从地区和终端节点获取。 例如IAM服务在“华北-北京四”区域的Endpoint为“iam.cn-north-4.myhuaweicloud.com”。 resource-path: 资源路径,也即API访问路径。从具体API的URI模块获取,例如“获取用户Token”API的resource-path为“/v3/auth/tokens”。 query-string: 查询参数,是可选部分,并不是每个API都有查询参数。查询参数前面需要带一个“?”,形式为“参数名=参数取值”,例如“limit=10”,表示查询不超过10条数据。 例如您需要获取IAM在“华北-北京四”区域的Token,则需使用“华北-北京四”区域的Endpoint(iam.cn-north-4.myhuaweicloud.com),并在获取用户Token的URI部分找到resource-path(/v3/auth/tokens),拼接起来如下所示。 https://iam.cn-north-4.myhuaweicloud.com/v3/auth/tokens 图1 URI示意图 为查看方便,在每个具体API的URI部分,只给出resource-path部分,并将请求方法写在一起。这是因为URI-scheme都是HTTPS,同一个服务的Endpoint在同一个区域也相同,所以简洁起见将这两部分省略。
  • 请求方法 HTTP请求方法(也称为操作或动词),它告诉服务你正在请求什么类型的操作。 GET:请求服务器返回指定资源。 PUT:请求服务器更新指定资源。 POST:请求服务器新增资源或执行特殊操作。 DELETE:请求服务器删除指定资源,如删除对象等。 HEAD:请求服务器资源头部。 PATCH:请求服务器更新资源的部分内容。当资源不存在的时候,PATCH可能会去创建一个新的资源。 在获取用户Token的URI部分,您可以看到其请求方法为“POST”,则其请求为: POST https://iam.cn-north-4.myhuaweicloud.com/v3/auth/tokens
  • 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 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.BatchDeleteResourceTagRequest{} var listTagsbody = []model.KeyValueBean{ { Key: "key1", }, { Key: "key2", Value: "value3", }, } request.Body = &model.ResourceTagRequest{ Tags: &listTagsbody, } response, err := client.BatchDeleteResourceTag(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • 响应参数 状态码: 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 错误请求返回的错误信息。
共100000条