华为云用户手册

  • 响应参数 状态码: 200 表4 响应Body参数 参数 参数类型 描述 rules Array of rules objects 风险规则列表 total Integer 总数 表5 rules 参数 参数类型 描述 id String 风险规则ID name String 风险规则名称 type String 风险类型 feature String 风险特征 status String 风险规则状态 rank Integer 风险规则优先级 risk_level 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 错误请求返回的错误信息。
  • 响应示例 状态码: 200 成功 { "rules" : [ { "id" : "xX4W2ngBo47GiyUSBeOy", "name" : "Database_drag_detection", "type" : "OPERATE", "feature" : "CLIENT[Any]OPERATE[[SELECT]OBJECT[Any]", "status" : "ON", "rank" : -1, "risk_level" : "HIGH" }, { "id" : "xn4W2ngBo47GiyUSBeP4", "name" : "Database_Slow_SQL_Detection", "type" : "OPERATE", "feature" : "CLIENT[Any]OPERATE[[SELECT]OBJECT[Any]", "status" : "ON", "rank" : -2, "risk_level" : "LOW" } ], "total" : 2 } 状态码: 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/risk 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 项目ID instance_id 是 String 实例ID 表2 Query参数 参数 是否必选 参数类型 描述 name 否 String 风险名称 risk_levels 否 String 风险级别[LOW,MEDIUM,HIGH,NO_RISK]
  • 响应示例 状态码: 200 成功 { "resources" : [ { "resource_detail" : null, "resource_id" : "cdfs_cefs_wesas_12_dsad", "resource_name" : "resouece1", "tags" : [ { "key" : "key1", "value" : "value1" }, { "key" : "key2", "value" : "value1" } ], "sys_tags" : [ { "key" : "_sys_enterprise_project_id", "value" : "5aa119a8-d25b-45a7-8d1b-88e127885635" } ] } ], "total_count" : 1000 } 状态码: 400 失败 { "error" : { "error_code" : "DBSS.XXXX", "error_msg" : "XXX" } }
  • 请求示例 /v1/{project_id}/{resource_type}/resource-instances/filter { "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 表7 响应Body参数 参数 参数类型 描述 resources Array of resources objects 资源实例列表 total_count Integer 总记录数 表8 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场景不能返回此字段 表9 tags 参数 参数类型 描述 key String 键 value String 值 表10 sys_tags 参数 参数类型 描述 key String 键 value String 值 状态码: 400 表11 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表12 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。 状态码: 403 表13 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表14 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。 状态码: 500 表15 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表16 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。
  • URI POST /v1/{project_id}/{resource_type}/resource-instances/filter 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 项目ID resource_type 是 String 资源类型。审计:auditInstance 表2 Query参数 参数 是否必选 参数类型 描述 limit 否 String 查询记录数(action为count时无此参数)如果action为filter默认为1000,limit最多为1000,不能为负数,最小值为1 offset 否 String 索引位置,偏移量(action为count时无此参数)从第一条数据偏移offset条数据后开始查询,如果action为filter默认为0(偏移0条数据,表示从第一条数据开始查询),必须为数字,不能为负数
  • 请求参数 表3 请求Header参数 参数 是否必选 参数类型 描述 X-Auth-Token 是 String 用户Token 表4 请求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”字段 表5 matches 参数 是否必选 参数类型 描述 key 否 String 键 value 否 String 值 表6 TagKeyValuesBean 参数 是否必选 参数类型 描述 key 是 String 键。最大长度128个unicode字符。 key不能为空。(搜索时不对此参数做字符集校验),key不能为空或者空字符串,不能为空格,校验和使用之前先trim 前后半角空格 values 是 Array of strings 值列表。每个值最大长度255个unicode字符,校验和使用之前先trim 前后半角空格。 value可为空数组但不可缺省。 如果values为空列表,则表示any_value(查询任意value)。value之间为或的关系
  • 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.ListProjectResourceTagsRequest{} response, err := client.ListProjectResourceTags(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 = ListProjectResourceTagsRequest() response = client.list_project_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)
  • 响应示例 状态码: 200 成功 { "tags" : [ { "key" : "key1", "values" : [ "value1", "value2" ] }, { "key" : "key2", "values" : [ "value1", "value2" ] } ] } 状态码: 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 ListProjectResourceTagsSolution { 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(); ListProjectResourceTagsRequest request = new ListProjectResourceTagsRequest(); try { ListProjectResourceTagsResponse response = client.listProjectResourceTags(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参数 参数 参数类型 描述 tags Array of tags objects 标签列表 表4 tags 参数 参数类型 描述 key String 键。最大长度128个字符。 key满足3.1 KEY字符集规范。 values Array of strings 值列表。每个值最大长度255个字符。 value满足3.2 VALUE字符集规范。 状态码: 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 33 # 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 = SwitchAgentRequest() request.body = AgentSwitchRequest( status=1, agent_id="ASWDSDSDSWEWDSDSD" ) response = client.switch_agent(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.SwitchAgentRequest{} request.Body = &model.AgentSwitchRequest{ Status: int32(1), AgentId: "ASWDSDSDSWEWDSDSD", } response, err := client.SwitchAgent(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • Java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 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()); } } }
  • 请求参数 表2 请求Header参数 参数 是否必选 参数类型 描述 X-Auth-Token 是 String 用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 表3 请求Body参数 参数 是否必选 参数类型 描述 agent_id 是 String 审计agent的ID status 是 Integer Agent开关状态 1:开启 0:关闭
  • 响应参数 状态码: 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 错误请求返回的错误信息。
  • 响应示例 状态码: 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 值
  • 请求示例 /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" } ] }
  • 响应参数 状态码: 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 错误请求返回的错误信息。
  • 错误码 当您调用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 网关超时。 父主题: 附录
共100000条