华为云用户手册

  • 响应参数 状态码: 200 表4 响应Header参数 参数 参数类型 描述 X-request-id String 请求ID,格式为:request_uuid-timestamp-hostname 表5 响应Body参数 参数 参数类型 描述 code String 错误码 最小长度:1 最大长度:32 message String 错误信息 最小长度:1 最大长度:32 data PlaybookInfo object 剧本详情信息 表6 PlaybookInfo 参数 参数类型 描述 id String 剧本ID 最小长度:32 最大长度:64 name String 剧本名称 最小长度:0 最大长度:1024 description String 描述信息 最小长度:0 最大长度:1024 create_time String 剧本创建时间 最小长度:0 最大长度:64 update_time String 剧本更新时间 最小长度:0 最大长度:64 project_id String 项目ID 最小长度:32 最大长度:64 version_id String 剧本版本ID 最小长度:32 最大长度:64 enabled Boolean 是否启用 workspace_id String 工作空间ID 最小长度:32 最大长度:64 approve_role String 审核用户角色 最小长度:0 最大长度:64 user_role String 用户角色 最小长度:0 最大长度:64 edit_role String 编辑用户角色 最小长度:0 最大长度:64 owner_id String 所有者ID 最小长度:32 最大长度:64 version String 版本号 最小长度:32 最大长度:64 dataclass_name String 数据类名称 最小长度:0 最大长度:64 dataclass_id String 数据类ID 最小长度:1 最大长度:64 unaudited_version_id String 待审核剧本版本ID 最小长度:1 最大长度:64 reject_version_id String 已驳回剧本版本ID 最小长度:1 最大长度:64 状态码: 400 表7 响应Header参数 参数 参数类型 描述 X-request-id String 请求ID,格式为:request_uuid-timestamp-hostname 表8 响应Body参数 参数 参数类型 描述 code String 错误码 最小长度:0 最大长度:64 message String 错误描述 最小长度:0 最大长度:1024
  • 响应示例 状态码: 200 请求成功响应信息 { "code" : 0, "message" : "Error message", "data" : { "id" : "909494e3-558e-46b6-a9eb-07a8e18ca62f", "name" : "MyXXX", "description" : "This my XXXX", "create_time" : "2021-01-30T23:00:00Z+0800", "update_time" : "2021-01-30T23:00:00Z+0800", "project_id" : "909494e3-558e-46b6-a9eb-07a8e18ca62f", "version_id" : "909494e3-558e-46b6-a9eb-07a8e18ca62f", "enabled" : true, "workspace_id" : "string", "approve_role" : "approve", "user_role" : "string", "edit_role" : "editor", "owner_id" : "909494e3-558e-46b6-a9eb-07a8e18ca62f", "version" : "v1.1.1", "dataclass_name" : "string", "dataclass_id" : "string", "unaudited_version_id" : "string", "reject_version_id" : "string" } }
  • Java 修改一个剧本,剧本名称为MyXXX,描述信息为This my XXXX,开启状态为已开启,启用剧本ID为active_version_id。 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 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.secmaster.v2.region.SecMasterRegion; import com.huaweicloud.sdk.secmaster.v2.*; import com.huaweicloud.sdk.secmaster.v2.model.*; public class UpdatePlaybookSolution { 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); SecMasterClient client = SecMasterClient.newBuilder() .withCredential(auth) .withRegion(SecMasterRegion.valueOf("cn-north-4")) .build(); UpdatePlaybookRequest request = new UpdatePlaybookRequest(); ModifyPlaybookInfo body = new ModifyPlaybookInfo(); body.withActiveVersionId("active_version_id"); body.withEnabled(true); body.withDescription("This my XXXX"); body.withName("MyXXX"); request.withBody(body); try { UpdatePlaybookResponse response = client.updatePlaybook(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()); } } }
  • URI PUT /v1/{project_id}/workspaces/{workspace_id}/soc/playbooks/{playbook_id} 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 项目ID 最小长度:32 最大长度:36 workspace_id 是 String 工作空间ID 最小长度:32 最大长度:36 playbook_id 是 String 剧本ID 最小长度:32 最大长度:64
  • 请求参数 表2 请求Header参数 参数 是否必选 参数类型 描述 X-Auth-Token 是 String 用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 最小长度:1 最大长度:2097152 content-type 是 String application/json;charset=UTF-8 缺省值:application/json;charset=UTF-8 最小长度:1 最大长度:64 表3 请求Body参数 参数 是否必选 参数类型 描述 name 否 String 剧本名称 最小长度:0 最大长度:1024 description 否 String 描述 最小长度:0 最大长度:1024 enabled 否 Boolean 是否启用 active_version_id 否 String 启用的剧本版本ID 最小长度:32 最大长度:64
  • Python 创建一条ID为f60bf0e7-73b8-4832-8fc4-8c2a12830552的事件关系。 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 # coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdksecmaster.v2.region.secmaster_region import SecMasterRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdksecmaster.v2 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 = SecMasterClient.new_builder() \ .with_credentials(credentials) \ .with_region(SecMasterRegion.value_of("cn-north-4")) \ .build() try: request = CreateDataobjectRelationsRequest() listIdsbody = [ "f60bf0e7-73b8-4832-8fc4-8c2a12830552" ] request.body = CreateDataobjectRelationsRequestBody( ids=listIdsbody ) response = client.create_dataobject_relations(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 创建一条ID为f60bf0e7-73b8-4832-8fc4-8c2a12830552的事件关系。 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 package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" secmaster "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2/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 := secmaster.NewSecMasterClient( secmaster.SecMasterClientBuilder(). WithRegion(region.ValueOf("cn-north-4")). WithCredential(auth). Build()) request := &model.CreateDataobjectRelationsRequest{} var listIdsbody = []string{ "f60bf0e7-73b8-4832-8fc4-8c2a12830552", } request.Body = &model.CreateDataobjectRelationsRequestBody{ Ids: &listIdsbody, } response, err := client.CreateDataobjectRelations(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • 响应示例 状态码: 200 关联Dataobject返回body体 { "code" : "909494e3-558e-46b6-a9eb-07a8e18ca62f", "message" : "Error message", "request_id" : "Error message", "success" : false, "total" : 41, "limit" : 3, "offset" : 10, "data" : { "success_ids" : [ "909494e3-558e-46b6-a9eb-07a8e18ca62f" ], "error_ids" : [ "909494e3-558e-46b6-a9eb-07a8e18ca62f" ] } }
  • 响应参数 状态码: 200 表4 响应Header参数 参数 参数类型 描述 X-request-id String 请求ID,格式为:request_uuid-timestamp-hostname 表5 响应Body参数 参数 参数类型 描述 code String Id value 最小长度:0 最大长度:64 message String Error message 最小长度:0 最大长度:32 request_id String Error message 最小长度:0 最大长度:32 success Boolean Error message 最小长度:1 最大长度:32 total Integer tatal count 最小值:0 最大值:99999 limit Integer current page count 最小值:0 最大值:9999 offset Integer current page size 最小值:0 最大值:100 data DataResponse object indicator batch operation response 表6 DataResponse 参数 参数类型 描述 success_ids Array of strings id list 最小长度:32 最大长度:64 数组长度:0 - 999 error_ids Array of strings id list 最小长度:32 最大长度:64 数组长度:0 - 999 状态码: 400 表7 响应Header参数 参数 参数类型 描述 X-request-id String 请求ID,格式为:request_uuid-timestamp-hostname 表8 响应Body参数 参数 参数类型 描述 code String 错误码 最小长度:0 最大长度:64 message String 错误描述 最小长度:0 最大长度:1024
  • URI POST /v1/{project_id}/workspaces/{workspace_id}/soc/{dataclass_type}/{data_object_id}/{related_dataclass_type} 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 项目id 最小长度:32 最大长度:36 workspace_id 是 String 工作空间id 最小长度:32 最大长度:36 dataclass_type 是 String 关联主体dataobject所属数据类,小写复数,如告警为alerts,事件为incidents 最小长度:1 最大长度:64 data_object_id 是 String 关联主体dataobject的id 最小长度:32 最大长度:36 related_dataclass_type 是 String 被关联的dataobject所属数据类,小写复数,如告警为alerts,事件为incidents 最小长度:1 最大长度:64
  • 请求参数 表2 请求Header参数 参数 是否必选 参数类型 描述 X-Auth-Token 是 String 用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值) 最小长度:0 最大长度:2097152 content-type 是 String 内容类型 缺省值:application/json;charset=UTF-8 最小长度:0 最大长度:64 表3 请求Body参数 参数 是否必选 参数类型 描述 ids 否 Array of strings 关联dataobject的ID列表 最小长度:32 最大长度:64 数组长度:0 - 100
  • Go 删除id为909494e3-558e-46b6-a9eb-07a8e18ca621的事件 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 package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" secmaster "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2/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 := secmaster.NewSecMasterClient( secmaster.SecMasterClientBuilder(). WithRegion(region.ValueOf("cn-north-4")). WithCredential(auth). Build()) request := &model.DeleteIncidentRequest{} var deleteIncidentRequestBodyDeleteIncidentRequestBody interface{} = "{\"ids\":\"909494e3-558e-46b6-a9eb-07a8e18ca621\"}" request.Body = listDeleteIncidentRequestBodyDeleteIncidentRequestBody response, err := client.DeleteIncident(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • Python 删除id为909494e3-558e-46b6-a9eb-07a8e18ca621的事件 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 # coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdksecmaster.v2.region.secmaster_region import SecMasterRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdksecmaster.v2 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 = SecMasterClient.new_builder() \ .with_credentials(credentials) \ .with_region(SecMasterRegion.value_of("cn-north-4")) \ .build() try: request = DeleteIncidentRequest() request.body = listDeleteIncidentRequestBodyDeleteIncidentRequestBody response = client.delete_incident(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 事件删除结果 { "code" : "909494e3-558e-46b6-a9eb-07a8e18ca62f", "message" : "Error message", "data" : { "error_ids" : [ "909494e3-558e-46b6-a9eb-07a8e18ca62f" ], "success_ids" : [ "909494e3-558e-46b6-a9eb-07a8e18ca62f" ] } }
  • Java 删除id为909494e3-558e-46b6-a9eb-07a8e18ca621的事件 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 package 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.secmaster.v2.region.SecMasterRegion; import com.huaweicloud.sdk.secmaster.v2.*; import com.huaweicloud.sdk.secmaster.v2.model.*; public class DeleteIncidentSolution { 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); SecMasterClient client = SecMasterClient.newBuilder() .withCredential(auth) .withRegion(SecMasterRegion.valueOf("cn-north-4")) .build(); DeleteIncidentRequest request = new DeleteIncidentRequest(); body.withDeleteIncidentRequestBody("{\"ids\":\"909494e3-558e-46b6-a9eb-07a8e18ca621\"}"); request.withBody(listDeleteIncidentRequestBodyDeleteIncidentRequestBody); try { DeleteIncidentResponse response = client.deleteIncident(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } }
  • 请求参数 表2 请求Header参数 参数 是否必选 参数类型 描述 X-Auth-Token 是 String 用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值) 最小长度:0 最大长度:2097152 content-type 是 String 内容类型 缺省值:application/json;charset=UTF-8 最小长度:0 最大长度:64 表3 请求Body参数 参数 是否必选 参数类型 描述 batch_ids 否 Array of strings 删除事件的ID列表 最小长度:0 最大长度:100 数组长度:0 - 999
  • 响应参数 状态码: 200 表4 响应Header参数 参数 参数类型 描述 X-request-id String 请求ID,格式为:request_uuid-timestamp-hostname 表5 响应Body参数 参数 参数类型 描述 code String 错误码 最小长度:0 最大长度:64 message String 错误信息 最小长度:0 最大长度:1024 data data object 批量删除事件返回对象 表6 data 参数 参数类型 描述 error_ids Array of strings 失败id 最小长度:0 最大长度:100 数组长度:0 - 100 success_ids Array of strings 成功id 最小长度:0 最大长度:100 数组长度:0 - 100 状态码: 400 表7 响应Header参数 参数 参数类型 描述 X-request-id String 请求ID,格式为:request_uuid-timestamp-hostname 表8 响应Body参数 参数 参数类型 描述 code String 错误码 最小长度:0 最大长度:64 message String 错误描述 最小长度:0 最大长度:1024
  • Go 创建一个剧本版本,剧本版本所属工作空间ID为string,剧本ID为909494e3-558e-46b6-a9eb-07a8e18ca62f,数据类ID为909494e3-558e-46b6-a9eb-07a8e18ca62f,规则为启用。 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 package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" secmaster "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2/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 := secmaster.NewSecMasterClient( secmaster.SecMasterClientBuilder(). WithRegion(region.ValueOf("cn-north-4")). WithCredential(auth). Build()) request := &model.CreatePlaybookVersionRequest{} idActions:= "909494e3-558e-46b6-a9eb-07a8e18ca62f" nameActions:= "MyXXX" descriptionActions:= "This my XXXX" actionTypeActions:= "Workflow" actionIdActions:= "909494e3-558e-46b6-a9eb-07a8e18ca62f" playbookIdActions:= "string" playbookVersionIdActions:= "string" projectIdActions:= "string" var listActionsbody = []model.ActionInfo{ { Id: &idActions, Name: &nameActions, Description: &descriptionActions, ActionType: &actionTypeActions, ActionId: &actionIdActions, PlaybookId: &playbookIdActions, PlaybookVersionId: &playbookVersionIdActions, ProjectId: &projectIdActions, }, } actionStrategyCreatePlaybookVersionInfo:= "sync" dataobjectDeleteCreatePlaybookVersionInfo:= true dataobjectUpdateCreatePlaybookVersionInfo:= true dataobjectCreateCreatePlaybookVersionInfo:= true triggerTypeCreatePlaybookVersionInfo:= "event" ruleIdCreatePlaybookVersionInfo:= "4185bbd2-9d18-4362-92cb-46df0b24fe4e" ruleEnableCreatePlaybookVersionInfo:= true dataclassIdCreatePlaybookVersionInfo:= "909494e3-558e-46b6-a9eb-07a8e18ca62f" playbookIdCreatePlaybookVersionInfo:= "909494e3-558e-46b6-a9eb-07a8e18ca62f" workspaceIdCreatePlaybookVersionInfo:= "string" descriptionCreatePlaybookVersionInfo:= "This my XXXX" request.Body = &model.CreatePlaybookVersionInfo{ ActionStrategy: &actionStrategyCreatePlaybookVersionInfo, DataobjectDelete: &dataobjectDeleteCreatePlaybookVersionInfo, DataobjectUpdate: &dataobjectUpdateCreatePlaybookVersionInfo, DataobjectCreate: &dataobjectCreateCreatePlaybookVersionInfo, TriggerType: &triggerTypeCreatePlaybookVersionInfo, RuleId: &ruleIdCreatePlaybookVersionInfo, RuleEnable: &ruleEnableCreatePlaybookVersionInfo, DataclassId: &dataclassIdCreatePlaybookVersionInfo, Actions: &listActionsbody, PlaybookId: &playbookIdCreatePlaybookVersionInfo, WorkspaceId: &workspaceIdCreatePlaybookVersionInfo, Description: &descriptionCreatePlaybookVersionInfo, } response, err := client.CreatePlaybookVersion(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • 请求示例 创建一个剧本版本,剧本版本所属工作空间ID为string,剧本ID为909494e3-558e-46b6-a9eb-07a8e18ca62f,数据类ID为909494e3-558e-46b6-a9eb-07a8e18ca62f,规则为启用。 { "description" : "This my XXXX", "workspace_id" : "string", "playbook_id" : "909494e3-558e-46b6-a9eb-07a8e18ca62f", "actions" : [ { "id" : "909494e3-558e-46b6-a9eb-07a8e18ca62f", "name" : "MyXXX", "description" : "This my XXXX", "action_type" : "Workflow", "action_id" : "909494e3-558e-46b6-a9eb-07a8e18ca62f", "playbook_id" : "string", "playbook_version_id" : "string", "project_id" : "string" } ], "dataclass_id" : "909494e3-558e-46b6-a9eb-07a8e18ca62f", "rule_enable" : true, "rule_id" : "4185bbd2-9d18-4362-92cb-46df0b24fe4e", "trigger_type" : "event", "dataobject_create" : true, "dataobject_update" : true, "dataobject_delete" : true, "action_strategy" : "sync" }
  • 响应参数 状态码: 200 表5 响应Header参数 参数 参数类型 描述 X-request-id String 请求ID,格式为:request_uuid-timestamp-hostname 表6 响应Body参数 参数 参数类型 描述 code String 错误码 最小长度:1 最大长度:32 message String Error message 最小长度:1 最大长度:32 data PlaybookVersionInfo object 剧本版本详情信息 表7 PlaybookVersionInfo 参数 参数类型 描述 id String 剧本版本ID 最小长度:32 最大长度:64 description String 描述 最小长度:0 最大长度:1024 create_time String 创建时间 最小长度:0 最大长度:64 update_time String 更新时间 最小长度:0 最大长度:64 project_id String 项目ID 最小长度:32 最大长度:64 creator_id String 创建者ID 最小长度:32 最大长度:64 modifier_id String 修改者ID 最小长度:32 最大长度:64 playbook_id String 剧本ID 最小长度:32 最大长度:64 version String 版本号 最小长度:32 最大长度:64 enabled Boolean 是否启用。(true--已启用,false-未启用) status String 剧本版本状态,编辑中:EDITING 审核中:APPROVING 不通过:UNPASSED 已发布:PUBLISHED 最小长度:0 最大长度:64 action_strategy String 执行策略. 目前仅支持异步并发执行,对应值为ASYNC 最小长度:0 最大长度:64 actions Array of ActionInfo objects 剧本关联流程列表信息 数组长度:0 - 99 rule_enable Boolean 是否启用触发条件过滤器 rules RuleInfo object 剧本触发规格信息 dataclass_id String 数据类ID 最小长度:0 最大长度:64 trigger_type String 剧本触发方式(EVENT--事件触发,TIMER--定时触发) 最小长度:0 最大长度:64 dataobject_create Boolean 标识数据对象是否创建时触发剧本 dataobject_update Boolean 标识数据对象是否更新时触发剧本 dataobject_delete Boolean 标识数据对象是否删除时触发剧本 version_type Integer 版本类型(0--草稿版本,1--正式版本) 最小值:0 最大值:1 rule_id String 过滤规则ID 最小长度:0 最大长度:64 dataclass_name String 数据类名称 最小长度:0 最大长度:64 approve_name String 审核者 最小长度:0 最大长度:64 表8 ActionInfo 参数 参数类型 描述 id String 剧本流程动作ID 最小长度:32 最大长度:64 name String 流程动作名称 最小长度:0 最大长度:1024 description String 描述 最小长度:0 最大长度:1024 action_type String 流程动作类型 最小长度:0 最大长度:64 action_id String 流程ID 最小长度:32 最大长度:64 playbook_id String 剧本ID 最小长度:0 最大长度:64 playbook_version_id String 剧本版本ID 最小长度:0 最大长度:64 project_id String 项目ID 最小长度:0 最大长度:64 表9 RuleInfo 参数 参数类型 描述 id String 规则ID 最小长度:32 最大长度:64 project_id String 项目ID 最小长度:32 最大长度:64 rule String 触发规则 最小长度:0 最大长度:128 状态码: 400 表10 响应Header参数 参数 参数类型 描述 X-request-id String 请求ID,格式为:request_uuid-timestamp-hostname 表11 响应Body参数 参数 参数类型 描述 code String 错误码 最小长度:0 最大长度:64 message String 错误描述 最小长度:0 最大长度:1024
  • Python 创建一个剧本版本,剧本版本所属工作空间ID为string,剧本ID为909494e3-558e-46b6-a9eb-07a8e18ca62f,数据类ID为909494e3-558e-46b6-a9eb-07a8e18ca62f,规则为启用。 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 # coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdksecmaster.v2.region.secmaster_region import SecMasterRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdksecmaster.v2 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 = SecMasterClient.new_builder() \ .with_credentials(credentials) \ .with_region(SecMasterRegion.value_of("cn-north-4")) \ .build() try: request = CreatePlaybookVersionRequest() listActionsbody = [ ActionInfo( id="909494e3-558e-46b6-a9eb-07a8e18ca62f", name="MyXXX", description="This my XXXX", action_type="Workflow", action_id="909494e3-558e-46b6-a9eb-07a8e18ca62f", playbook_id="string", playbook_version_id="string", project_id="string" ) ] request.body = CreatePlaybookVersionInfo( action_strategy="sync", dataobject_delete=True, dataobject_update=True, dataobject_create=True, trigger_type="event", rule_id="4185bbd2-9d18-4362-92cb-46df0b24fe4e", rule_enable=True, dataclass_id="909494e3-558e-46b6-a9eb-07a8e18ca62f", actions=listActionsbody, playbook_id="909494e3-558e-46b6-a9eb-07a8e18ca62f", workspace_id="string", description="This my XXXX" ) response = client.create_playbook_version(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 请求成功响应信息 { "code" : 0, "message" : "Error message", "data" : { "id" : "909494e3-558e-46b6-a9eb-07a8e18ca62f", "description" : "This my XXXX", "create_time" : "2021-01-30T23:00:00Z+0800", "update_time" : "2021-01-30T23:00:00Z+0800", "project_id" : "909494e3-558e-46b6-a9eb-07a8e18ca62f", "creator_id" : "909494e3-558e-46b6-a9eb-07a8e18ca62f", "modifier_id" : "909494e3-558e-46b6-a9eb-07a8e18ca62f", "playbook_id" : "909494e3-558e-46b6-a9eb-07a8e18ca62f", "version" : "v1.1.1", "enabled" : true, "status" : "editing", "action_strategy" : "sync", "actions" : [ { "id" : "909494e3-558e-46b6-a9eb-07a8e18ca62f", "name" : "MyXXX", "description" : "This my XXXX", "action_type" : "Workflow", "action_id" : "909494e3-558e-46b6-a9eb-07a8e18ca62f", "playbook_id" : "string", "playbook_version_id" : "string", "project_id" : "string" } ], "rule_enable" : true, "rules" : { "id" : "909494e3-558e-46b6-a9eb-07a8e18ca62f", "project_id" : "909494e3-558e-46b6-a9eb-07a8e18ca62f", "rule" : "909494e3-558e-46b6-a9eb-07a8e18ca62f" }, "dataclass_id" : "909494e3-558e-46b6-a9eb-07a8e18ca62f", "trigger_type" : "event", "dataobject_create" : true, "dataobject_update" : true, "dataobject_delete" : true, "version_type" : 1, "rule_id" : "string", "dataclass_name" : "string", "approve_name" : "string" } }
  • URI POST /v1/{project_id}/workspaces/{workspace_id}/soc/playbooks/{playbook_id}/versions 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 项目ID 最小长度:32 最大长度:36 workspace_id 是 String 工作空间ID 最小长度:32 最大长度:36 playbook_id 是 String 剧本ID 最小长度:32 最大长度:64
  • 请求参数 表2 请求Header参数 参数 是否必选 参数类型 描述 X-Auth-Token 是 String 用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 最小长度:1 最大长度:2097152 content-type 是 String application/json;charset=UTF-8 缺省值:application/json;charset=UTF-8 最小长度:1 最大长度:64 表3 请求Body参数 参数 是否必选 参数类型 描述 description 否 String 描述 最小长度:0 最大长度:1024 workspace_id 否 String 工作空间ID 最小长度:0 最大长度:2097152 playbook_id 否 String 剧本ID 最小长度:32 最大长度:64 actions 否 Array of ActionInfo objects 关联流程列表 数组长度:0 - 99 dataclass_id 否 String 数据类ID 最小长度:32 最大长度:64 rule_enable 否 Boolean 过滤规则是否启用 rule_id 否 String 过滤规则ID 最小长度:0 最大长度:64 trigger_type 否 String 触发方式. EVENT--事件触发, TIMER--定时触发 最小长度:0 最大长度:64 dataobject_create 否 Boolean 标识数据对象是否创建时触发剧本 dataobject_update 否 Boolean 标识数据对象是否更新时触发剧本 dataobject_delete 否 Boolean 标识数据对象是否删除时触发剧本 action_strategy 否 String 执行策略. 目前仅支持异步并发执行,对应值为ASYNC 最小长度:1 最大长度:64 表4 ActionInfo 参数 是否必选 参数类型 描述 id 否 String 剧本流程动作ID 最小长度:32 最大长度:64 name 否 String 流程动作名称 最小长度:0 最大长度:1024 description 否 String 描述 最小长度:0 最大长度:1024 action_type 否 String 流程动作类型 最小长度:0 最大长度:64 action_id 否 String 流程ID 最小长度:32 最大长度:64 playbook_id 否 String 剧本ID 最小长度:0 最大长度:64 playbook_version_id 否 String 剧本版本ID 最小长度:0 最大长度:64 project_id 否 String 项目ID 最小长度:0 最大长度:64
  • 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.secmaster.v2.region.SecMasterRegion; import com.huaweicloud.sdk.secmaster.v2.*; import com.huaweicloud.sdk.secmaster.v2.model.*; public class ListAlertRuleMetricsSolution { 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); SecMasterClient client = SecMasterClient.newBuilder() .withCredential(auth) .withRegion(SecMasterRegion.valueOf("cn-north-4")) .build(); ListAlertRuleMetricsRequest request = new ListAlertRuleMetricsRequest(); try { ListAlertRuleMetricsResponse response = client.listAlertRuleMetrics(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 huaweicloudsdksecmaster.v2.region.secmaster_region import SecMasterRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdksecmaster.v2 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 = SecMasterClient.new_builder() \ .with_credentials(credentials) \ .with_region(SecMasterRegion.value_of("cn-north-4")) \ .build() try: request = ListAlertRuleMetricsRequest() response = client.list_alert_rule_metrics(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
  • URI GET /v1/{project_id}/workspaces/{workspace_id}/siem/alert-rules/metrics 表1 路径参数 参数 是否必选 参数类型 描述 project_id 是 String 项目 ID。Project ID. 最小长度:32 最大长度:36 workspace_id 是 String 工作空间 ID。Workspace ID. 最小长度:32 最大长度:36
  • 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" secmaster "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2/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 := secmaster.NewSecMasterClient( secmaster.SecMasterClientBuilder(). WithRegion(region.ValueOf("cn-north-4")). WithCredential(auth). Build()) request := &model.ListAlertRuleMetricsRequest{} response, err := client.ListAlertRuleMetrics(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • Go 查询id为id1、id2,名称为指标名称,类型为DATA_SOURCE,数据类id为28f61af50fc9452aa0ed5ea25c3cc3d3的指标列表,偏移量为0,查询上限10条,根据create_time排序 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 package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" secmaster "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2/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 := secmaster.NewSecMasterClient( secmaster.SecMasterClientBuilder(). WithRegion(region.ValueOf("cn-north-4")). WithCredential(auth). Build()) request := &model.ListIndicatorsRequest{} var listIdsbody = []string{ "id1", "id2", } sortByIndicatorListSearchRequest:= "create_time" dataclassIdIndicatorListSearchRequest:= "28f61af50fc9452aa0ed5ea25c3cc3d3" nameIndicatorListSearchRequest:= "指标名称" request.Body = &model.IndicatorListSearchRequest{ SortBy: &sortByIndicatorListSearchRequest, Limit: int32(10), Offset: int32(0), Condition: "{conditions: [{name: "title", data: ["title", "=", "事件"]}], logics: ["title"]}", DataclassId: &dataclassIdIndicatorListSearchRequest, Name: &nameIndicatorListSearchRequest, Ids: &listIdsbody, } response, err := client.ListIndicators(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
  • 响应示例 状态码: 200 请求成功响应信息 { "code" : "00000000", "data" : [ { "create_time" : "2023-07-24T20:54:19Z+0800", "data_object" : { "indicator_type" : { "layout_id" : "20e45c85-8192-3142-bfc8-54b784a80c69", "indicator_type" : "ipv6", "id" : "ac794b2dfab9fe8c0676587301a636d3", "category" : "ipv6" }, "revoked" : false, "workspace_id" : "d5baeef8-3e75-4e91-9826-fb208ac58987", "update_time" : "2023-07-24T20:54:19.038Z+0800", "project_id" : "15645222e8744afa985c93dab6341da6", "first_report_time" : "2023-07-31T20:54:12.000Z+0800", "id" : "ff61d1f8-0de4-4077-9e9b-e312f6829c6d", "granular_marking" : 1, "value" : "{}", "create_time" : "2023-07-24T20:54:19.038Z+0800", "confidence" : 80, "last_report_time" : "2023-07-25T20:54:15.000Z+0800", "data_source" : { "domain_id" : "ac7438b990ef4a37b741004eb45e8bf4", "project_id" : "15645222e8744afa985c93dab6341da6", "region_id" : "cn-XXX-7", "source_type" : 1 }, "environment" : { "domain_id" : "ac7438b990ef4a37b741004eb45e8bf4", "project_id" : "15645222e8744afa985c93dab6341da6", "region_id" : "cn-xxx-7", "vendor_type" : "xxx" }, "verdict" : "Black", "name" : "test", "status" : "Open" }, "dataclass_ref" : { "id" : "97ccf890-7480-31f6-a961-cf8da1f2f040", "name" : "name" }, "id" : "ff61d1f8-0de4-4077-9e9b-e312f6829c6d", "update_time" : "2023-07-24T20:54:19Z+0800" } ], "message" : "", "total" : 2 }
共100000条