From 64190ce9f9525a449bad301e1a71fa39f4065599 Mon Sep 17 00:00:00 2001 From: Marko Simon Date: Fri, 26 Jul 2024 17:55:53 +0200 Subject: [PATCH 01/14] add intelligent grouping related fields --- alert_source.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/alert_source.go b/alert_source.go index 5363e02..a694145 100644 --- a/alert_source.go +++ b/alert_source.go @@ -44,6 +44,7 @@ type AlertSource struct { LinkTemplates []LinkTemplate `json:"linkTemplates,omitempty"` PriorityTemplate *PriorityTemplate `json:"priorityTemplate,omitempty"` AlertGroupingWindow string `json:"alertGroupingWindow,omitempty"` // e.g. PT4H + ScoreThreshold string `json:"scoreThreshold,omitempty"` } // EmailPredicate definition @@ -165,6 +166,7 @@ var AlertSourceAlertCreations = struct { OneOpenAlertAllowed string OpenResolveOnExtraction string OneAlertGroupedPerWindow string + IntelligentGrouping string }{ // @deprecated OneIncidentPerEmail: "ONE_INCIDENT_PER_EMAIL", @@ -178,6 +180,7 @@ var AlertSourceAlertCreations = struct { OneOpenAlertAllowed: "ONE_OPEN_ALERT_ALLOWED", OpenResolveOnExtraction: "OPEN_RESOLVE_ON_EXTRACTION", OneAlertGroupedPerWindow: "ONE_ALERT_GROUPED_PER_WINDOW", + IntelligentGrouping: "INTELLIGENT_GROUPING", } // AlertSourceAlertCreationsAll defines alert source alert creations list @@ -194,6 +197,7 @@ var AlertSourceAlertCreationsAll = []string{ AlertSourceAlertCreations.OneOpenAlertAllowed, AlertSourceAlertCreations.OpenResolveOnExtraction, AlertSourceAlertCreations.OneAlertGroupedPerWindow, + AlertSourceAlertCreations.IntelligentGrouping, } // AlertSourceAlertGroupingWindows defines alert source alert grouping windows From d374c1128eee8efb12b6ebc790352b626833a17c Mon Sep 17 00:00:00 2001 From: Marko Simon Date: Fri, 26 Jul 2024 18:28:45 +0200 Subject: [PATCH 02/14] add simple event filter --- alert_source.go | 1 + 1 file changed, 1 insertion(+) diff --git a/alert_source.go b/alert_source.go index a694145..859fc12 100644 --- a/alert_source.go +++ b/alert_source.go @@ -45,6 +45,7 @@ type AlertSource struct { PriorityTemplate *PriorityTemplate `json:"priorityTemplate,omitempty"` AlertGroupingWindow string `json:"alertGroupingWindow,omitempty"` // e.g. PT4H ScoreThreshold string `json:"scoreThreshold,omitempty"` + EventFilter string `json:"eventFilter,omitempty"` } // EmailPredicate definition From a2aaf8149116774575439178b76a744f7318a9e0 Mon Sep 17 00:00:00 2001 From: Marko Simon Date: Fri, 26 Jul 2024 18:36:11 +0200 Subject: [PATCH 03/14] add slack webhook alert action --- alert_action.go | 5 +++++ connector.go | 3 +++ 2 files changed, 8 insertions(+) diff --git a/alert_action.go b/alert_action.go index 5ec8dd3..bca3a9b 100644 --- a/alert_action.go +++ b/alert_action.go @@ -122,6 +122,11 @@ type AlertActionParamsMicrosoftTeamsWebhook struct { URL string `json:"url,omitempty"` } +// AlertActionParamsSlackWebhook definition +type AlertActionParamsSlackWebhook struct { + URL string `json:"url,omitempty"` +} + // AlertActionParamsServiceNow definition type AlertActionParamsServiceNow struct { CallerID string `json:"callerId,omitempty"` // user email diff --git a/connector.go b/connector.go index 7523953..74d9113 100644 --- a/connector.go +++ b/connector.go @@ -155,6 +155,7 @@ var ConnectorTypes = struct { MicrosoftTeamsWebhook string ServiceNow string Slack string + SlackWebhook string Telegram string Topdesk string Webhook string @@ -175,6 +176,7 @@ var ConnectorTypes = struct { MicrosoftTeamsWebhook: "microsoft_teams_webhook", ServiceNow: "servicenow", Slack: "slack", + SlackWebhook: "slack_webhook", Telegram: "telegram", Topdesk: "topdesk", Webhook: "webhook", @@ -198,6 +200,7 @@ var ConnectorTypesAll = []string{ ConnectorTypes.MicrosoftTeamsWebhook, ConnectorTypes.ServiceNow, ConnectorTypes.Slack, + ConnectorTypes.SlackWebhook, ConnectorTypes.Telegram, ConnectorTypes.Topdesk, ConnectorTypes.Webhook, From 6fb17bd14aae34abb16b1998ef767da2868540dd Mon Sep 17 00:00:00 2001 From: Marko Simon Date: Fri, 26 Jul 2024 19:03:59 +0200 Subject: [PATCH 04/14] add alert not resolved trigger type add specific delay fields deprecate former delaySec field --- alert_action.go | 63 +++++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/alert_action.go b/alert_action.go index bca3a9b..81ea5d9 100644 --- a/alert_action.go +++ b/alert_action.go @@ -10,38 +10,42 @@ import ( // AlertAction definition https://api.ilert.com/api-docs/#tag/Alert-Actions type AlertAction struct { - ID string `json:"id,omitempty"` - Name string `json:"name"` - AlertSourceIDs []int64 `json:"alertSourceIds,omitempty"` // @deprecated - AlertSources *[]AlertSource `json:"alertSources,omitempty"` - ConnectorID string `json:"connectorId,omitempty"` - ConnectorType string `json:"connectorType"` - TriggerMode string `json:"triggerMode"` - DelaySec int `json:"delaySec,omitempty"` // between 0 and 7200, only allowed with triggerType 'alert-escalation-ended' - TriggerTypes []string `json:"triggerTypes,omitempty"` - CreatedAt string `json:"createdAt,omitempty"` // date time string in ISO 8601 - UpdatedAt string `json:"updatedAt,omitempty"` // date time string in ISO 8601 - Params interface{} `json:"params"` - AlertFilter *AlertFilter `json:"alertFilter,omitempty"` - Teams *[]TeamShort `json:"teams,omitempty"` + ID string `json:"id,omitempty"` + Name string `json:"name"` + AlertSourceIDs []int64 `json:"alertSourceIds,omitempty"` // @deprecated + AlertSources *[]AlertSource `json:"alertSources,omitempty"` + ConnectorID string `json:"connectorId,omitempty"` + ConnectorType string `json:"connectorType"` + TriggerMode string `json:"triggerMode"` + DelaySec int `json:"delaySec,omitempty"` // @deprecated + EscalationEndedDelaySec int `json:"escalationEndedDelaySec,omitempty"` // between 0 and 7200, used with triggerType 'AlertEscalationEnded' + NotResolvedDelaySec int `json:"notResolvedDelaySec,omitempty"` // between 0 and 7200, used with triggerType 'AlertNotResolved' + TriggerTypes []string `json:"triggerTypes,omitempty"` + CreatedAt string `json:"createdAt,omitempty"` // date time string in ISO 8601 + UpdatedAt string `json:"updatedAt,omitempty"` // date time string in ISO 8601 + Params interface{} `json:"params"` + AlertFilter *AlertFilter `json:"alertFilter,omitempty"` + Teams *[]TeamShort `json:"teams,omitempty"` } // AlertActionOutput definition https://api.ilert.com/api-docs/#tag/Alert-Actions type AlertActionOutput struct { - ID string `json:"id"` - Name string `json:"name"` - AlertSourceIDs []int64 `json:"alertSourceIds,omitempty"` // @deprecated - AlertSources *[]AlertSource `json:"alertSources,omitempty"` - ConnectorID string `json:"connectorId"` - ConnectorType string `json:"connectorType"` - TriggerMode string `json:"triggerMode"` - DelaySec int `json:"delaySec,omitempty"` // between 0 and 7200, only allowed with triggerType 'alert-escalation-ended' - TriggerTypes []string `json:"triggerTypes,omitempty"` - CreatedAt string `json:"createdAt"` // date time string in ISO 8601 - UpdatedAt string `json:"updatedAt"` // date time string in ISO 8601 - Params *AlertActionOutputParams `json:"params"` - AlertFilter *AlertFilter `json:"alertFilter,omitempty"` - Teams *[]TeamShort `json:"teams,omitempty"` + ID string `json:"id"` + Name string `json:"name"` + AlertSourceIDs []int64 `json:"alertSourceIds,omitempty"` // @deprecated + AlertSources *[]AlertSource `json:"alertSources,omitempty"` + ConnectorID string `json:"connectorId"` + ConnectorType string `json:"connectorType"` + TriggerMode string `json:"triggerMode"` + DelaySec int `json:"delaySec,omitempty"` // @deprecated + EscalationEndedDelaySec int `json:"escalationEndedDelaySec,omitempty"` // between 0 and 7200, used with triggerType 'AlertEscalationEnded' + NotResolvedDelaySec int `json:"notResolvedDelaySec,omitempty"` // between 0 and 7200, used with triggerType 'AlertNotResolved' + TriggerTypes []string `json:"triggerTypes,omitempty"` + CreatedAt string `json:"createdAt"` // date time string in ISO 8601 + UpdatedAt string `json:"updatedAt"` // date time string in ISO 8601 + Params *AlertActionOutputParams `json:"params"` + AlertFilter *AlertFilter `json:"alertFilter,omitempty"` + Teams *[]TeamShort `json:"teams,omitempty"` } // AlertActionOutputParams definition @@ -262,6 +266,7 @@ var AlertActionTriggerTypes = struct { AlertResponderRemoved string AlertChannelAttached string AlertChannelDetached string + AlertNotResolved string }{ AlertCreated: "alert-created", AlertAssigned: "alert-assigned", @@ -276,6 +281,7 @@ var AlertActionTriggerTypes = struct { AlertResponderRemoved: "alert-responder-removed", AlertChannelAttached: "alert-channel-attached", AlertChannelDetached: "alert-channel-detached", + AlertNotResolved: "v-alert-not-resolved", } // AlertActionTriggerTypesAll defines all alertAction trigger types @@ -293,6 +299,7 @@ var AlertActionTriggerTypesAll = []string{ AlertActionTriggerTypes.AlertResponderRemoved, AlertActionTriggerTypes.AlertChannelAttached, AlertActionTriggerTypes.AlertChannelDetached, + AlertActionTriggerTypes.AlertNotResolved, } // AlertFilterOperator defines alertFilter operator From adb429a4bdaa8ab4a0694c2e6c78ee19065bde97 Mon Sep 17 00:00:00 2001 From: Marko Simon Date: Mon, 29 Jul 2024 16:10:42 +0200 Subject: [PATCH 05/14] add email login and announcement to status page resource --- status_page.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/status_page.go b/status_page.go index ed2e4dc..6551898 100644 --- a/status_page.go +++ b/status_page.go @@ -36,6 +36,10 @@ type StatusPage struct { Structure *StatusPageStructure `json:"structure,omitempty"` ThemeMode string `json:"themeMode,omitempty"` // please use field `Appearance` instead Appearance string `json:"appearance,omitempty"` + EmailWhitelist []string `json:"emailWhitelist,omitempty"` + Announcement string `json:"announcement,omitempty"` + AnnouncementOnPage bool `json:"announcementOnPage,omitempty"` + AnnouncementInWidget bool `json:"announcementInWidget,omitempty"` } // StatusPageStructure defines status page structure From 4a35f7d17ce2188a6f27347a6bac4780527a6dd4 Mon Sep 17 00:00:00 2001 From: Marko Simon Date: Mon, 29 Jul 2024 16:27:26 +0200 Subject: [PATCH 06/14] update changelog --- CHANGELOG.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e44fd45..23d081c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # Changelog +## 29.07.2024, Version 3.9.0 + +- add new api resources/fields pt.1 [#42](https://github.com/iLert/ilert-go/pull/41) + - alert action + - deprecate `delaySec` in favor of more specific `escalationEndedDelaySec` and `notResolvedDelaySec` + - new trigger type `AlertNotResolved` + - new alert action type `SlackWebhook` + - alert source + - new alert grouping type `intelligentGrouping` + - add field `scoreThreshold` + - add event filter + - status page + - add email login via `emailWhitelist` + - add `announcement` fields + +## 09.05.2024, Version 3.8.1 + +- add region to user [#41](https://github.com/iLert/ilert-go/pull/41) + ## 09.05.2024, Version 3.8.1 - add region to user [#41](https://github.com/iLert/ilert-go/pull/41) From b242bc9120c8b5339632737e33e257f3301269c1 Mon Sep 17 00:00:00 2001 From: Marko Simon Date: Mon, 29 Jul 2024 16:27:39 +0200 Subject: [PATCH 07/14] bump version --- version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.go b/version.go index 55b30c9..478929b 100644 --- a/version.go +++ b/version.go @@ -1,4 +1,4 @@ package ilert // Version package version -const Version = "v3.8.3" +const Version = "v3.9.0" From 87c749679bc7690a2100e4f823af76317b013490 Mon Sep 17 00:00:00 2001 From: Marko Simon Date: Mon, 29 Jul 2024 16:28:32 +0200 Subject: [PATCH 08/14] fix changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23d081c..dc97a53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 29.07.2024, Version 3.9.0 -- add new api resources/fields pt.1 [#42](https://github.com/iLert/ilert-go/pull/41) +- add new api resources/fields pt.1 [#42](https://github.com/iLert/ilert-go/pull/42) - alert action - deprecate `delaySec` in favor of more specific `escalationEndedDelaySec` and `notResolvedDelaySec` - new trigger type `AlertNotResolved` From 69436aef392a5209dcc1327d7d5672fce9550642 Mon Sep 17 00:00:00 2001 From: Marko Simon Date: Mon, 29 Jul 2024 16:28:56 +0200 Subject: [PATCH 09/14] fix changelog --- CHANGELOG.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc97a53..cecc51f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,10 +19,6 @@ - add region to user [#41](https://github.com/iLert/ilert-go/pull/41) -## 09.05.2024, Version 3.8.1 - -- add region to user [#41](https://github.com/iLert/ilert-go/pull/41) - ## 06.05.2024, Version 3.8.0 - add send-no-invitation option to user create api [#40](https://github.com/iLert/ilert-go/pull/40) From f7055bf10c3ee04077d04699615fc33f7b4846d4 Mon Sep 17 00:00:00 2001 From: Marko Simon Date: Thu, 22 Aug 2024 12:34:54 +0200 Subject: [PATCH 10/14] add metrics to status page --- status_page.go | 1 + 1 file changed, 1 insertion(+) diff --git a/status_page.go b/status_page.go index 6551898..448c8db 100644 --- a/status_page.go +++ b/status_page.go @@ -40,6 +40,7 @@ type StatusPage struct { Announcement string `json:"announcement,omitempty"` AnnouncementOnPage bool `json:"announcementOnPage,omitempty"` AnnouncementInWidget bool `json:"announcementInWidget,omitempty"` + Metrics []Metric `json:"metrics,omitempty"` } // StatusPageStructure defines status page structure From 70df3a5a18439cf2d3949b70285de8ab0706b9ca Mon Sep 17 00:00:00 2001 From: Marko Simon Date: Thu, 22 Aug 2024 13:26:39 +0200 Subject: [PATCH 11/14] update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cecc51f..0b5d31c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## 29.07.2024, Version 3.9.0 +## 22.08.2024, Version 3.9.0 - add new api resources/fields pt.1 [#42](https://github.com/iLert/ilert-go/pull/42) - alert action @@ -14,6 +14,7 @@ - status page - add email login via `emailWhitelist` - add `announcement` fields + - add `metrics` ## 09.05.2024, Version 3.8.1 From 3fb5ff46da0a81b3fdc9ea7ecd4cd777d483343d Mon Sep 17 00:00:00 2001 From: Marko Simon Date: Thu, 22 Aug 2024 13:48:08 +0200 Subject: [PATCH 12/14] fix type for score threshold --- alert_source.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alert_source.go b/alert_source.go index 859fc12..d72c325 100644 --- a/alert_source.go +++ b/alert_source.go @@ -44,7 +44,7 @@ type AlertSource struct { LinkTemplates []LinkTemplate `json:"linkTemplates,omitempty"` PriorityTemplate *PriorityTemplate `json:"priorityTemplate,omitempty"` AlertGroupingWindow string `json:"alertGroupingWindow,omitempty"` // e.g. PT4H - ScoreThreshold string `json:"scoreThreshold,omitempty"` + ScoreThreshold int64 `json:"scoreThreshold,omitempty"` EventFilter string `json:"eventFilter,omitempty"` } From e34dc31694e2b4ecf92c79f7d5b7aae0c8fa4e4c Mon Sep 17 00:00:00 2001 From: Marko Simon Date: Thu, 22 Aug 2024 14:31:12 +0200 Subject: [PATCH 13/14] add includes for alert source api calls --- alert_source.go | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/alert_source.go b/alert_source.go index d72c325..8ee4854 100644 --- a/alert_source.go +++ b/alert_source.go @@ -44,7 +44,7 @@ type AlertSource struct { LinkTemplates []LinkTemplate `json:"linkTemplates,omitempty"` PriorityTemplate *PriorityTemplate `json:"priorityTemplate,omitempty"` AlertGroupingWindow string `json:"alertGroupingWindow,omitempty"` // e.g. PT4H - ScoreThreshold int64 `json:"scoreThreshold,omitempty"` + ScoreThreshold float64 `json:"scoreThreshold,omitempty"` EventFilter string `json:"eventFilter,omitempty"` } @@ -469,6 +469,10 @@ var AlertSourceIntegrationTypesAll = []string{ type CreateAlertSourceInput struct { _ struct{} AlertSource *AlertSource + + // describes optional properties that should be included in the response + // possible values: "summaryTemplate", "detailsTemplate", "routingTemplate", "textTemplate", "linkTemplates", "priorityTemplate", "eventFilter" + Include []*string } // CreateAlertSourceOutput represents the output of a CreateAlertSource operation. @@ -506,7 +510,13 @@ func (c *Client) CreateAlertSource(input *CreateAlertSourceInput) (*CreateAlertS v.RemoveLegacyFields() } - resp, err := c.httpClient.R().SetBody(input.AlertSource).Post(apiRoutes.alertSources) + q := url.Values{} + + for _, include := range input.Include { + q.Add("include", *include) + } + + resp, err := c.httpClient.R().SetBody(input.AlertSource).Post(fmt.Sprintf("%s?%s", apiRoutes.alertSources, q.Encode())) if err != nil { return nil, err } @@ -529,7 +539,7 @@ type GetAlertSourceInput struct { AlertSourceID *int64 // describes optional properties that should be included in the response - // possible values: "summaryTemplate", "detailsTemplate", "routingTemplate", "textTemplate", "linkTemplates", "priorityTemplate" + // possible values: "summaryTemplate", "detailsTemplate", "routingTemplate", "textTemplate", "linkTemplates", "priorityTemplate", "eventFilter" Include []*string } @@ -659,6 +669,10 @@ type UpdateAlertSourceInput struct { _ struct{} AlertSourceID *int64 AlertSource *AlertSource + + // describes optional properties that should be included in the response + // possible values: "summaryTemplate", "detailsTemplate", "routingTemplate", "textTemplate", "linkTemplates", "priorityTemplate", "eventFilter" + Include []*string } // UpdateAlertSourceOutput represents the output of a UpdateAlertSource operation. @@ -699,7 +713,13 @@ func (c *Client) UpdateAlertSource(input *UpdateAlertSourceInput) (*UpdateAlertS v.RemoveLegacyFields() } - resp, err := c.httpClient.R().SetBody(input.AlertSource).Put(fmt.Sprintf("%s/%d", apiRoutes.alertSources, *input.AlertSourceID)) + q := url.Values{} + + for _, include := range input.Include { + q.Add("include", *include) + } + + resp, err := c.httpClient.R().SetBody(input.AlertSource).Put(fmt.Sprintf("%s/%d?%s", apiRoutes.alertSources, *input.AlertSourceID, q.Encode())) if err != nil { return nil, err } From 27a402b08b10853b4034d11505916e3d085bccfa Mon Sep 17 00:00:00 2001 From: Marko Simon Date: Thu, 22 Aug 2024 14:40:23 +0200 Subject: [PATCH 14/14] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b5d31c..aa2a5cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - new alert grouping type `intelligentGrouping` - add field `scoreThreshold` - add event filter + - add includes for POST and PUT API calls - status page - add email login via `emailWhitelist` - add `announcement` fields