Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AA-1910 add allow_invocation_manually and allow_invocation_from_event_orchestration #162

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions pagerduty/automation_actions_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,23 @@ import "fmt"
type AutomationActionsActionService service

type AutomationActionsAction struct {
ID string `json:"id"`
Name string `json:"name"`
Description *string `json:"description,omitempty"`
ActionType string `json:"action_type"`
RunnerID *string `json:"runner,omitempty"`
ActionDataReference AutomationActionsActionDataReference `json:"action_data_reference"`
Services []*ServiceReference `json:"services,omitempty"`
Teams []*TeamReference `json:"teams,omitempty"`
Privileges *AutomationActionsPrivileges `json:"privileges,omitempty"`
Type *string `json:"type,omitempty"`
ActionClassification *string `json:"action_classification,omitempty"`
RunnerType *string `json:"runner_type,omitempty"`
CreationTime *string `json:"creation_time,omitempty"`
ModifyTime *string `json:"modify_time,omitempty"`
OnlyInvocableOnUnresolvedIncidents *bool `json:"only_invocable_on_unresolved_incidents,omitempty"`
ID string `json:"id"`
Name string `json:"name"`
Description *string `json:"description,omitempty"`
ActionType string `json:"action_type"`
RunnerID *string `json:"runner,omitempty"`
ActionDataReference AutomationActionsActionDataReference `json:"action_data_reference"`
Services []*ServiceReference `json:"services,omitempty"`
Teams []*TeamReference `json:"teams,omitempty"`
Privileges *AutomationActionsPrivileges `json:"privileges,omitempty"`
Type *string `json:"type,omitempty"`
ActionClassification *string `json:"action_classification,omitempty"`
RunnerType *string `json:"runner_type,omitempty"`
CreationTime *string `json:"creation_time,omitempty"`
ModifyTime *string `json:"modify_time,omitempty"`
OnlyInvocableOnUnresolvedIncidents *bool `json:"only_invocable_on_unresolved_incidents,omitempty"`
AllowInvocationManually *bool `json:"allow_invocation_manually,omitempty"`
AllowInvocationFromEventOrchestration *bool `json:"allow_invocation_from_event_orchestration,omitempty"`
}

