华为云用户手册

  • 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) } }
  • 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 表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 错误描述。
  • 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)
  • 请求参数 表2 请求Body参数 参数 是否必选 参数类型 描述 tags 否 Array of Tags objects 标签列表。 表3 Tags 参数 是否必选 参数类型 描述 key 否 String 键。最大长度128个unicode字符。标签的键可以包含任意语种字母、数字、空格和_ . : = + - @,但首尾不能含有空格,不能以_sys_开头。 value 否 String 值。每个值最大长度255个unicode字符,删除时如果value有值按照key/value删除,如果value没值,则按照key删除。标签的值可以包含任意语种字母、数字、空格和_ . : / = + - @,但首尾不能含有空格。
  • 响应参数 状态码: 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 请求正常。 { "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 请求正常。 { "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,则表示当前请求条件下查询事件列表已经全部返回没有下一页。
  • 响应参数 状态码: 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" } ] }
  • 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" } ] }
  • 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) } }
  • 请求参数 表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参数同时使用。
  • 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不同,使用时请注意。
  • 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....”加到请求消息头即可,如下所示。 POST https://iam.cn-north-1.myhuaweicloud.com/v3/auth/projectsContent-Type: application/json X-Auth-Token: ABCDEFJ....
  • 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 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.CreateNotificationRequest{} var listRuleFilter = []string{ "code != 200", "api_version = v1.0", "trace_rating = normal", "trace_type != ApiCall", "resource_id = xxx", "resource_name = xxx", } filterbody := &model.Filter{ Condition: model.GetFilterConditionEnum().OR, IsSupportFilter: true, Rule: listRuleFilter, } topicIdCreateNotificationRequestBody:= "urn:smn:{regionid}:24edf66e79d04187acb99a463e610764:test" request.Body = &model.CreateNotificationRequestBody{ Filter: filterbody, TopicId: &topicIdCreateNotificationRequestBody, OperationType: model.GetCreateNotificationRequestBodyOperationTypeEnum().COMPLETE, NotificationName: "test", } response, err := client.CreateNotification(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } 创建自定义类型关键操作通知请求样例。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 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.CreateNotificationRequest{} var listRuleFilter = []string{ "code != 200", "api_version = v1.0", "trace_rating = normal", "trace_type != ApiCall", "resource_id = xxx", "resource_name = xxx", } filterbody := &model.Filter{ Condition: model.GetFilterConditionEnum().OR, IsSupportFilter: true, Rule: listRuleFilter, } var listUserListNotifyUserList = []string{ "test3", "test4", } var listUserListNotifyUserList1 = []string{ "test1", "test2", } var listNotifyUserListbody = []model.NotificationUsers{ { UserGroup: "admin", UserList: listUserListNotifyUserList1, }, { UserGroup: "CTS view", UserList: listUserListNotifyUserList, }, } var listTraceNamesOperations = []string{ "deletePolicyGroup", "updatePolicyGroup", "createPolicyGroup", } var listTraceNamesOperations1 = []string{ "deleteNotification", "updateNotification", } var listTraceNamesOperations2 = []string{ "createTracker", "deleteTracker", } var listOperationsbody = []model.Operations{ { ServiceType: "CTS", ResourceType: "tracker", TraceNames: listTraceNamesOperations2, }, { ServiceType: "CTS", ResourceType: "notification", TraceNames: listTraceNamesOperations1, }, { ServiceType: "AOM", ResourceType: "pe", TraceNames: listTraceNamesOperations, }, } topicIdCreateNotificationRequestBody:= "urn:smn:{regionid}:24edf66e79d04187acb99a463e610764:test" request.Body = &model.CreateNotificationRequestBody{ Filter: filterbody, TopicId: &topicIdCreateNotificationRequestBody, NotifyUserList: &listNotifyUserListbody, Operations: &listOperationsbody, OperationType: model.GetCreateNotificationRequestBodyOperationTypeEnum().CUSTOMIZED, NotificationName: "keyOperate_info_cfwy", } response, err := client.CreateNotification(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • 响应示例 状态码: 201 创建成功。 { "create_time" : 1634001495876, "notification_id" : "cda8fd83-d08c-46f0-b914-1453a6a85c00", "notification_name" : "keyOperate_info_cfwy", "notification_type" : "smn", "notify_user_list" : [ { "user_group" : "admin", "user_list" : [ "test1", "test2" ] }, { "user_group" : "CTS view", "user_list" : [ "test3", "test4" ] } ], "operation_type" : "customized", "operations" : [ { "resource_type" : "tracker", "service_type" : "CTS", "trace_names" : [ "createTracker", "deleteTracker" ] }, { "resource_type" : "notification", "service_type" : "CTS", "trace_names" : [ "deleteNotification", "updateNotification" ] }, { "resource_type" : "pe", "service_type" : "AOM", "trace_names" : [ "deletePolicyGroup", "updatePolicyGroup", "createPolicyGroup" ] } ], "project_id" : "24edf66e79d04187acb99a463e610764", "status" : "enabled", "topic_id" : "urn:smn:{regionid}:24edf66e79d04187acb99a463e610764:test" }
  • 请求示例 创建完整类型关键操作通知请求样例。 POST https://{endpoint}/v3/{project_id}/notifications { "notification_name" : "test", "filter" : { "is_support_filter" : true, "rule" : [ "code != 200", "api_version = v1.0", "trace_rating = normal", "trace_type != ApiCall", "resource_id = xxx", "resource_name = xxx" ], "condition" : "OR" }, "operation_type" : "complete", "topic_id" : "urn:smn:{regionid}:24edf66e79d04187acb99a463e610764:test" } 创建自定义类型关键操作通知请求样例。 POST https://{endpoint}/v3/{project_id}/notifications { "notification_name" : "keyOperate_info_cfwy", "operation_type" : "customized", "filter" : { "is_support_filter" : true, "rule" : [ "code != 200", "api_version = v1.0", "trace_rating = normal", "trace_type != ApiCall", "resource_id = xxx", "resource_name = xxx" ], "condition" : "OR" }, "operations" : [ { "service_type" : "CTS", "resource_type" : "tracker", "trace_names" : [ "createTracker", "deleteTracker" ] }, { "service_type" : "CTS", "resource_type" : "notification", "trace_names" : [ "deleteNotification", "updateNotification" ] }, { "service_type" : "AOM", "resource_type" : "pe", "trace_names" : [ "deletePolicyGroup", "updatePolicyGroup", "createPolicyGroup" ] } ], "notify_user_list" : [ { "user_group" : "admin", "user_list" : [ "test1", "test2" ] }, { "user_group" : "CTS view", "user_list" : [ "test3", "test4" ] } ], "topic_id" : "urn:smn:{regionid}:24edf66e79d04187acb99a463e610764:test" }
  • 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 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 = CreateNotificationRequest() listRuleFilter = [ "code != 200", "api_version = v1.0", "trace_rating = normal", "trace_type != ApiCall", "resource_id = xxx", "resource_name = xxx" ] filterbody = Filter( condition="OR", is_support_filter=True, rule=listRuleFilter ) request.body = CreateNotificationRequestBody( filter=filterbody, topic_id="urn:smn:{regionid}:24edf66e79d04187acb99a463e610764:test", operation_type="complete", notification_name="test" ) response = client.create_notification(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) 创建自定义类型关键操作通知请求样例。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 # 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 = CreateNotificationRequest() listRuleFilter = [ "code != 200", "api_version = v1.0", "trace_rating = normal", "trace_type != ApiCall", "resource_id = xxx", "resource_name = xxx" ] filterbody = Filter( condition="OR", is_support_filter=True, rule=listRuleFilter ) listUserListNotifyUserList = [ "test3", "test4" ] listUserListNotifyUserList1 = [ "test1", "test2" ] listNotifyUserListbody = [ NotificationUsers( user_group="admin", user_list=listUserListNotifyUserList1 ), NotificationUsers( user_group="CTS view", user_list=listUserListNotifyUserList ) ] listTraceNamesOperations = [ "deletePolicyGroup", "updatePolicyGroup", "createPolicyGroup" ] listTraceNamesOperations1 = [ "deleteNotification", "updateNotification" ] listTraceNamesOperations2 = [ "createTracker", "deleteTracker" ] listOperationsbody = [ Operations( service_type="CTS", resource_type="tracker", trace_names=listTraceNamesOperations2 ), Operations( service_type="CTS", resource_type="notification", trace_names=listTraceNamesOperations1 ), Operations( service_type="AOM", resource_type="pe", trace_names=listTraceNamesOperations ) ] request.body = CreateNotificationRequestBody( filter=filterbody, topic_id="urn:smn:{regionid}:24edf66e79d04187acb99a463e610764:test", notify_user_list=listNotifyUserListbody, operations=listOperationsbody, operation_type="customized", notification_name="keyOperate_info_cfwy" ) response = client.create_notification(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
  • 响应参数 状态码: 201 表6 响应Body参数 参数 参数类型 描述 notification_name String 通知名称。 operation_type String 操作类型。和自定义。 complete:完整类型,对所有已对接云审计服务的所有操作发送SMN通知。 customized:自定义类型,对指定云服务的指定操作发送SMN通知。 枚举值: customized complete operations Array of Operations objects 操作事件列表。 notify_user_list Array of NotificationUsers objects 通知用户列表,目前最多支持对10个用户组和50个用户发起的操作进行配置。 status String 通知状态。启用和停用。 disabled:停用关键操作通知。 enabled:启用关键操作通知。 枚举值: enabled disabled topic_id String 消息通知服务(SMN)主题的唯一的资源标识,可通过查询主题列表获取该标识。 notification_id String 通知的唯一标识ID。 notification_type String 通知类型。 -smn:消息通知服务。 -fun:函数工作流。 枚举值: smn fun project_id String 项目ID。 create_time Long 通知规则创建时间。 filter Filter object 关键操作通知高级筛选条件。 表7 Operations 参数 参数类型 描述 service_type String 标识云服务类型。必须为已对接CTS的云服务的英文缩写,且服务类型一般为大写字母。 已对接的云服务列表参见《云审计服务用户指南》“支持审计的服务及详细操作列表”章节,单击对应云服务的文档链接,可以查看到该云服务的英文缩写。 resource_type String 标识资源类型。 trace_names Array of strings 标识事件名称。 表8 NotificationUsers 参数 参数类型 描述 user_group String IAM用户组。 user_list Array of strings IAM用户。 表9 Filter 参数 参数类型 描述 condition String 多条件关系。 AND(默认值) 表示所有过滤条件满足后生效。 OR 表示有任意一个条件满足时生效。 枚举值: AND(默认值) OR is_support_filter Boolean 是否打开高级筛选开关。 rule Array of strings 高级过滤条件规则,示例如下:"key != value",格式为:字段 规则 值。-字段取值范围:api_version,code,trace_rating,trace_type,resource_id,resource_name。-规则:!= 或 =。- 值:api_version正则约束:^(a-zA-Z0-9_-.){1,64}$;code:最小长度1,最大长度256;trace_rating枚举值:"normal", "warning", "incident";trace_type枚举值:"ConsoleAction", "ApiCall", "SystemAction";resource_id:最小长度1,最大长度350;resource_name:最小长度1,最大长度256 状态码: 400 表10 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 401 表11 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 403 表12 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 404 表13 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 500 表14 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。 状态码: 503 表15 响应Body参数 参数 参数类型 描述 error_code String 错误码标识,CTS.XXX。 error_msg String 错误描述。
  • 请求参数 表2 请求Body参数 参数 是否必选 参数类型 描述 notification_name 是 String 标识关键操作名称。 operation_type 是 String 标识操作类型。 目前支持的操作类型有完整类型(complete)和自定义类型(customized)。 完整类型下,CTS发送通知的对象为已对接服务的所有事件,此时不用指定operations和notify_user_list字段。 自定义类型下,CTS发送通知的对象是在operations列表中指定的事件。 枚举值: complete customized operations 否 Array of Operations objects 操作事件列表。 notify_user_list 否 Array of NotificationUsers objects 通知用户列表,目前最多支持对10个用户组和50个用户发起的操作进行配置。 topic_id 否 String 消息通知服务的topic_urn或者函数工作流的func_urn。- 消息通知服务的topic_urn可以通过消息通知服务的查询主题列表API获取,示例:urn:smn:regionId:f96188c7ccaf4ffba0c9aa149ab2bd57:test_topic_v2。- 函数工作流的func_urn可以通过函数工作流的获取函数列表API获取,示例:urn:fss:xxxxxxxxx:7aad83af3e8d42e99ac194e8419e2c9b:function:default:test。 filter 否 Filter object 关键操作通知高级过滤条件。 表3 Operations 参数 是否必选 参数类型 描述 service_type 是 String 标识云服务类型。必须为已对接CTS的云服务的英文缩写,且服务类型一般为大写字母。 已对接的云服务列表参见《云审计服务用户指南》“支持审计的服务及详细操作列表”章节,单击对应云服务的文档链接,可以查看到该云服务的英文缩写。 resource_type 是 String 标识资源类型。 trace_names 是 Array of strings 标识事件名称。 表4 NotificationUsers 参数 是否必选 参数类型 描述 user_group 是 String IAM用户组。 user_list 是 Array of strings IAM用户。 表5 Filter 参数 是否必选 参数类型 描述 condition 是 String 多条件关系。 AND(默认值) 表示所有过滤条件满足后生效。 OR 表示有任意一个条件满足时生效。 枚举值: AND(默认值) OR is_support_filter 是 Boolean 是否打开高级筛选开关。 rule 是 Array of strings 高级过滤条件规则,示例如下:"key != value",格式为:字段 规则 值。-字段取值范围:api_version,code,trace_rating,trace_type,resource_id,resource_name。-规则:!= 或 =。- 值:api_version正则约束:^(a-zA-Z0-9_-.){1,64}$;code:最小长度1,最大长度256;trace_rating枚举值:"normal", "warning", "incident";trace_type枚举值:"ConsoleAction", "ApiCall", "SystemAction";resource_id:最小长度1,最大长度350;resource_name:最小长度1,最大长度256
  • 支持的授权项 策略包含系统策略和自定义策略,如果系统策略不满足授权要求,企业管理员可以创建自定义策略,并通过给用户组授予自定义策略来进行精细的访问控制。策略支持的操作与API相对应,授权项列表说明如下: 权限:自定义策略中授权项定义的内容即为权限。 对应API接口:自定义策略实际调用的API接口。 授权项:自定义策略中支持的Action,在自定义策略中的Action中写入授权项,可以实现授权项对应的权限功能。 依赖的授权项:部分Action存在对其他Action的依赖,需要将依赖的Action同时写入授权项,才能实现对应的权限功能。 IAM项目(Project)/企业项目(Enterprise Project):自定义策略的授权范围,包括IAM项目与企业项目。授权范围如果同时支持IAM项目和企业项目,表示此授权项对应的自定义策略,可以在IAM和企业管理两个服务中给用户组授权并生效。如果仅支持IAM项目,不支持企业项目,表示仅能在IAM中给用户组授权并生效,如果在企业管理中授权,则该自定义策略不生效。关于IAM项目与企业项目的区别,详情请参见IAM与企业管理的区别。 “√”表示支持,“x”表示暂不支持。 权限 对应API接口 授权项(Action) 依赖的授权项 IAM项目 (Project) 企业项目 (Enterprise Project) 查询事件列表 GET /v3/{project_id}/traces cts:trace:list - √ x 查询事件列表 GET /v2.0/{project_id}/{tracker_name}/trace cts:trace:list - √ x 查询事件列表 GET /v1.0/{project_id}/{tracker_name}/trace cts:trace:list - √ x 查询追踪器 GET /v3/{project_id}/trackers cts:tracker:list obs:bucket:GetBucketAcl obs:bucket:ListAllMyBuckets √ x 查询追踪器 GET /v1.0/{project_id}/tracker cts:tracker:list obs:bucket:GetBucketAcl obs:bucket:ListAllMyBuckets √ x 创建追踪器 POST /v3/{project_id}/tracker cts:tracker:create lts:topics:list lts:topics:create lts:groups:list lts:groups:create obs:bucket:CreateBucket obs:bucket:HeadBucket obs:bucket:GetLifecycleConfiguration obs:bucket:PutLifecycleConfiguration obs:bucket:GetBucketAcl obs:bucket:PutBucketAclkms:cmk:list √ x 创建追踪器 POST /v1.0/{project_id}/tracker cts:tracker:create lts:topics:list lts:topics:create lts:groups:list lts:groups:create obs:bucket:CreateBucket obs:bucket:HeadBucket obs:bucket:GetLifecycleConfiguration obs:bucket:PutLifecycleConfiguration obs:bucket:GetBucketAcl obs:bucket:PutBucketAclkms:cmk:list √ x 修改追踪器 PUT /v3/{project_id}/tracker cts:tracker:update lts:topics:list lts:topics:create lts:groups:list lts:groups:create obs:bucket:CreateBucket obs:bucket:HeadBucket obs:bucket:GetLifecycleConfiguration obs:bucket:PutLifecycleConfiguration obs:bucket:GetBucketAcl obs:bucket:PutBucketAcl kms:cmk:list √ x 修改追踪器 PUT /v1.0/{project_id}/tracker/{tracker_name} cts:tracker:update lts:topics:list lts:topics:create lts:groups:list lts:groups:create obs:bucket:CreateBucket obs:bucket:HeadBucket obs:bucket:GetLifecycleConfiguration obs:bucket:PutLifecycleConfiguration obs:bucket:GetBucketAcl obs:bucket:PutBucketAcl kms:cmk:list √ x 删除追踪器 DELETE /v3/{project_id}/trackers cts:tracker:delete - √ x 删除追踪器 DELETE /v1.0/{project_id}/tracker cts:tracker:delete - √ x 查询租户追踪器配额信息 GET /v3/{project_id}/quotas cts:quota:get - √ x
  • 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 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.CreateTrackerRequest{} bucketNameObsInfo:= "test-data-tracker" filePrefixNameObsInfo:= "11" isObsCreatedObsInfo:= false obsInfobody := &model.TrackerObsInfo{ BucketName: &bucketNameObsInfo, FilePrefixName: &filePrefixNameObsInfo, IsObsCreated: &isObsCreatedObsInfo, } isSupportValidateCreateTrackerRequestBody:= true kmsIdCreateTrackerRequestBody:= "13a4207c-7abe-4b68-8510-16b84c3b5504" isSupportTraceFilesEncryptionCreateTrackerRequestBody:= true isLtsEnabledCreateTrackerRequestBody:= true request.Body = &model.CreateTrackerRequestBody{ IsSupportValidate: &isSupportValidateCreateTrackerRequestBody, KmsId: &kmsIdCreateTrackerRequestBody, IsSupportTraceFilesEncryption: &isSupportTraceFilesEncryptionCreateTrackerRequestBody, ObsInfo: obsInfobody, IsLtsEnabled: &isLtsEnabledCreateTrackerRequestBody, TrackerName: "system", TrackerType: model.GetCreateTrackerRequestBodyTrackerTypeEnum().SYSTEM, } response, err := client.CreateTracker(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } 数据类追踪器创建样例。 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 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.CreateTrackerRequest{} var listDataEventDataBucket = []model.DataBucketDataEvent{ model.GetDataBucketDataEventEnum().READ, model.GetDataBucketDataEventEnum().WRITE, } dataBucketNameDataBucket:= "cstest0423" dataBucketbody := &model.DataBucket{ DataBucketName: &dataBucketNameDataBucket, DataEvent: &listDataEventDataBucket, } bucketNameObsInfo:= "saveTraceBucket" filePrefixNameObsInfo:= "11" isObsCreatedObsInfo:= false bucketLifecycleObsInfo:= int32(30) obsInfobody := &model.TrackerObsInfo{ BucketName: &bucketNameObsInfo, FilePrefixName: &filePrefixNameObsInfo, IsObsCreated: &isObsCreatedObsInfo, BucketLifecycle: &bucketLifecycleObsInfo, } isLtsEnabledCreateTrackerRequestBody:= true request.Body = &model.CreateTrackerRequestBody{ DataBucket: dataBucketbody, ObsInfo: obsInfobody, IsLtsEnabled: &isLtsEnabledCreateTrackerRequestBody, TrackerName: "data-tracker-name", TrackerType: model.GetCreateTrackerRequestBodyTrackerTypeEnum().DATA, } response, err := client.CreateTracker(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
共100000条