安全云脑 SECMASTER-创建剧本版本:Go

时间:2023-12-06 18:52:41

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)
    }
}
support.huaweicloud.com/api-secmaster/CreatePlaybookVersion.html