华为云用户手册

  • Python 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 # coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from 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 = BatchDeleteResourceTagRequest() listTagsbody = [ KeyValueBean( key="key1" ), KeyValueBean( key="key2", value="value3" ) ] request.body = ResourceTagRequest( tags=listTagsbody ) response = client.batch_delete_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 值
  • 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 # 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 = ListAuditOperateLogsRequest() timebody = TimeRangeBean( time_range="HOUR" ) request.body = OperateLogGetRequest( size="10", page="1", time=timebody ) response = client.list_audit_operate_logs(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
  • Go 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 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.ListAuditOperateLogsRequest{} timeRangeTime:= "HOUR" timebody := &model.TimeRangeBean{ TimeRange: &timeRangeTime, } sizeOperateLogGetRequest:= "10" pageOperateLogGetRequest:= "1" request.Body = &model.OperateLogGetRequest{ Size: &sizeOperateLogGetRequest, Page: &pageOperateLogGetRequest, Time: timebody, } response, err := client.ListAuditOperateLogs(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • 响应示例 状态码: 200 成功 { "total_num" : 3, "operate_log" : [ { "id" : "1LJP-HgBCwCqSg3BVuAp", "user" : "hby-test", "time" : "2021-04-22 06:40:52", "function" : "数据库列表", "action" : "删除", "name" : "db01 ", "description" : "删除审计的数据库", "result" : "success" }, { "id" : "07JO-HgBCwCqSg3ByOAD", "user" : "hby-test", "time" : "2021-04-22 06:40:15", "function" : "数据库列表", "action" : "更新", "name" : "db01 ", "description" : "关闭审计客户端", "result" : "success" }, { "id" : "ULKM93gBCwCqSg3BZeD1", "user" : "hby-test", "time" : "2021-04-22 03:07:56", "function" : "数据库列表", "action" : "创建", "name" : "db01", "description" : "创建新的数据库", "result" : "success" } ] } 状态码: 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 49 50 51 52 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 ListAuditOperateLogsSolution { 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(); ListAuditOperateLogsRequest request = new ListAuditOperateLogsRequest(); OperateLogGetRequest body = new OperateLogGetRequest(); TimeRangeBean timebody = new TimeRangeBean(); timebody.withTimeRange("HOUR"); body.withSize("10"); body.withPage("1"); body.withTime(timebody); request.withBody(body); try { ListAuditOperateLogsResponse response = client.listAuditOperateLogs(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 表5 响应Body参数 参数 参数类型 描述 total_num Integer 总数 operate_log Array of OperateLogInfo objects 操作日志列表 表6 OperateLogInfo 参数 参数类型 描述 id String 操作日志ID user String 操作日志用户 time String 该条记录发生的时间,格式为时间戳 function String 该条记录的功能类型 action String 该条记录的操作类型  create:创建  update:更新  operate:操作(开关)  delete:删除 name String 该条记录对应的用户操作对象 description String 该条记录具体的描述 result String 该条记录对应用户执行的结果  success表示成功  fail表示失败 状态码: 400 表7 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表8 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。 状态码: 403 表9 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表10 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。 状态码: 500 表11 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表12 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。
  • 请求参数 表2 请求Header参数 参数 是否必选 参数类型 描述 X-Auth-Token 是 String 用户Token 表3 请求Body参数 参数 是否必选 参数类型 描述 time 否 TimeRangeBean object 时间区间 user_name 否 String 筛选角色用户获取操作日志 operate_name 否 String 筛选操作对象名称获取操作日志 result 否 String 根据执行结果获取操作日志 [success, fail] page 否 String 页数 size 否 String 每页条数 表4 TimeRangeBean 参数 是否必选 参数类型 描述 end_time 否 String 开始时间,必须和end_time成对出现。格式必须为yyyy-MM-dd HH:mm:ss。UTC时间 start_time 否 String 结束时间,必须和start_time成对出现。格式必须为yyyy-MM-dd HH:mm:ss。UTC时间 time_range 否 String 请求查询的时间段,值为: HALF_HOUR HOUR THREE_HOUR TWELVE_HOUR DAY(24小时) WEEK(7天) MONTH(30天) 枚举值:  HALF_HOUR  HOUR  THREE_HOUR  TWELVE_HOUR  DAY  WEEK  MONTH
  • 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 ShowAuditRuleRiskSolution { 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(); ShowAuditRuleRiskRequest request = new ShowAuditRuleRiskRequest(); try { ShowAuditRuleRiskResponse response = client.showAuditRuleRisk(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } }
  • Go 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 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.ShowAuditRuleRiskRequest{} response, err := client.ShowAuditRuleRisk(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • 响应示例 状态码: 200 成功 { "status" : "OFF", "action" : "LOGIN,SELECT,INSERT", "schemas" : [ { "schema" : "dbss_audit", "table" : null, "column" : null } ], "rank" : 6, "ignore_case" : false, "rule_id" : "AWT0HznX7At9UslqwTfm", "rule_name" : "risk_rule_name_00", "risk_level" : "MEDIUM", "db_ids" : "11111,22222", "execution_symbol" : "GREATER", "execution_time" : 10000, "affect_symbol" : "GREATER", "affect_rows" : 30, "client_ips" : "192.168.0.1" } 状态码: 400 请求参数错误 { "error" : { "error_code" : "DBSS.XXXX", "error_msg" : "XXX" } } 状态码: 500 服务器内部错误 { "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 = ShowAuditRuleRiskRequest() response = client.show_audit_rule_risk(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 表3 响应Body参数 参数 参数类型 描述 rule_id String 风险规则ID rule_name String 风险名称 status String 风险规则状态 枚举值:  OFF  ON action String 操作集合, 中间逗号分隔 LOGIN CREATE_TABLE CREATE_TABLESPACE DROP_TABLE DROP_TABLESPACE DELETE INSERT INSERT_SELECT SELECT SELECT_FOR_UPDATE UPDATE CREATE_USER DROP_USER GRANT OPERATE ALL schemas Array of schemas objects Schema列表 rank Integer 风险规则优先级 ignore_case Boolean 是否忽略大小写 risk_level String 风险级别 枚举值:  LOW  MEDIUM  HIGH  NO_RISK db_ids String 数据库id,中间逗号分隔(单个id 小于256位) execution_symbol String 执行时长对执行时长阈值的关系 枚举值:  GREATER  EQUAL  LESS  GREATER_EQUAL  LESS_EQUAL  NO_MATCH execution_time Integer 设定的执行时长阈值 affect_symbol String 影响行数对行数阈值的关系: 枚举值:  GREATER  EQUAL  LESS  GREATER_EQUAL  LESS_EQUAL  NO_MATCH affect_rows Integer 设定的影响行数阈值 client_ips String 客户端IP段: IP-IP格式,或IP/XX 格式。 各个IP段使用逗号连接 表4 schemas 参数 参数类型 描述 schema String schema名称 table String 表名 column 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 错误请求返回的错误信息。
  • 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.ShowAuditQuotaRequest{} response, err := client.ShowAuditQuota(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 = ShowAuditQuotaRequest() response = client.show_audit_quota(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 成功 { "project_id" : "0250cb8a80c24c0b9f20f557cb159aad", "cpu" : 796, "ram" : 1622016, "audit_quota" : 1 } 状态码: 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 ShowAuditQuotaSolution { 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(); ShowAuditQuotaRequest request = new ShowAuditQuotaRequest(); try { ShowAuditQuotaResponse response = client.showAuditQuota(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参数 参数 参数类型 描述 audit_quota Long 实例当前剩余配额。 cpu Long Cpu当前剩余配额。 project_id String 项目Id。 quota Long 配额。 ram Long 内存当前剩余配额 状态码: 400 表4 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表5 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。 状态码: 403 表6 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表7 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。 状态码: 500 表8 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表9 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。
  • 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不同,使用时请注意。
  • 基本概念 账号 用户注册时的账号,账号对其所拥有的资源及云服务具有完全的访问权限,可以重置用户密码、分配用户权限等。由于账号是付费主体,为了确保账号安全,建议您不要直接使用账号进行日常管理工作,而是创建用户并使用创建的用户进行日常管理工作。 用户 由账号在IAM中创建的用户,是云服务的使用人员,具有身份凭证(密码和访问密钥)。 通常在调用API的鉴权过程中,您需要用到账号、用户和密码等信息。 区域(Region) 从地理位置和网络时延维度划分,同一个Region内共享弹性计算、块存储、对象存储、VPC网络、弹性公网IP、镜像等公共服务。Region分为通用Region和专属Region,通用Region指面向公共租户提供通用云服务的Region;专属Region指只承载同一类业务或只面向特定租户提供业务服务的专用Region。 详情请参见区域和可用区。 可用区(AZ,Availability Zone) 一个AZ是一个或多个物理数据中心的集合,有独立的风火水电,AZ内逻辑上再将计算、网络、存储等资源划分成多个集群。一个Region中的多个AZ间通过高速光纤相连,以满足用户跨AZ构建高可用性系统的需求。 项目 区域默认对应一个项目,这个项目由系统预置,用来隔离物理区域间的资源(计算资源、存储资源和网络资源),以默认项目为单位进行授权,用户可以访问您账号中该区域的所有资源。如果您希望进行更加精细的权限控制,可以在区域默认的项目中创建子项目,并在子项目中创建资源,然后以子项目为单位进行授权,使得用户仅能访问特定子项目中资源,使得资源的权限控制更加精确。 图1 项目隔离模型 父主题: 使用前必读
  • 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 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.CreateInstancesPeriodOrderRequest{} var listTagsbody = []model.KeyValueBean{ { Key: "key_test", Value: "1", }, } var listProductInfosbody = []model.CreateInstancePeriodRequestProductInfos{ { ProductId: "00301-225396-0--0", CloudServiceType: "hws.service.type.dbss", ResourceType: "hws.resource.type.dbss", ResourceSpecCode: "dbss.bypassaudit.low", ProductSpecDesc: "test", }, } var listSecurityGroupsbody = []model.CreateInstancePeriodRequestSecurityGroups{ { Id: "04088976-9c63-4e6b-9070-84e6a30c782b", }, } var listNicsbody = []model.CreateInstancePeriodRequestNics{ { SubnetId: "6201dcf2-1374-43ec-ae8b-78b4081572d3", }, } isAutoRenewCreateInstancePeriodRequest:= int32(0) promotionInfoCreateInstancePeriodRequest:= "" commentCreateInstancePeriodRequest:= "" request.Body = &model.CreateInstancePeriodRequest{ IsAutoRenew: &isAutoRenewCreateInstancePeriodRequest, PromotionInfo: &promotionInfoCreateInstancePeriodRequest, Tags: &listTagsbody, ProductInfos: listProductInfosbody, SubscriptionNum: int32(1), PeriodNum: int32(1), PeriodType: int32(2), ChargingMode: int32(0), CloudServiceType: "hws.service.type.dbss", Region: "cn-north-7", Comment: &commentCreateInstancePeriodRequest, SecurityGroups: listSecurityGroupsbody, Nics: listNicsbody, EnterpriseProjectId: "0", AvailabilityZone: "cn-north-7c", VpcId: "4c035747-f77b-4c6d-b23b-cb3a2b96c7e6", Name: "DBSS-acc3", FlavorRef: "st6.xlarge.4", } response, err := client.CreateInstancesPeriodOrder(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • 请求示例 创建一个包周期计费"chargin_mode : 0"的实例,版本为基础版:"resource_spec_code" : "dbss.bypassaudit.low"。 /v2/{project_id}/dbss/audit/charge/period/order { "flavor_ref" : "st6.xlarge.4", "name" : "DBSS-acc3", "vpc_id" : "4c035747-f77b-4c6d-b23b-cb3a2b96c7e6", "availability_zone" : "cn-north-7c", "comment" : "", "region" : "cn-north-7", "nics" : [ { "subnet_id" : "6201dcf2-1374-43ec-ae8b-78b4081572d3" } ], "security_groups" : [ { "id" : "04088976-9c63-4e6b-9070-84e6a30c782b" } ], "cloud_service_type" : "hws.service.type.dbss", "charging_mode" : 0, "period_type" : 2, "period_num" : 1, "subscription_num" : 1, "is_auto_renew" : 0, "product_infos" : [ { "product_id" : "00301-225396-0--0", "cloud_service_type" : "hws.service.type.dbss", "resource_type" : "hws.resource.type.dbss", "resource_spec_code" : "dbss.bypassaudit.low", "product_spec_desc" : "{\"specDesc\":{\"zh-cn\":{\"key1\":\"value1\"},\"en-us\":{\"key1\":\"value1\"}}}" } ], "promotion_info" : "", "enterprise_project_id" : "0", "tags" : [ { "key" : "key_test", "value" : "1" } ] } 创建一个包周期计费"chargin_mode : 0"的实例,版本为专业版:"resource_spec_code" : "dbss.bypassaudit.medium"。 { "flavor_ref": "c6.2xlarge.2", "name": "DBSS-test", "vpc_id": "4c035747-f77b-4c6d-b23b-cb3a2b96c7e6", "availability_zone": "cn-north-7b", "comment": "", "region": "cn-north-7", "nics": [ { "subnet_id": "6201dcf2-1374-43ec-ae8b-78b4081572d3" } ], "security_groups": [ { "id": "59c45017-a484-481b-8440-18c2214ccb06" } ], "cloud_service_type": "hws.service.type.dbss", "charging_mode": 0, "period_type": 2, "period_num": 1, "subscription_num": 1, "is_auto_renew": 0, "product_infos": [ { "product_id": "00301-225396-0--0", "cloud_service_type": "hws.service.type.dbss", "resource_type": "hws.resource.type.dbss", "resource_spec_code": "dbss.bypassaudit.medium", "product_spec_desc": "{\"specDesc\":{\"zh-cn\":{\"key1\":\"value1\"},\"en-us\":{\"key1\":\"value1\"}}}" } ], "promotion_info": "", "enterprise_project_id": "0" }
  • 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 # 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 = CreateInstancesPeriodOrderRequest() listTagsbody = [ KeyValueBean( key="key_test", value="1" ) ] listProductInfosbody = [ CreateInstancePeriodRequestProductInfos( product_id="00301-225396-0--0", cloud_service_type="hws.service.type.dbss", resource_type="hws.resource.type.dbss", resource_spec_code="dbss.bypassaudit.low", product_spec_desc="test" ) ] listSecurityGroupsbody = [ CreateInstancePeriodRequestSecurityGroups( id="04088976-9c63-4e6b-9070-84e6a30c782b" ) ] listNicsbody = [ CreateInstancePeriodRequestNics( subnet_id="6201dcf2-1374-43ec-ae8b-78b4081572d3" ) ] request.body = CreateInstancePeriodRequest( is_auto_renew=0, promotion_info="", tags=listTagsbody, product_infos=listProductInfosbody, subscription_num=1, period_num=1, period_type=2, charging_mode=0, cloud_service_type="hws.service.type.dbss", region="cn-north-7", comment="", security_groups=listSecurityGroupsbody, nics=listNicsbody, enterprise_project_id="0", availability_zone="cn-north-7c", vpc_id="4c035747-f77b-4c6d-b23b-cb3a2b96c7e6", name="DBSS-acc3", flavor_ref="st6.xlarge.4" ) response = client.create_instances_period_order(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 表8 响应Body参数 参数 参数类型 描述 description String 描述 code String 返回码 order_id String 订单ID 状态码: 400 表9 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表10 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。 状态码: 403 表11 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表12 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。 状态码: 500 表13 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表14 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。
  • 请求参数 表2 请求Header参数 参数 是否必选 参数类型 描述 X-Auth-Token 是 String 用户Token 表3 请求Body参数 参数 是否必选 参数类型 描述 flavor_ref 是 String 云服务器使用的规格ID name 是 String 云服务器名称。 取值范围: 只能由中文字符、英文字母、数字、下划线、中划线组成,且长度小于等于64个字符。 创建的云服务器数量大于1时,长度小于等于59个字符 vpc_id 是 String VPC的ID availability_zone 是 String 云服务器对应可用分区信息。(两个主备分区,中间用“,”分割,例如az1.dc1,az2.dc2) enterprise_project_id 是 String 企业项目ID nics 是 Array of nics objects 云服务器对应的网卡信息 security_groups 是 Array of security_groups objects 云服务器对应安全组信息 comment 否 String 备注信息 region 是 String 云服务器所在区域ID cloud_service_type 是 String 服务类型: 默认hws.service.type.dbss charging_mode 是 Integer 计费模式: 0:包周期计费 1:按需计费 period_type 是 Integer 订购周期类型: 0:天; 1:周; 2:月; 3:年; 4:小时; 5:绝对时间 period_num 是 Integer 订购周期数 subscription_num 是 Integer 订购数量: DBSS只支持订购1套,不支持多套 product_infos 是 Array of product_infos objects 产品信息列表 tags 否 Array of KeyValueBean objects 资源标签 promotion_info 否 String 折扣信息 is_auto_renew 否 Integer 自动续费 1表示自动续费,0表示不自动续费 表4 nics 参数 是否必选 参数类型 描述 subnet_id 是 String 网卡对应的子网ID ip_address 否 String IP地址,不填或空字符串为自动分配 表5 security_groups 参数 是否必选 参数类型 描述 id 是 String 云服务器对应的安全组ID,会对创建云服务器中配置的网卡生效 表6 product_infos 参数 是否必选 参数类型 描述 product_id 是 String 产品ID cloud_service_type 是 String 服务类型: 默认hws.service.type.dbss resource_type 是 String 资源类型: 默认hws.resource.type.dbss resource_spec_code 是 String 资源规格:dbss.bypassaudit.low、dbss.bypassaudit.medium、dbss.bypassaudit.high product_spec_desc 是 String 产品规格描述, json字符串格式 :{"specDesc":{"zh-cn":{"key1":"value1"},"en-us":{"key1":"value1"}}} 表7 KeyValueBean 参数 是否必选 参数类型 描述 key 是 String 键 value 是 String 值
  • 响应示例 状态码: 200 成功 { "servers" : [ { "name" : "DBSS-Test", "comment" : "", "connect_ipv6" : null, "status" : "ACTIVE", "task" : "NO_TASK", "id" : "8c53ed03-8ed7-4ff2-ad97-7b2d6d1dd364", "specification" : "Low | 3 Proxy", "zone" : "cn-cmcc1a-01", "created" : "2021-04-21 04:37:54", "expired" : null, "subnet_id" : "97ef0bb5-3759-4db4-aa49-0d087ed49ce5", "cpu" : 4, "ram" : 16384, "region" : "cn-cmcc1", "version" : "21.04.16.164614", "charge_model" : "Demand", "remain_days" : null, "config_num" : 1, "effect" : null, "scene" : null, "connect_ip" : "192.168.0.229", "port_id" : "dc4bd420-e01c-4d12-a7ff-814f17c63079", "resource_id" : "062212d8-8e30-4783-9671-43f3f1f3bb1e", "vpc_id" : "76d98391-5abc-46ed-b8a8-f664202cb166", "security_group_id" : "f0fbec06-bcf6-4c7e-99fa-f0ddfbb1d9bd", "resource_spec_code" : "dbss.bypassaudit.low", "keep_days" : null, "new_version" : null, "database_limit" : 3 } ], "total" : 1 } 状态码: 400 失败 { "error" : { "error_code" : "DBSS.XXXX", "error_msg" : "XXX" } }
  • 响应参数 状态码: 200 表4 响应Body参数 参数 参数类型 描述 servers Array of AuditInstanceListBean objects 实例信息列表 total Integer 总数 表5 AuditInstanceListBean 参数 参数类型 描述 charge_model String 付费模式 Period:包周期 Demand:按需。 comment String 备注信息。 config_num Integer 配置的数据库总数。 connect_ip String 连接地址。 connect_ipv6 String ipv6连接地址。 cpu Integer CPU个数 created String 创建时间 database_limit Integer 支持的数据库总数 effect Integer 1.冻结可释放 2.冻结不可释放 3.冻结后不可续费 expired String 过期时间 id String ID keep_days String 剩余天数 name String 实例别名 new_version String 如果有返回,则需要升级,如果没有,则为null port_id String 绑定弹性IP的portID ram Integer 内存 region String 实例所在region remain_days String 到期天数 resource_id String 资源ID resource_spec_code String 实例的规格 scene String 场景 security_group_id String 安全组 specification String 实例规格 status String 实例状态: SHUTOFF(已关闭) ACTIVE(运行中,允许任何操作) DELETING(删除中,不允许任何操作) BUILD(创建中,不允许任何操作) DELETED(已删除,不需要展示) ERROR(故障,只允许删除) HAWAIT(等待备机创建成功,不允许任何操作) FROZEN(已冻结,只允许续费、绑定/解绑) UPGRADING(升级中,不允许升级操作) subnet_id String 子网ID task String 任务状态: powering-on(正在开启,实例可以绑定、解绑) powering-off(正在关闭,实例可以绑定、解绑) rebooting(正在重启,实例可以绑定、解绑) delete_wait(等待删除,集群与实例不允许任何操作) NO_TASK(不展示) version String 实例的当前版本 vpc_id String 虚拟私有云 zone 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 成功 { "databases" : [ { "database" : { "id" : "zLKv83gBCwCqSg3BJt0m", "name" : "db01", "type" : "MYSQL", "version" : "5.0", "charset" : "UTF8", "ip" : "192.168.0.204", "port" : "3306", "os" : "LINUX64", "status" : "OFF", "instance_name" : "", "audit_status" : null, "agent_url" : [ "zrKw83gBCwCqSg3Bkt1P" ], "db_classification" : "ECS" } } ] } 状态码: 400 请求参数错误 { "error" : { "error_code" : "DBSS.XXXX", "error_msg" : "XXX" } } 状态码: 500 服务器内部错误 { "error" : { "error_code" : "DBSS.XXXX", "error_msg" : "XXX" } }
  • 响应参数 状态码: 200 表4 响应Body参数 参数 参数类型 描述 databases Array of DataBaseBean objects 数据库信息列表 total Integer 总数 表5 DataBaseBean 参数 参数类型 描述 database DataBase object 数据库信息 表6 DataBase 参数 参数类型 描述 id String 数据库ID name String 数据库名称 type String 添加的数据库类型: 枚举值:  MYSQL  ORACLE  POSTGRESQL  SQLSERVER  DAMENG  TAURUS  DWS  KINGBASE  GAUSSDBOPENGAUSS  GREENPLUM  HIGHGO  SHENTONG  GBASE8A  GBASE8S  GBASEXDM  MONGODB  DDS version String 数据库版本 charset String 数据库字符集 ip String 数据库IP port String 数据库端口 os String 数据库操作系统 status String 开启状态(1:开启,0:关闭) instance_name String 数据库实例名 audit_status String 数据库的运行状态 枚举值:  ACTIVE  SHUTOFF  ERROR agent_url Array of strings agent的唯一ID db_classification String 数据库分类,取值范围: RDS(表示RDS数据库)和 ECS(自建数据库) 状态码: 400 表7 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表8 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。 状态码: 403 表9 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表10 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。 状态码: 500 表11 响应Body参数 参数 参数类型 描述 error Object 错误信息返回体。 表12 ErrorDetail 参数 参数类型 描述 error_code String 错误请求返回的错误码。 error_msg String 错误请求返回的错误信息。
共100000条