Skip to content
Merged
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
5 changes: 5 additions & 0 deletions client/models/saved_searches.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ type SavedSearchObject struct {
ActionSlackParamFields string `json:"action.slack.param.fields,omitempty" url:"action.slack.param.fields"`
ActionSlackParamMessage string `json:"action.slack.param.message,omitempty" url:"action.slack.param.message"`
ActionSlackParamWebhookUrlOverride string `json:"action.slack.param.webhook_url_override,omitempty" url:"action.slack.param.webhook_url_override"`
ActionSlackAppAlertIntegrationParamAutoJoinChannel string `json:"action.slack_app_alert_integration.param.auto_join_channel,omitempty" url:"action.slack_app_alert_integration.param.auto_join_channel"`
ActionSlackAppAlertIntegrationParamBotUsername string `json:"action.slack_app_alert_integration.param.bot_username,omitempty" url:"action.slack_app_alert_integration.param.bot_username"`
ActionSlackAppAlertIntegrationParamChannel string `json:"action.slack_app_alert_integration.param.channel,omitempty" url:"action.slack_app_alert_integration.param.channel"`
ActionSlackAppAlertIntegrationParamEmoji string `json:"action.slack_app_alert_integration.param.emoji,omitempty" url:"action.slack_app_alert_integration.param.emoji"`
ActionSlackAppAlertIntegrationParamMessage string `json:"action.slack_app_alert_integration.param.message,omitempty" url:"action.slack_app_alert_integration.param.message"`
ActionJiraServiceDeskParamAccount string `json:"action.jira_service_desk.param.account,omitempty" url:"action.jira_service_desk.param.account"`
ActionJiraServiceDeskParamJiraProject string `json:"action.jira_service_desk.param.jira_project,omitempty" url:"action.jira_service_desk.param.jira_project"`
ActionJiraServiceDeskParamJiraIssueType string `json:"action.jira_service_desk.param.jira_issue_type,omitempty" url:"action.jira_service_desk.param.jira_issue_type"`
Expand Down
6 changes: 6 additions & 0 deletions docs/resources/saved_searches.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ This resource block supports the following arguments:
- `action_slack_param_attachment` - (Optional) Include a message attachment. Valid values are message, none, or alert_link
- `action_slack_param_message` - (Optional) Enter the chat message to send to the Slack channel. The message can include tokens that insert text based on the results of the search.
- `action_slack_param_webhook_url_override` - (Optional) You can override the Slack webhook URL here if you need to send the alert message to a different Slack team
- `action_slack_app_alert_integration_param_auto_join_channel` - (Optional) Automatically join the channel if the bot is not already a member (Should be 1 (Enabled) or 0 (Disabled))
- `action_slack_app_alert_integration_param_bot_username` - (Optional) The bot username that will post the message
- `action_slack_app_alert_integration_param_channel` - (Optional) Slack channel to send the message to (Should start with # or @)
- `action_slack_app_alert_integration_param_emoji` - (Optional) Emoji icon to use as the bot's avatar (Should start and end with :)
- `action_slack_app_alert_integration_param_message` - (Optional) Enter the chat message to send to the Slack channel. The message can include tokens that insert text based on the results of the
- `action_slack_app_alert_integration_param_fields`
- `action_jira_service_desk_param_account` - (Optional) Jira Service Desk account name
- `action_jira_service_desk_param_jira_project` - (Optional) Jira Project name
- `action_jira_service_desk_param_jira_issue_type` - (Optional) Jira issue type name
Expand Down
45 changes: 45 additions & 0 deletions splunk/resource_splunk_saved_searches.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,31 @@ func savedSearches() *schema.Resource {
Optional: true,
Description: "You can override the Slack webhook URL here if you need to send the alert message to a different Slack team.",
},
"action_slack_app_alert_integration_param_auto_join_channel": {
Type: schema.TypeString,
Optional: true,
Description: "Valid values: (1 | 0) Specify whether the Slack App bot should automatically join the channel if it is not already a member. Defaults to false.",
},
"action_slack_app_alert_integration_param_bot_username": {
Type: schema.TypeString,
Optional: true,
Description: "Specify a custom bot username for the Slack App alert.",
},
"action_slack_app_alert_integration_param_channel": {
Type: schema.TypeString,
Optional: true,
Description: "Slack channel to send the message to (Should not start with #)",
},
"action_slack_app_alert_integration_param_emoji": {
Type: schema.TypeString,
Optional: true,
Description: "Specify a custom bot emoji for the Slack App alert.",
},
"action_slack_app_alert_integration_param_message": {
Type: schema.TypeString,
Optional: true,
Description: "Enter the chat message to send to the Slack channel. The message can include tokens that insert text based on the results of the search.",
},
"action_jira_service_desk_param_account": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -1608,6 +1633,21 @@ func savedSearchesRead(d *schema.ResourceData, meta interface{}) error {
if err = d.Set("action_slack_param_webhook_url_override", entry.Content.ActionSlackParamWebhookUrlOverride); err != nil {
return err
}
if err = d.Set("action_slack_app_alert_integration_param_auto_join_channel", entry.Content.ActionSlackAppAlertIntegrationParamAutoJoinChannel); err != nil {
return err
}
if err = d.Set("action_slack_app_alert_integration_param_bot_username", entry.Content.ActionSlackAppAlertIntegrationParamBotUsername); err != nil {
return err
}
if err = d.Set("action_slack_app_alert_integration_param_channel", entry.Content.ActionSlackAppAlertIntegrationParamChannel); err != nil {
return err
}
if err = d.Set("action_slack_app_alert_integration_param_emoji", entry.Content.ActionSlackAppAlertIntegrationParamEmoji); err != nil {
return err
}
if err = d.Set("action_slack_app_alert_integration_param_message", entry.Content.ActionSlackAppAlertIntegrationParamMessage); err != nil {
return err
}
if err = d.Set("action_jira_service_desk_param_account", entry.Content.ActionJiraServiceDeskParamAccount); err != nil {
return err
}
Expand Down Expand Up @@ -2013,6 +2053,11 @@ func getSavedSearchesConfig(d *schema.ResourceData) (savedSearchesObj *models.Sa
ActionSlackParamFields: d.Get("action_slack_param_fields").(string),
ActionSlackParamMessage: d.Get("action_slack_param_message").(string),
ActionSlackParamWebhookUrlOverride: d.Get("action_slack_param_webhook_url_override").(string),
ActionSlackAppAlertIntegrationParamAutoJoinChannel: d.Get("action_slack_app_alert_integration_param_auto_join_channel").(string),
ActionSlackAppAlertIntegrationParamBotUsername: d.Get("action_slack_app_alert_integration_param_bot_username").(string),
ActionSlackAppAlertIntegrationParamChannel: d.Get("action_slack_app_alert_integration_param_channel").(string),
ActionSlackAppAlertIntegrationParamEmoji: d.Get("action_slack_app_alert_integration_param_emoji").(string),
ActionSlackAppAlertIntegrationParamMessage: d.Get("action_slack_app_alert_integration_param_message").(string),
ActionJiraServiceDeskParamAccount: d.Get("action_jira_service_desk_param_account").(string),
ActionJiraServiceDeskParamJiraProject: d.Get("action_jira_service_desk_param_jira_project").(string),
ActionJiraServiceDeskParamJiraIssueType: d.Get("action_jira_service_desk_param_jira_issue_type").(string),
Expand Down
46 changes: 46 additions & 0 deletions splunk/resource_splunk_saved_searches_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,29 @@ resource "splunk_saved_searches" "test" {
realtime_schedule = true
search = "index=main level=error"
}

`
const newSavedSearchesSlackAppAlertIntegration = `
resource "splunk_saved_searches" "test" {
name = "Test Slack App Alert"
actions = "slack_app_alert"
action_slack_app_alert_integration_param_auto_join_channel = "1"
action_slack_app_alert_integration_param_bot_username = "SplunkBot"
action_slack_app_alert_integration_param_channel = "channel"
action_slack_app_alert_integration_param_emoji = ":splunk:"
action_slack_app_alert_integration_param_message = "error message"
alert_comparator = "greater than"
alert_digest_mode = true
alert_expires = "30d"
alert_threshold = "0"
alert_type = "number of events"
cron_schedule = "*/1 * * * *"
disabled = false
is_scheduled = true
is_visible = true
realtime_schedule = true
search = "index=main level=error"
}
`

const newSavedSearchesVictorops = `
Expand Down Expand Up @@ -540,6 +563,29 @@ func TestAccSplunkSavedSearches(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "search", "index=main level=error"),
),
},
{
Config: newSavedSearchesSlackAppAlertIntegration,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "name", "Test Slack App Alert"),
resource.TestCheckResourceAttr(resourceName, "actions", "slack_app_alert"),
resource.TestCheckResourceAttr(resourceName, "action_slack_app_alert_integration_param_auto_join_channel", "1"),
resource.TestCheckResourceAttr(resourceName, "action_slack_app_alert_integration_param_bot_username", "SplunkBot"),
resource.TestCheckResourceAttr(resourceName, "action_slack_app_alert_integration_param_channel", "channel"),
resource.TestCheckResourceAttr(resourceName, "action_slack_app_alert_integration_param_emoji", ":splunk:"),
resource.TestCheckResourceAttr(resourceName, "action_slack_app_alert_integration_param_message", "error message"),
resource.TestCheckResourceAttr(resourceName, "alert_comparator", "greater than"),
resource.TestCheckResourceAttr(resourceName, "alert_digest_mode", "true"),
resource.TestCheckResourceAttr(resourceName, "alert_expires", "30d"),
resource.TestCheckResourceAttr(resourceName, "alert_threshold", "0"),
resource.TestCheckResourceAttr(resourceName, "alert_type", "number of events"),
resource.TestCheckResourceAttr(resourceName, "cron_schedule", "*/1 * * * *"),
resource.TestCheckResourceAttr(resourceName, "disabled", "false"),
resource.TestCheckResourceAttr(resourceName, "is_scheduled", "true"),
resource.TestCheckResourceAttr(resourceName, "is_visible", "true"),
resource.TestCheckResourceAttr(resourceName, "realtime_schedule", "true"),
resource.TestCheckResourceAttr(resourceName, "search", "index=main level=error"),
),
},
{
Config: newSavedSearchesVictorops,
Check: resource.ComposeTestCheckFunc(
Expand Down
Loading