type AutomationActionsActionDataReference struct {
Expand Down
66 changes: 42 additions & 24 deletions pagerduty/automation_actions_action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,22 @@ func TestAutomationActionsActionTypeProcessAutomationCreate(t *testing.T) {
adf_node_filter := "tags: production"
job_id := "1519578e-a22a-4340-b58f-08194691e10b"
only_invocable_on_unresolved_incidents := true
allow_invocation_manually := true
allow_invocation_from_event_orchestration := true
adf := AutomationActionsActionDataReference{
ProcessAutomationJobId: &job_id,
ProcessAutomationJobArguments: &adf_arg,
ProcessAutomationNodeFilter: &adf_node_filter,
}
input := &AutomationActionsAction{
Name: "Action created by TF",
Description: &description,
ActionType: "process_automation",
RunnerID: &runner_id,
ActionDataReference: adf,
OnlyInvocableOnUnresolvedIncidents: &only_invocable_on_unresolved_incidents,
Name: "Action created by TF",
Description: &description,
ActionType: "process_automation",
RunnerID: &runner_id,
ActionDataReference: adf,
OnlyInvocableOnUnresolvedIncidents: &only_invocable_on_unresolved_incidents,
AllowInvocationManually: &allow_invocation_manually,
AllowInvocationFromEventOrchestration: &allow_invocation_from_event_orchestration,
}

mux.HandleFunc("/automation_actions/actions", func(w http.ResponseWriter, r *http.Request) {
Expand All @@ -115,7 +119,7 @@ func TestAutomationActionsActionTypeProcessAutomationCreate(t *testing.T) {
if !reflect.DeepEqual(v.Action, input) {
t.Errorf("Request body = %+v, want %+v", v.Action, input)
}
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"}}`))
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"}}`))
})

resp, _, err := client.AutomationActionsAction.Create(input)
Expand Down Expand Up @@ -153,8 +157,10 @@ func TestAutomationActionsActionTypeProcessAutomationCreate(t *testing.T) {
Privileges: &AutomationActionsPrivileges{
Permissions: []*string{&permissions_read},
},
ModifyTime: &modify_time,
OnlyInvocableOnUnresolvedIncidents: &only_invocable_on_unresolved_incidents,
ModifyTime: &modify_time,
OnlyInvocableOnUnresolvedIncidents: &only_invocable_on_unresolved_incidents,
AllowInvocationManually: &allow_invocation_manually,
AllowInvocationFromEventOrchestration: &allow_invocation_from_event_orchestration,
}

if !reflect.DeepEqual(resp, want) {
Expand All @@ -172,18 +178,23 @@ func TestAutomationActionsActionUpdate(t *testing.T) {
adf_node_filter := "tags: production"
job_id := "1519578e-a22a-4340-b58f-08194691e10b"
only_invocable_on_unresolved_incidents := true
allow_invocation_manually := true
allow_invocation_from_event_orchestration := true

adf := AutomationActionsActionDataReference{
ProcessAutomationJobId: &job_id,
ProcessAutomationJobArguments: &adf_arg,
ProcessAutomationNodeFilter: &adf_node_filter,
}
input := &AutomationActionsAction{
Name: "Action created by TF",
Description: &description,
ActionType: "process_automation",
RunnerID: &runner_id,
ActionDataReference: adf,
OnlyInvocableOnUnresolvedIncidents: &only_invocable_on_unresolved_incidents,
Name: "Action created by TF",
Description: &description,
ActionType: "process_automation",
RunnerID: &runner_id,
ActionDataReference: adf,
OnlyInvocableOnUnresolvedIncidents: &only_invocable_on_unresolved_incidents,
AllowInvocationManually: &allow_invocation_manually,
AllowInvocationFromEventOrchestration: &allow_invocation_from_event_orchestration,
}

var id = "01DF4OBNYKW84FS9CCYVYS1MOS"
Expand All @@ -196,7 +207,7 @@ func TestAutomationActionsActionUpdate(t *testing.T) {
if !reflect.DeepEqual(v.Action, input) {
t.Errorf("Request body = %+v, want %+v", v.Action, input)
}
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"}}`))
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"}}`))
})

resp, _, err := client.AutomationActionsAction.Update(id, input)
Expand Down Expand Up @@ -234,8 +245,10 @@ func TestAutomationActionsActionUpdate(t *testing.T) {
Privileges: &AutomationActionsPrivileges{
Permissions: []*string{&permissions_read},
},
ModifyTime: &modify_time,
OnlyInvocableOnUnresolvedIncidents: &only_invocable_on_unresolved_incidents,
ModifyTime: &modify_time,
OnlyInvocableOnUnresolvedIncidents: &only_invocable_on_unresolved_incidents,
AllowInvocationManually: &allow_invocation_manually,
AllowInvocationFromEventOrchestration: &allow_invocation_from_event_orchestration,
}

if !reflect.DeepEqual(resp, want) {
Expand Down Expand Up @@ -266,17 +279,22 @@ func TestAutomationActionsActionTypeScriptCreate(t *testing.T) {
invocation_command := "/bin/bash"
script_data := "java --version"
only_invocable_on_unresolved_incidents := true
allow_invocation_manually := true
allow_invocation_from_event_orchestration := true

adf := AutomationActionsActionDataReference{
Script: &script_data,
InvocationCommand: &invocation_command,
}
input := &AutomationActionsAction{
Name: "Action created by TF",
Description: &description,
ActionType: "script",
RunnerID: &runner_id,
ActionDataReference: adf,
OnlyInvocableOnUnresolvedIncidents: &only_invocable_on_unresolved_incidents,
Name: "Action created by TF",
Description: &description,
ActionType: "script",
RunnerID: &runner_id,
ActionDataReference: adf,
OnlyInvocableOnUnresolvedIncidents: &only_invocable_on_unresolved_incidents,
AllowInvocationManually: &allow_invocation_manually,
AllowInvocationFromEventOrchestration: &allow_invocation_from_event_orchestration,
}

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