Skip to content

Commit 97d7ded

Browse files
Merge pull request #162 from juliannagreen1/AA-1910
AA-1910 add allow_invocation_manually and allow_invocation_from_event_orchestration
2 parents ebbf6dc + 82f3463 commit 97d7ded

File tree

2 files changed

+63
-39
lines changed

2 files changed

+63
-39
lines changed

pagerduty/automation_actions_action.go

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,24 @@ import "fmt"
77
type AutomationActionsActionService service
88

99
type AutomationActionsAction struct {
10-
ID string `json:"id"`
11-
Name string `json:"name"`
12-
Description *string `json:"description,omitempty"`
13-
ActionType string `json:"action_type"`
14-
RunnerID *string `json:"runner,omitempty"`
15-
ActionDataReference AutomationActionsActionDataReference `json:"action_data_reference"`
16-
Services []*ServiceReference `json:"services,omitempty"`
17-
Teams []*TeamReference `json:"teams,omitempty"`
18-
Privileges *AutomationActionsPrivileges `json:"privileges,omitempty"`
19-
Type *string `json:"type,omitempty"`
20-
ActionClassification *string `json:"action_classification,omitempty"`
21-
RunnerType *string `json:"runner_type,omitempty"`
22-
CreationTime *string `json:"creation_time,omitempty"`
23-
ModifyTime *string `json:"modify_time,omitempty"`
24-
OnlyInvocableOnUnresolvedIncidents *bool `json:"only_invocable_on_unresolved_incidents,omitempty"`
10+
ID string `json:"id"`
11+
Name string `json:"name"`
12+
Description *string `json:"description,omitempty"`
13+
ActionType string `json:"action_type"`
14+
RunnerID *string `json:"runner,omitempty"`
15+
ActionDataReference AutomationActionsActionDataReference `json:"action_data_reference"`
16+
Services []*ServiceReference `json:"services,omitempty"`
17+
Teams []*TeamReference `json:"teams,omitempty"`
18+
Privileges *AutomationActionsPrivileges `json:"privileges,omitempty"`
19+
Type *string `json:"type,omitempty"`
20+
ActionClassification *string `json:"action_classification,omitempty"`
21+
RunnerType *string `json:"runner_type,omitempty"`
22+
CreationTime *string `json:"creation_time,omitempty"`
23+
ModifyTime *string `json:"modify_time,omitempty"`
24+
OnlyInvocableOnUnresolvedIncidents *bool `json:"only_invocable_on_unresolved_incidents,omitempty"`
25+
AllowInvocationManually *bool `json:"allow_invocation_manually,omitempty"`
26+
AllowInvocationFromEventOrchestration *bool `json:"allow_invocation_from_event_orchestration,omitempty"`
27+
MapToAllServices *bool `json:"map_to_all_services,omitempty"`
2528
}
2629

