Skip to content

Commit

Permalink
Merge pull request #29 from iLert/feature/alert-actions-v2
Browse files Browse the repository at this point in the history
Feature/alert actions v2
  • Loading branch information
STLVRTX authored Feb 1, 2024
2 parents eb4fc85 + ffbba3f commit 85f07b7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 20 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

# 01.02.2024, Version 3.6.0

- apply alert actions v2 changes in [#29](https://github.com/iLert/ilert-go/pull/29)
- add alertSources and teams fields, deprecate alertSourceIds

# 12.01.2024, Version 3.5.0

- add Telegram as alert action type in [#35](https://github.com/iLert/ilert-go/pull/35)
Expand Down
30 changes: 17 additions & 13 deletions alert_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,28 @@ 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"`
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,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"`
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"`
}

// 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"`
AlertSourceIDs []int64 `json:"alertSourceIds,omitempty"` // @deprecated
AlertSources []AlertSource `json:"alertSources,omitempty"`
ConnectorID string `json:"connectorId"`
ConnectorType string `json:"connectorType"`
TriggerMode string `json:"triggerMode"`
Expand All @@ -38,6 +41,7 @@ type AlertActionOutput struct {
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
Expand Down
12 changes: 6 additions & 6 deletions examples/alert_action/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ func main() {

rcn, err := client.CreateAlertAction(&ilert.CreateAlertActionInput{
AlertAction: &ilert.AlertAction{
Name: "Test GitHub AlertAction",
ConnectorType: ilert.ConnectorTypes.Github,
ConnectorID: rcr.Connector.ID,
TriggerMode: ilert.AlertActionTriggerModes.Automatic,
TriggerTypes: ilert.AlertActionTriggerTypesAll,
AlertSourceIDs: []int64{ras.AlertSource.ID},
Name: "Test GitHub AlertAction",
ConnectorType: ilert.ConnectorTypes.Github,
ConnectorID: rcr.Connector.ID,
TriggerMode: ilert.AlertActionTriggerModes.Automatic,
TriggerTypes: ilert.AlertActionTriggerTypesAll,
AlertSources: []ilert.AlertSource{*ras.AlertSource},
Params: ilert.AlertActionParamsGithub{
Owner: "my-org",
Repository: "my-repo",
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ilert

// Version package version
const Version = "v3.5.0"
const Version = "v3.6.0"

0 comments on commit 85f07b7

Please sign in to comment.