华为云用户手册

  • URI DELETE /v1.0/{project_id}/tracker 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 项目ID,获取方法请参见获取项目ID。 表2 Query参数 参数 是否必选 参数类型 描述 tracker_name 是 String 标识追踪器名称。 在不传入该字段的情况下,将删除当前租户所有的追踪器。 当前版本单租户仅支持一个追踪器,名称默认为“system”。
  • 基本概念 追踪器 使用 云审计 服务前需要开通云审计服务,开通云审计服务时系统会自动创建一个追踪器。该追踪器会自动识别并关联当前租户所使用的所有云服务,并将当前租户的所有操作记录在该追踪器中。 目前,一个租户仅支持创建1个管理追踪器和100个数据追踪器。 事件 事件即云审计服务追踪并保存的云服务资源的操作日志。您可以通过“事件”了解到谁在什么时间对系统哪些资源做了什么操作。 事件分为以下两类:管理类事件和数据类事件,管理类事件指云服务上报的事件,数据类事件指OBS服务上报的读写操作事件。 账号 用户注册时的账号,账号对其所拥有的资源及云服务具有完全的访问权限,可以重置用户密码、分配用户权限等。由于账号是付费主体,为了确保账号安全,建议您不要直接使用账号进行日常管理工作,而是创建用户并使用该用户进行日常管理工作。 用户 由账号在 IAM 中创建的用户,是云服务的使用人员,具有身份凭证(密码和访问密钥)。 在我的凭证下,您可以查看账号ID和IAM用户ID。通常在调用API的鉴权过程中,您需要用到账号、用户和密码等信息。 区域(Region) 从地理位置和网络时延维度划分,同一个Region内共享弹性计算、块存储、对象存储、VPC网络、弹性公网IP、镜像等公共服务。Region分为通用Region和专属Region,通用Region指面向公共租户提供通用云服务的Region;专属Region指只承载同一类业务或只面向特定租户提供业务服务的专用Region。 详情请参见区域和可用区。 可用区(AZ,Availability Zone) 一个可用区是一个或多个物理数据中心的集合,有独立的风火水电,AZ内逻辑上再将计算、网络、存储等资源划分成多个集群。一个Region中的多个AZ间通过高速光纤相连,以满足用户跨AZ构建高可用性系统的需求。 项目 区域默认对应一个项目,这个项目由系统预置,用来隔离物理区域间的资源(计算资源、存储资源和网络资源),以默认项目为单位进行授权,用户可以访问您账号中该区域的所有资源。如果您希望进行更加精细的权限控制,可以在区域默认的项目中创建子项目,并在子项目中创建资源,然后以子项目为单位进行授权,使得用户仅能访问特定子项目中资源,使得资源的权限控制更加精确。 图1 项目隔离模型 同样在我的凭证下,您可以查看项目ID。 企业项目 企业项目是项目的升级版,针对企业不同项目间资源的分组和管理,是逻辑隔离。企业项目中可以包含多个区域的资源,且项目中的资源可以迁入迁出。 关于企业项目ID的获取及企业项目特性的详细信息,请参见《企业管理用户指南》。 父主题: 使用前必读
  • 响应示例 状态码: 200 请求成功。 { "trackers" : [ { "is_support_trace_files_encryption" : true, "create_time" : 1589886034121, "stream_id" : "4a1ef2b6-d79a-4dc6-90f0-48151cd5491b", "kms_id" : "7dbbb3fa-93e4-4528-bc7b-9beb794b0229", "group_id" : "26fa12ac-75f7-42ed-8118-ab9f2263042f", "is_support_validate" : false, "obs_info" : { "is_obs_created" : false, "bucket_name" : "", "is_authorized_bucket" : false, "file_prefix_name" : "", "bucket_lifecycle" : 0 }, "lts" : { "log_group_name" : " CTS ", "is_lts_enabled" : true, "log_topic_name" : "system-trace" }, "tracker_type" : "system", "domain_id" : "2306579dc99f4c8690b14b68e734fcd9", "project_id" : "24edf66e79d04187acb99a463e610764", "tracker_name" : "system", "id" : "ebf8d1c3-762b-4ce3-b316-6b1aa32f8be3", "status" : "enabled" }, { "domain_id" : "2306579dc99f4c8690b14b68e734fcd9", "is_support_trace_files_encryption" : false, "obs_info" : { "is_obs_created" : false, "bucket_name" : "", "is_authorized_bucket" : false, "file_prefix_name" : "", "bucket_lifecycle" : 0 }, "create_time" : 1589276171198, "project_id" : "24edf66e79d04187acb99a463e610764", "data_bucket" : { "data_event" : [ "READ", "WRITE" ], "search_enabled" : false, "data_bucket_name" : "cstest0423" }, "tracker_name" : "sdsa", "is_support_validate" : false, "lts" : { "log_group_name" : "CTS", "is_lts_enabled" : false, "log_topic_name" : "sdsa" }, "id" : "c9a3961d-3aa0-4e60-8e63-dd4ce7f1a88a", "status" : "enabled", "tracker_type" : "data" } ] }
  • 响应参数 状态码: 200 表3 响应Body参数 参数 参数类型 描述 trackers Array of TrackerResponseBody objects 本次查询追踪器列表返回的追踪器数组。 表4 TrackerResponseBody 参数 参数类型 描述 id String 追踪器唯一标识。 create_time Long 追踪器创建时间戳。 kms_id String 事件文件转储加密所采用的秘钥id(从KMS获取)。当"tracker_type"参数值为"system"和"is_support_trace_files_encryption"参数值为“是”时,此参数为必选项。 is_support_validate Boolean 是否打开事件文件校验。 lts Lts object 事件分析 tracker_type String 标识追踪器类型。 目前支持系统追踪器类型有管理类追踪器(system)和数据类追踪器(data)。 枚举值: system data domain_id String 账号ID,参见《云审计服务API参考》“获取账号ID和项目ID”章节。 project_id String 项目ID。 tracker_name String 标识追踪器名称,当前版本默认为“system”。 status String 标识追踪器状态,包括正常(enabled),停止(disabled)和异常(error)三种状态,状态为异常时需通过明细(detail)字段说明错误来源。 枚举值: enabled disabled detail String 该参数仅在追踪器状态异常时返回,用于标识追踪器异常的原因,包括桶策略异常(bucketPolicyError),桶不存在(noBucket)和欠费或冻结(arrears)三种原因。 is_support_trace_files_encryption Boolean 事件文件转储加密功能开关。 该参数必须与kms_id参数同时使用。 当前环境仅"tracker_type"参数值为"system"时支持该功能。 obs_info ObsInfo object 事件转储桶信息。 data_bucket DataBucketQuery object 数据类事件追踪桶信息。 当"tracker_type"参数值为"data"时有效。 group_id String LTS服务日志组的ID。 stream_id String LTS服务日志流的ID。 is_organization_tracker Boolean 是否应用到我的组织。 只针对管理类追踪器。设置为true时,ORG组织下所有成员当前区域的审计日志会转储到该追踪器配置的OBS桶或者LTS日志流,但是事件列表界面不支持查看其它组织成员的审计日志。 management_event_selector ManagementEventSelector object 管理类事件选择器。 表5 Lts 参数 参数类型 描述 is_lts_enabled Boolean 是否启用日志服务检索功能。 log_group_name String 云审计服务在日志服务中创建的日志组名称。 log_topic_name String 云审计服务在日志服务中创建的日志主题名称。 表6 ObsInfo 参数 参数类型 描述 bucket_name String 标识OBS桶名称。由数字或字母开头,支持小写字母、数字、“-”、“.”,长度为3~63个字符。 file_prefix_name String 标识需要存储于OBS的日志文件前缀,0-9,a-z,A-Z,'-','.','_'长度为0~64字符。 is_obs_created Boolean 标识配置桶是否由追踪器自动创建。 is_authorized_bucket Boolean 标识配置桶是否已经授权给CTS服务账号。 bucket_lifecycle Long 标识配置桶内对象存储周期。 当"tracker_type"参数值为"data"时该参数值有效。 compress_type String 压缩类型。包括不压缩(json),压缩(gzip)两种状态。默认为gzip格式。 枚举值: gzip json is_sort_by_service Boolean 路径按云服务划分,打开后转储文件路径中将增加云服务名。默认为true。 表7 DataBucketQuery 参数 参数类型 描述 data_bucket_name String 标识OBS桶名称。由数字或字母开头,支持小写字母、数字、“-”、“.”,长度为3~63个字符。 search_enabled Boolean 追踪桶日志是否支持搜索。 data_event Array of strings 数据类追踪器追踪对象的桶名。 当启用或者停用数据类追踪器时,该参数为必选。 管理类追踪器无此参数。 追踪器一旦创建追踪桶无法修改。 READ OBS对象读取操作;WRITE OBS对象写操作。 枚举值: WRITE READ 表8 ManagementEventSelector 参数 参数类型 描述 exclude_service Array of strings 标识不转储的云服务名称。 目前只支持设置为KMS,表示屏蔽KMS服务的createDatakey事件。 状态码: 400 表9 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 401 表10 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 403 表11 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 500 表12 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 503 表13 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。
  • URI GET /v3/{project_id}/trackers 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 项目ID,参见获取账号ID和项目ID章节。 表2 Query参数 参数 是否必选 参数类型 描述 tracker_name 否 String 标示追踪器名称。 在不传入该字段的情况下,将查询租户所有的追踪器。 tracker_type 否 String 标识追踪器类型。 目前支持系统追踪器有管理类追踪器(system)和数据类追踪器(data)。 枚举值: system data
  • 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 huaweicloudsdkcts.v3.region.cts_region import CtsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkcts.v3 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 = CtsClient.new_builder() \ .with_credentials(credentials) \ .with_region(CtsRegion.value_of("cn-north-4")) \ .build() try: request = ListQuotasRequest() response = client.list_quotas(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
  • Go 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" cts "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cts/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cts/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cts/v3/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 := cts.NewCtsClient( cts.CtsClientBuilder(). WithRegion(region.ValueOf("cn-north-4")). WithCredential(auth). Build()) request := &model.ListQuotasRequest{} response, err := client.ListQuotas(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • 响应参数 状态码: 200 表2 响应Body参数 参数 参数类型 描述 resources Array of Quota objects 本次查询追踪器列表返回的追踪器数组。 表3 Quota 参数 参数类型 描述 type String quota资源类型。 used Long 已使用的资源个数。 quota Long 总资源个数。 状态码: 400 表4 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 401 表5 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 403 表6 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 404 表7 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 500 表8 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 503 表9 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。
  • Java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 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.cts.v3.region.CtsRegion; import com.huaweicloud.sdk.cts.v3.*; import com.huaweicloud.sdk.cts.v3.model.*; public class ListQuotasSolution { 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); CtsClient client = CtsClient.newBuilder() .withCredential(auth) .withRegion(CtsRegion.valueOf("cn-north-4")) .build(); ListQuotasRequest request = new ListQuotasRequest(); try { ListQuotasResponse response = client.listQuotas(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()); } } }
  • 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.cts.v3.region.CtsRegion; import com.huaweicloud.sdk.cts.v3.*; import com.huaweicloud.sdk.cts.v3.model.*; public class ListTraceResourcesSolution { 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); CtsClient client = CtsClient.newBuilder() .withCredential(auth) .withRegion(CtsRegion.valueOf("cn-north-4")) .build(); ListTraceResourcesRequest request = new ListTraceResourcesRequest(); try { ListTraceResourcesResponse response = client.listTraceResources(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()); } } }
  • 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 huaweicloudsdkcts.v3.region.cts_region import CtsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkcts.v3 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 = CtsClient.new_builder() \ .with_credentials(credentials) \ .with_region(CtsRegion.value_of("cn-north-4")) \ .build() try: request = ListTraceResourcesRequest() response = client.list_trace_resources(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 请求成功。 { "resources" : [ { "service_type" : "CTS", "resource" : [ "trace", "notification", "tracker" ] }, { "service_type" : " AOM ", "resource" : [ "xxxx1", "xxxx2" ] } ] }
  • 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" cts "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cts/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cts/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cts/v3/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 := cts.NewCtsClient( cts.CtsClientBuilder(). WithRegion(region.ValueOf("cn-north-4")). WithCredential(auth). Build()) request := &model.ListTraceResourcesRequest{} response, err := client.ListTraceResources(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • 响应参数 状态码: 200 表2 响应Body参数 参数 参数类型 描述 resources Array of TraceResource objects 返回的资源类型列表。 表3 TraceResource 参数 参数类型 描述 service_type String 云服务类型。必须为已对接CTS的云服务的英文缩写,且服务类型一般为大写字母。 resource Array of strings 云服务对应的资源类型列表。 状态码: 400 表4 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 401 表5 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 403 表6 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 404 表7 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 500 表8 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 503 表9 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 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 package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" cts "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cts/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cts/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cts/v3/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 := cts.NewCtsClient( cts.CtsClientBuilder(). WithRegion(region.ValueOf("cn-north-4")). WithCredential(auth). Build()) request := &model.BatchDeleteResourceTagsRequest{} keyTags:= "111" valueTags:= "33" var listTagsbody = []model.Tags{ { Key: &keyTags, Value: &valueTags, }, } request.Body = &model.BatchDeleteResourceTagsRequestBody{ Tags: &listTagsbody, } response, err := client.BatchDeleteResourceTags(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • 响应参数 状态码: 401 表4 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 403 表5 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 404 表6 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 500 表7 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 503 表8 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。
  • 请求参数 表2 请求Body参数 参数 是否必选 参数类型 描述 tags 否 Array of Tags objects 标签列表。 表3 Tags 参数 是否必选 参数类型 描述 key 否 String 键。最大长度128个unicode字符。标签的键可以包含任意语种字母、数字、空格和_ . : = + - @,但首尾不能含有空格,不能以_sys_开头。 value 否 String 值。每个值最大长度255个unicode字符,删除时如果value有值按照key/value删除,如果value没值,则按照key删除。标签的值可以包含任意语种字母、数字、空格和_ . : / = + - @,但首尾不能含有空格。
  • URI DELETE /v3/{project_id}/{resource_type}/{resource_id}/tags/delete 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 项目ID,参见获取账号ID和项目ID章节。 resource_type 是 String CTS服务的资源类型,目前仅支持cts-tracker。 枚举值: cts-tracker resource_id 是 String 资源ID。
  • 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 # coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkcts.v3.region.cts_region import CtsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkcts.v3 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 = CtsClient.new_builder() \ .with_credentials(credentials) \ .with_region(CtsRegion.value_of("cn-north-4")) \ .build() try: request = BatchDeleteResourceTagsRequest() listTagsbody = [ Tags( key="111", value="33" ) ] request.body = BatchDeleteResourceTagsRequestBody( tags=listTagsbody ) response = client.batch_delete_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 请求正常。 { "versions" : [ { "id" : "v1.0", "links" : { "href" : "https://x.x.x.x/v1.0/", "rel" : "self" }, "min_version" : "", "status" : "CURRENT", "updated" : "2018-09-30T00:00:00Z", "version" : "" }, { "id" : "v2.0", "links" : { "href" : "https://x.x.x.x/v2.0/", "rel" : "self" }, "min_version" : "", "status" : "SUPPORTED", "updated" : "2018-09-30T00:00:00Z", "version" : "" } ] }
  • 响应参数 状态码: 200 表1 响应Body参数 参数 参数类型 描述 versions Array of Versions objects 描述versions相关对象的列表。 表2 Versions 参数 参数类型 描述 id String 版本ID(版本号),如v1。 links Array of LinksBody objects API的URL地址。 version String 若该版本API支持微版本,则填支持的最大微版本号,如果不支持微版本,则填空。 status String 版本状态,为如下3种: CURRENT:表示该版本为主推版本。 SUPPORTED:表示为老版本,但是现在还继续支持。 DEPRECATED:表示为废弃版本,存在后续删除的可能。 枚举值: CURRENT SUPPORTED DEPRECATED updated String 版本发布时间,要求用UTC时间表示。如v1发布的时间2014-06-28T12:20:21Z。 min_version String 若该版本API 支持微版本,则填支持的最小微版本号, 如果不支持微版本,则填空。 表3 LinksBody 参数 参数类型 描述 href String 当前API版本的引用地址。 rel String 当前API版本和被引用地址的关系。
  • 响应示例 状态码: 200 请求正常。 { "meta_data" : { "count" : 2, "marker" : "e001ccb8-bc09-11e6-b2cc-2640a43cc6e8" }, "traces" : [ { "time" : 1472148708232, "user" : { "name" : "xxx", "domain" : { "name" : "xxx", "id" : "ded649d814464428ba89d04d7955c93e" } }, "response" : { "code" : "VPC.0514", "message" : "Update port fail." }, "code" : 200, "service_type" : "VPC", "resource_type" : "eip", "resource_name" : "192.144.163.1", "resource_id" : "d502809d-0d1d-41ce-9690-784282142ccc", "trace_name" : "deleteEip", "trace_rating" : "warning", "trace_type" : "ConsoleAction", "api_version" : "2.0", "record_time" : 1481066128032, "trace_id" : "e001ccb9-bc09-11e6-b00b-4b2a61338db6" }, { "time" : 1472148708232, "user" : { "name" : "xxx", "domain" : { "name" : "xxx", "id" : "ded649d814464428ba89d04d7955c93e" } }, "response" : { "code" : "VPC.0514", "message" : "Update port fail." }, "code" : 200, "service_type" : "VPC", "resource_type" : "eip", "resource_name" : "192.144.163.1", "resource_id" : "d502809d-0d1d-41ce-9690-784282142ccc", "trace_name" : "deleteEip", "trace_rating" : "warning", "trace_type" : "ConsoleAction", "api_version" : "2.0", "record_time" : 1481066128032, "trace_id" : "e001ccb8-bc09-11e6-b2cc-2640a43cc6e8" } ] }
  • URI GET /v1.0/{project_id}/{tracker_name}/trace 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 项目ID,获取方法请参见获取项目ID。 tracker_name 是 String 当前版本单租户仅支持一个追踪器,名称默认为“system”。 表2 Query参数 参数 是否必选 参数类型 描述 service_type 否 String 标识查询事件列表对应的云服务类型。必须为已对接CTS的云服务的英文缩写,且服务类型一般为大写字母。已对接的云服务列表参见《云审计服务用户指南》“支持审计的服务及详细操作列表”章节,单击对应云服务的文档链接,可以查看到该云服务的英文缩写。 user 否 String 标识特定用户名称,用以查询该用户下的所有事件。 from 否 Long 标识查询事件列表的起始时间戳(timestamp,为标准UTC时间,毫秒级,13位数字,不包括传入时间)默认为上一小时的时间戳。查询条件from与to配套使用。 limit 否 Integer 标示查询事件列表中限定返回的事件条数。不传时默认10条,最大值200条。 next 否 String 取值为响应中中marker的值,用于标识查询事件的起始时间(自此条事件的记录时间起,向更早时间查询)。 可以与“from”、“to”结合使用。 最终的查询条件取两组时间条件的交集。 resource_id 否 String 标示查询事件列表对应的云服务资源ID。 resource_name 否 String 标示查询事件列表对应的的资源名称。 说明:该字段可能包含大写字母。 resource_type 否 String 标示查询事件列表对应的资源类型。 to 否 Long 标识查询事件列表的结束时间戳(timestamp,为标准UTC时间,毫秒级,13位数字,不包括传入时间)默认为当前时间戳。查询条件to与from配套使用。 trace_id 否 String 标示某一条事件的事件ID。当传入这个查询条件时,其他查询条件自动不生效。 trace_name 否 String 标示查询事件列表对应的事件名称。 说明:该字段可能包含大写字母。 trace_rating 否 String 标示查询事件列表对应的事件等级目前有三种:正常(normal), 警告(warning),事故(incident)。
  • 响应参数 状态码: 200 表3 响应Body参数 参数 参数类型 描述 traces Array of Traces objects 本次查询事件列表返回事件数组。 meta_data MetaData object 本次查询事件条数和标记位。 表4 Traces 参数 参数类型 描述 resource_id String 标识事件对应的云服务资源ID。 trace_name String 标识查询事件列表对应的事件名称。由0-9,a-z,A-Z,'-','.','_',组成,长度为1~64个字符,且以首字符必须为字母。 trace_rating String 标识事件等级,目前有三种:正常(normal),警告(warning),事故(incident)。 枚举值: normal warning incident trace_type String 标识事件发生源头类型,主要包括API调用(ApiCall),Console页面调用(ConsoleAction)和系统间调用(SystemAction)。 request String 标识事件对应接口请求内容,即资源操作请求体。 response String 记录用户请求的响应,标识事件对应接口响应内容,即资源操作结果返回体。 code String 记录用户请求的响应,标识事件对应接口返回的HTTP状态码。 api_version String 标识事件对应的云服务接口版本。 message String 标识其他云服务为此条事件添加的备注信息。 record_time Long 标识云审计服务记录本次事件的时间戳。 trace_id String 标识事件的ID,由系统生成的UUID。 time Long 标识事件产生的时间戳。 user UserInfo object 标识触发事件的用户信息。 service_type String 标识查询事件列表对应的云服务类型。必须为已对接CTS的云服务的英文缩写,且服务类型一般为大写字母。已对接的云服务列表参见《云审计服务用户指南》“支持审计的服务及详细操作列表”章节,单击对应云服务的文档链接,可以查看到该云服务的英文缩写。 resource_type String 查询事件列表对应的资源类型。 source_ip String 标识触发事件的租户IP。 resource_name String 标识事件对应的资源名称。 request_id String 记录本次请求的request id location_info String 记录本次请求出错后,问题定位所需要的辅助信息。 endpoint String 云资源的详情页面 resource_url String 云资源的详情页面的访问链接(不含endpoint) 表5 UserInfo 参数 参数类型 描述 id String 账号ID,获取方式请参见获取账号ID。 name String 账号名称。 domain BaseUser object 标识触发事件的用户domain信息。 表6 BaseUser 参数 参数类型 描述 id String 账号ID,获取方式请参见获取账号ID。 name String 账号名称。 表7 MetaData 参数 参数类型 描述 count Integer 标识本次查询事件列表返回的事件记录的总条数。 marker String 标识本次查询事件列表返回的最后一个事件ID。可以使用这个参数返回值作为分页请求参数next的值,如果marker返回为null,则表示当前请求条件下查询事件列表已经全部返回没有下一页。
  • Go 检查obs桶状态请求体示例 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 package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" cts "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cts/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cts/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cts/v3/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 := cts.NewCtsClient( cts.CtsClientBuilder(). WithRegion(region.ValueOf("cn-north-4")). WithCredential(auth). Build()) request := &model.CheckObsBucketsRequest{} kmsIdBuckets:= "1f26f8d8-65d4-436b-bea2-bd0ac1984f71" isSupportTraceFilesEncryptionBuckets:= false kmsIdBuckets1:= "0c1b7d87-5186-411a-86ce-ed3b2ec848c9" isSupportTraceFilesEncryptionBuckets1:= false var listBucketsbody = []model.CheckBucketRequest{ { BucketName: "bucket1", BucketLocation: "cn-north-1", KmsId: &kmsIdBuckets, IsSupportTraceFilesEncryption: &isSupportTraceFilesEncryptionBuckets, }, { BucketName: "bucket2", BucketLocation: "cn-north-2", KmsId: &kmsIdBuckets1, IsSupportTraceFilesEncryption: &isSupportTraceFilesEncryptionBuckets1, }, } request.Body = &model.CheckObsBucketsRequestBody{ Buckets: &listBucketsbody, } response, err := client.CheckObsBuckets(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • Python 检查obs桶状态请求体示例 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 # coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkcts.v3.region.cts_region import CtsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkcts.v3 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 = CtsClient.new_builder() \ .with_credentials(credentials) \ .with_region(CtsRegion.value_of("cn-north-4")) \ .build() try: request = CheckObsBucketsRequest() listBucketsbody = [ CheckBucketRequest( bucket_name="bucket1", bucket_location="cn-north-1", kms_id="1f26f8d8-65d4-436b-bea2-bd0ac1984f71", is_support_trace_files_encryption=False ), CheckBucketRequest( bucket_name="bucket2", bucket_location="cn-north-2", kms_id="0c1b7d87-5186-411a-86ce-ed3b2ec848c9", is_support_trace_files_encryption=False ) ] request.body = CheckObsBucketsRequestBody( buckets=listBucketsbody ) response = client.check_obs_buckets(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 请求成功。 { "buckets" : [ { "bucket_location" : "cn-north-1", "bucket_name" : "bucket1", "check_bucket_response" : { "response_code" : 200, "success" : true }, "is_support_trace_files_encryption" : false, "kms_id" : "1f26f8d8-65d4-436b-bea2-bd0ac1984f71" }, { "bucket_location" : "cn-north-2", "bucket_name" : "bucket2", "check_bucket_response" : { "error_code" : "OBS.NoSuchBucket", "error_message" : "Error message:Request Error.OBS service Error Message.", "response_code" : 404, "success" : false }, "is_support_trace_files_encryption" : false, "kms_id" : "0c1b7d87-5186-411a-86ce-ed3b2ec848c9" } ] }
  • 响应参数 状态码: 200 表4 响应Body参数 参数 参数类型 描述 buckets Array of Bucket objects 检查OBS桶状态响应体。 表5 Bucket 参数 参数类型 描述 bucket_name String 标识OBS桶名称。由数字或字母开头,支持小写字母、数字、“-”、“.”,长度为3~63个字符。 bucket_location String 标识桶位置。 kms_id String 事件文件转储加密所采用的秘钥id。 如果is_support_trace_files_encryption"参数值为“是”时,此参数为必选项。 is_support_trace_files_encryption Boolean 事件文件转储加密功能开关。 该参数必须与kms_id参数同时使用。 check_bucket_response CheckBucketResponse object 转储OBS桶的检查结果。 表6 CheckBucketResponse 参数 参数类型 描述 error_code String 错误码。 error_message String 错误信息。 response_code Integer 返回的http状态码。 success Boolean 是否成功转储。 状态码: 400 表7 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 401 表8 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 403 表9 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 404 表10 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 500 表11 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 503 表12 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。
  • 请求示例 检查obs桶状态请求体示例 POST https://{endpoint}/v3/{domain_id}/checkbucket { "buckets" : [ { "bucket_location" : "cn-north-1", "bucket_name" : "bucket1", "is_support_trace_files_encryption" : false, "kms_id" : "1f26f8d8-65d4-436b-bea2-bd0ac1984f71" }, { "bucket_location" : "cn-north-2", "bucket_name" : "bucket2", "is_support_trace_files_encryption" : false, "kms_id" : "0c1b7d87-5186-411a-86ce-ed3b2ec848c9" } ] }
  • 请求参数 表2 请求Body参数 参数 是否必选 参数类型 描述 buckets 否 Array of CheckBucketRequest objects 请求检查的OBS桶列表。 表3 CheckBucketRequest 参数 是否必选 参数类型 描述 bucket_name 是 String 标识OBS桶名称。由数字或字母开头,支持小写字母、数字、“-”、“.”,长度为3~63个字符。 bucket_location 是 String 标识OBS桶位置。 kms_id 否 String 事件文件转储加密所采用的秘钥id,is_support_trace_files_encryption"参数值为“是”时,此参数为必选项。 is_support_trace_files_encryption 否 Boolean 事件文件转储加密功能开关。 该参数必须与kms_id参数同时使用。
共100000条