From 060a8a6262e7d2f08c353a9e0b474b4630692bd2 Mon Sep 17 00:00:00 2001 From: Julianna Green Date: Tue, 29 Oct 2024 10:50:24 -0700 Subject: [PATCH] AA-1837 add only_invocable_on_unresolved_incidents attribute to automation action --- ...rce_pagerduty_automation_actions_action.go | 5 ++++ ...agerduty_automation_actions_action_test.go | 1 + ...rce_pagerduty_automation_actions_action.go | 14 +++++++++ ...agerduty_automation_actions_action_test.go | 7 ++++- .../pagerduty/automation_actions_action.go | 29 ++++++++++--------- .../d/automation_actions_action.html.markdown | 7 +++-- .../r/automation_actions_action.html.markdown | 3 +- 7 files changed, 47 insertions(+), 19 deletions(-) diff --git a/pagerduty/data_source_pagerduty_automation_actions_action.go b/pagerduty/data_source_pagerduty_automation_actions_action.go index ed16962cc..fe12c65a6 100644 --- a/pagerduty/data_source_pagerduty_automation_actions_action.go +++ b/pagerduty/data_source_pagerduty_automation_actions_action.go @@ -94,6 +94,11 @@ func dataSourcePagerDutyAutomationActionsAction() *schema.Resource { Computed: true, Optional: true, }, + "only_invocable_on_unresolved_incidents": { + Type: schema.TypeString, + Computed: true, + Optional: true, + }, }, } } diff --git a/pagerduty/data_source_pagerduty_automation_actions_action_test.go b/pagerduty/data_source_pagerduty_automation_actions_action_test.go index fa10025b6..59110783d 100644 --- a/pagerduty/data_source_pagerduty_automation_actions_action_test.go +++ b/pagerduty/data_source_pagerduty_automation_actions_action_test.go @@ -75,6 +75,7 @@ resource "pagerduty_automation_actions_action" "test" { process_automation_job_arguments = "-arg 1" process_automation_node_filter = "tags: production" } + only_invocable_on_unresolved_incidents: true } data "pagerduty_automation_actions_action" "foo" { diff --git a/pagerduty/resource_pagerduty_automation_actions_action.go b/pagerduty/resource_pagerduty_automation_actions_action.go index 907afdc7a..b26e9fc52 100644 --- a/pagerduty/resource_pagerduty_automation_actions_action.go +++ b/pagerduty/resource_pagerduty_automation_actions_action.go @@ -99,6 +99,11 @@ func resourcePagerDutyAutomationActionsAction() *schema.Resource { Computed: true, Optional: true, }, + "only_invocable_on_unresolved_incidents": { + Type: schema.TypeBool, + Computed: true, + Optional: true, + }, }, } } @@ -153,6 +158,11 @@ func buildAutomationActionsActionStruct(d *schema.ResourceData) (*pagerduty.Auto automationActionsAction.ModifyTime = &val } + if attr, ok := d.GetOk("only_invocable_on_unresolved_incidents"); ok { + val := attr.(bool) + automationActionsAction.OnlyInvocableOnUnresolvedIncidents = &val + } + return &automationActionsAction, nil } @@ -298,6 +308,10 @@ func resourcePagerDutyAutomationActionsActionRead(d *schema.ResourceData, meta i if automationActionsAction.ActionClassification != nil { d.Set("action_classification", &automationActionsAction.ActionClassification) } + + if automationActionsAction.OnlyInvocableOnUnresolvedIncidents != nil { + d.Set("only_invocable_on_unresolved_incidents", &automationActionsAction.OnlyInvocableOnUnresolvedIncidents) + } } return nil }) diff --git a/pagerduty/resource_pagerduty_automation_actions_action_test.go b/pagerduty/resource_pagerduty_automation_actions_action_test.go index e47e21ed6..b7f6266d7 100644 --- a/pagerduty/resource_pagerduty_automation_actions_action_test.go +++ b/pagerduty/resource_pagerduty_automation_actions_action_test.go @@ -57,6 +57,7 @@ func TestAccPagerDutyAutomationActionsActionTypeProcessAutomation_Basic(t *testi resource.TestCheckResourceAttrSet("pagerduty_automation_actions_action.foo", "modify_time"), resource.TestCheckResourceAttrSet("pagerduty_automation_actions_action.foo", "runner_id"), resource.TestCheckResourceAttr("pagerduty_automation_actions_action.foo", "runner_type", "runbook"), + resource.TestCheckResourceAttr("pagerduty_automation_actions_action.foo", "only_invocable_on_unresolved_incidents", "true"), ), }, { @@ -84,6 +85,7 @@ func TestAccPagerDutyAutomationActionsActionTypeProcessAutomation_Basic(t *testi resource.TestCheckResourceAttrSet("pagerduty_automation_actions_action.foo", "modify_time"), resource.TestCheckResourceAttrSet("pagerduty_automation_actions_action.foo", "runner_id"), resource.TestCheckResourceAttr("pagerduty_automation_actions_action.foo", "runner_type", "runbook"), + resource.TestCheckResourceAttr("pagerduty_automation_actions_action.foo", "only_invocable_on_unresolved_incidents", "true"), ), }, }, @@ -127,6 +129,7 @@ func TestAccPagerDutyAutomationActionsActionTypeScript_Basic(t *testing.T) { resource.TestCheckResourceAttrSet("pagerduty_automation_actions_action.foo", "modify_time"), resource.TestCheckNoResourceAttr("pagerduty_automation_actions_action.foo", "runner_type"), resource.TestCheckNoResourceAttr("pagerduty_automation_actions_action.foo", "runner_id"), + resource.TestCheckNoResourceAttr("pagerduty_automation_actions_action.foo", "only_invocable_on_unresolved_incidents"), ), }, { @@ -152,6 +155,7 @@ func TestAccPagerDutyAutomationActionsActionTypeScript_Basic(t *testing.T) { resource.TestCheckResourceAttrSet("pagerduty_automation_actions_action.foo", "modify_time"), resource.TestCheckNoResourceAttr("pagerduty_automation_actions_action.foo", "runner_type"), resource.TestCheckNoResourceAttr("pagerduty_automation_actions_action.foo", "runner_id"), + resource.TestCheckNoResourceAttr("pagerduty_automation_actions_action.foo", "only_invocable_on_unresolved_incidents"), ), }, }, @@ -214,7 +218,8 @@ resource "pagerduty_automation_actions_action" "foo" { process_automation_job_id = "pa_job_id_123" process_automation_job_arguments = "-arg 1" process_automation_node_filter = "tags: production" - } + }, + only_invocable_on_unresolved_incidents = "true" } `, actionName, actionName) } diff --git a/vendor/github.com/heimweh/go-pagerduty/pagerduty/automation_actions_action.go b/vendor/github.com/heimweh/go-pagerduty/pagerduty/automation_actions_action.go index a2eb1ecc5..40ba2f081 100644 --- a/vendor/github.com/heimweh/go-pagerduty/pagerduty/automation_actions_action.go +++ b/vendor/github.com/heimweh/go-pagerduty/pagerduty/automation_actions_action.go @@ -7,20 +7,21 @@ 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"` + 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:"modify_time,omitempty"` } type AutomationActionsActionDataReference struct { diff --git a/website/docs/d/automation_actions_action.html.markdown b/website/docs/d/automation_actions_action.html.markdown index 94420e951..9b50201c8 100644 --- a/website/docs/d/automation_actions_action.html.markdown +++ b/website/docs/d/automation_actions_action.html.markdown @@ -31,14 +31,15 @@ The following attributes are exported: * `id` - The ID of the action. * `name` - The name of the action. * `type` - The type of object. The value returned will be `action`. -* `action_type` - The type of the action. The only allowed values are `process_automation` and `script`. +* `action_type` - The type of the action. The only allowed values are `process_automation` and `script`. * `creation_time` - The time action was created. Represented as an ISO 8601 timestamp. * `action_data_reference` - Action Data block. Action Data is documented below. * `description` - (Optional) The description of the action. -* `runner_id` - (Optional) The Process Automation Actions runner to associate the action with. +* `runner_id` - (Optional) The Process Automation Actions runner to associate the action with. * `runner_type` - (Optional) The type of the runner associated with the action. -* `action_classification` - (Optional) The category of the action. The only allowed values are `diagnostic` and `remediation`. +* `action_classification` - (Optional) The category of the action. The only allowed values are `diagnostic` and `remediation`. * `modify_time` - (Optional) The last time action has been modified. Represented as an ISO 8601 timestamp. +* `only_invocable_on_unresolved_incidents` - (Optional) Whether or not the action can be invoked on unresolved incidents. Action Data (`action_data_reference`) supports the following: diff --git a/website/docs/r/automation_actions_action.html.markdown b/website/docs/r/automation_actions_action.html.markdown index 7c5155473..30abc0452 100644 --- a/website/docs/r/automation_actions_action.html.markdown +++ b/website/docs/r/automation_actions_action.html.markdown @@ -43,7 +43,7 @@ The following arguments are supported: * `action_type` - (Required) The type of the action. The only allowed values are `process_automation` and `script`. Cannot be changed once set. * `action_data_reference` - (Required) Action Data block. Action Data is documented below. * `runner_id` - (Optional) The Process Automation Actions runner to associate the action with. Cannot be changed for the `process_automation` action type once set. - * `action_classification` - (Optional) The category of the action. The only allowed values are `diagnostic` and `remediation`. + * `action_classification` - (Optional) The category of the action. The only allowed values are `diagnostic` and `remediation`. Action Data (`action_data_reference`) supports the following: @@ -52,6 +52,7 @@ Action Data (`action_data_reference`) supports the following: * `process_automation_node_filter` - (Optional) The expression that filters on which nodes a Process Automation Job executes [Learn more](https://docs.rundeck.com/docs/manual/05-nodes.html#node-filtering). * `script` - (Required for `script` action_type) Body of the script to be executed on the Runner. Max length is 16777215 characters. * `invocation_command` - (Optional) The command to execute the script with. + * `only_invocable_on_unresolved_incidents` - (Optional) Whether or not the action can be invoked on unresolved incidents. ## Attributes Reference