2730
type AutomationActionsActionDataReference struct {

pagerduty/automation_actions_action_test.go

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,24 @@ func TestAutomationActionsActionTypeProcessAutomationCreate(t *testing.T) {
9494
adf_node_filter := "tags: production"
9595
job_id := "1519578e-a22a-4340-b58f-08194691e10b"
9696
only_invocable_on_unresolved_incidents := true
97+
allow_invocation_manually := true
98+
allow_invocation_from_event_orchestration := true
99+
map_to_all_services := true
97100
adf := AutomationActionsActionDataReference{
98101
ProcessAutomationJobId: &job_id,
99102
ProcessAutomationJobArguments: &adf_arg,
100103
ProcessAutomationNodeFilter: &adf_node_filter,
101104
}
102105
input := &AutomationActionsAction{
103-
Name: "Action created by TF",
104-
Description: &description,
105-
ActionType: "process_automation",
106-
RunnerID: &runner_id,
107-
ActionDataReference: adf,
108-
OnlyInvocableOnUnresolvedIncidents: &only_invocable_on_unresolved_incidents,
106+
Name: "Action created by TF",
107+
Description: &description,
108+
ActionType: "process_automation",
109+
RunnerID: &runner_id,
110+
ActionDataReference: adf,
111+
OnlyInvocableOnUnresolvedIncidents: &only_invocable_on_unresolved_incidents,
112+
AllowInvocationManually: &allow_invocation_manually,
113+
AllowInvocationFromEventOrchestration: &allow_invocation_from_event_orchestration,
114+
MapToAllServices: &map_to_all_services,
109115
}
110116

111117
mux.HandleFunc("/automation_actions/actions", func(w http.ResponseWriter, r *http.Request) {
@@ -115,7 +121,7 @@ func TestAutomationActionsActionTypeProcessAutomationCreate(t *testing.T) {
115121
if !reflect.DeepEqual(v.Action, input) {
116122
t.Errorf("Request body = %+v, want %+v", v.Action, input)
117123
}
118-
w.Write([]byte(`{"action":{"only_invocable_on_unresolved_incidents":true,"action_data_reference":{"process_automation_job_id":"1519578e-a22a-4340-b58f-08194691e10b","process_automation_job_arguments":"-arg 123", "process_automation_node_filter":"tags: production"},"action_type":"process_automation","creation_time":"2022-12-12T18:51:42.048162Z","description":"Description of Action created by TF","id":"01DF4OBNYKW84FS9CCYVYS1MOS","last_run":"2022-12-12T18:52:11.937747Z","last_run_by":{"id":"PINL781","type":"user_reference"},"modify_time":"2022-12-12T18:51:42.048162Z","name":"Action created by TF","privileges":{"permissions":["read"]},"runner":"01DF4O9T1MDPYOUT7SUX9EXZ4R","runner_type":"runbook","services":[{"id":"PQWQ0U6","type":"service_reference"}],"teams":[{"id":"PZ31N6S","type":"team_reference"}],"type":"action"}}`))
124+
w.Write([]byte(`{"action":{"only_invocable_on_unresolved_incidents":true,"allow_invocation_manually":true,"allow_invocation_from_event_orchestration":true,"map_to_all_services":true,"action_data_reference":{"process_automation_job_id":"1519578e-a22a-4340-b58f-08194691e10b","process_automation_job_arguments":"-arg 123", "process_automation_node_filter":"tags: production"},"action_type":"process_automation","creation_time":"2022-12-12T18:51:42.048162Z","description":"Description of Action created by TF","id":"01DF4OBNYKW84FS9CCYVYS1MOS","last_run":"2022-12-12T18:52:11.937747Z","last_run_by":{"id":"PINL781","type":"user_reference"},"modify_time":"2022-12-12T18:51:42.048162Z","name":"Action created by TF","privileges":{"permissions":["read"]},"runner":"01DF4O9T1MDPYOUT7SUX9EXZ4R","runner_type":"runbook","services":[{"id":"PQWQ0U6","type":"service_reference"}],"teams":[{"id":"PZ31N6S","type":"team_reference"}],"type":"action"}}`))
119125
})
120126

121127
resp, _, err := client.AutomationActionsAction.Create(input)
@@ -153,8 +159,11 @@ func TestAutomationActionsActionTypeProcessAutomationCreate(t *testing.T) {
153159
Privileges: &AutomationActionsPrivileges{
154160
Permissions: []*string{&permissions_read},
155161
},
156-
ModifyTime: &modify_time,
157-
OnlyInvocableOnUnresolvedIncidents: &only_invocable_on_unresolved_incidents,
162+
ModifyTime: &modify_time,
163+
OnlyInvocableOnUnresolvedIncidents: &only_invocable_on_unresolved_incidents,
164+
AllowInvocationManually: &allow_invocation_manually,
165+
AllowInvocationFromEventOrchestration: &allow_invocation_from_event_orchestration,
166+
MapToAllServices: &map_to_all_services,
158167
}
159168

160169
if !reflect.DeepEqual(resp, want) {
@@ -172,18 +181,23 @@ func TestAutomationActionsActionUpdate(t *testing.T) {
172181
adf_node_filter := "tags: production"
173182
job_id := "1519578e-a22a-4340-b58f-08194691e10b"
174183
only_invocable_on_unresolved_incidents := true
184+
allow_invocation_manually := true
185+
allow_invocation_from_event_orchestration := true
186+
175187
adf := AutomationActionsActionDataReference{
176188
ProcessAutomationJobId: &job_id,
177189
ProcessAutomationJobArguments: &adf_arg,
178190
ProcessAutomationNodeFilter: &adf_node_filter,
179191
}
180192
input := &AutomationActionsAction{
181-
Name: "Action created by TF",
182-
Description: &description,
183-
ActionType: "process_automation",
184-
RunnerID: &runner_id,
185-
ActionDataReference: adf,
186-
OnlyInvocableOnUnresolvedIncidents: &only_invocable_on_unresolved_incidents,
193+
Name: "Action created by TF",
194+
Description: &description,
195+
ActionType: "process_automation",
196+
RunnerID: &runner_id,
197+
ActionDataReference: adf,
198+
OnlyInvocableOnUnresolvedIncidents: &only_invocable_on_unresolved_incidents,
199+
AllowInvocationManually: &allow_invocation_manually,
200+
AllowInvocationFromEventOrchestration: &allow_invocation_from_event_orchestration,
187201
}
188202

189203
var id = "01DF4OBNYKW84FS9CCYVYS1MOS"
@@ -196,7 +210,7 @@ func TestAutomationActionsActionUpdate(t *testing.T) {
196210
if !reflect.DeepEqual(v.Action, input) {
197211
t.Errorf("Request body = %+v, want %+v", v.Action, input)
198212
}
199-
w.Write([]byte(`{"action":{"only_invocable_on_unresolved_incidents":true,"action_data_reference":{"process_automation_job_id":"1519578e-a22a-4340-b58f-08194691e10b","process_automation_job_arguments":"-arg 123", "process_automation_node_filter":"tags: production"},"action_type":"process_automation","creation_time":"2022-12-12T18:51:42.048162Z","description":"Description of Action created by TF","id":"01DF4OBNYKW84FS9CCYVYS1MOS","last_run":"2022-12-12T18:52:11.937747Z","last_run_by":{"id":"PINL781","type":"user_reference"},"modify_time":"2022-12-12T18:51:42.048162Z","name":"Action created by TF","privileges":{"permissions":["read"]},"runner":"01DF4O9T1MDPYOUT7SUX9EXZ4R","runner_type":"runbook","services":[{"id":"PQWQ0U6","type":"service_reference"}],"teams":[{"id":"PZ31N6S","type":"team_reference"}],"type":"action"}}`))
213+
w.Write([]byte(`{"action":{"only_invocable_on_unresolved_incidents":true,"allow_invocation_manually":true,"allow_invocation_from_event_orchestration":true,"action_data_reference":{"process_automation_job_id":"1519578e-a22a-4340-b58f-08194691e10b","process_automation_job_arguments":"-arg 123", "process_automation_node_filter":"tags: production"},"action_type":"process_automation","creation_time":"2022-12-12T18:51:42.048162Z","description":"Description of Action created by TF","id":"01DF4OBNYKW84FS9CCYVYS1MOS","last_run":"2022-12-12T18:52:11.937747Z","last_run_by":{"id":"PINL781","type":"user_reference"},"modify_time":"2022-12-12T18:51:42.048162Z","name":"Action created by TF","privileges":{"permissions":["read"]},"runner":"01DF4O9T1MDPYOUT7SUX9EXZ4R","runner_type":"runbook","services":[{"id":"PQWQ0U6","type":"service_reference"}],"teams":[{"id":"PZ31N6S","type":"team_reference"}],"type":"action"}}`))
200214
})
201215

202216
resp, _, err := client.AutomationActionsAction.Update(id, input)
@@ -234,8 +248,10 @@ func TestAutomationActionsActionUpdate(t *testing.T) {
234248
Privileges: &AutomationActionsPrivileges{
235249
Permissions: []*string{&permissions_read},
236250
},
237-
ModifyTime: &modify_time,
238-
OnlyInvocableOnUnresolvedIncidents: &only_invocable_on_unresolved_incidents,
251+
ModifyTime: &modify_time,
252+
OnlyInvocableOnUnresolvedIncidents: &only_invocable_on_unresolved_incidents,
253+
AllowInvocationManually: &allow_invocation_manually,
254+
AllowInvocationFromEventOrchestration: &allow_invocation_from_event_orchestration,
239255
}
240256

241257
if !reflect.DeepEqual(resp, want) {
@@ -266,17 +282,22 @@ func TestAutomationActionsActionTypeScriptCreate(t *testing.T) {
266282
invocation_command := "/bin/bash"
267283
script_data := "java --version"
268284
only_invocable_on_unresolved_incidents := true
285+
allow_invocation_manually := true
286+
allow_invocation_from_event_orchestration := true
287+
269288
adf := AutomationActionsActionDataReference{
270289
Script: &script_data,
271290
InvocationCommand: &invocation_command,
272291
}
273292
input := &AutomationActionsAction{
274-
Name: "Action created by TF",
275-
Description: &description,
276-
ActionType: "script",
277-
RunnerID: &runner_id,
278-
ActionDataReference: adf,
279-
OnlyInvocableOnUnresolvedIncidents: &only_invocable_on_unresolved_incidents,
293+
Name: "Action created by TF",
294+
Description: &description,
295+
ActionType: "script",
296+
RunnerID: &runner_id,
297+
ActionDataReference: adf,
298+
OnlyInvocableOnUnresolvedIncidents: &only_invocable_on_unresolved_incidents,
299+
AllowInvocationManually: &allow_invocation_manually,
300+
AllowInvocationFromEventOrchestration: &allow_invocation_from_event_orchestration,
280301
}
281302

282303
mux.HandleFunc("/automation_actions/actions", func(w http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)