Skip to content

Commit

Permalink
Merge pull request #18 from signalsciences/PutCustomAlert
Browse files Browse the repository at this point in the history
add put for custom alert. patch will not update SkipNotifications
  • Loading branch information
jhanrahan-sigsci authored Feb 23, 2021
2 parents 7a26569 + 8098047 commit a202798
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,19 +535,19 @@ func (sc *Client) UpdateSite(corpName, siteName string, body UpdateSiteBody) (Si
type CustomAlert struct {
ID string `json:"id,omitempty"` //Site-specific unique ID of the alert
SiteID string `json:"siteID,omitempty"`
TagName string `json:"tagName,omitempty"` //The name of the tag whose occurrences the alert is watching. Must match an existing tag
LongName string `json:"longName,omitempty"` //A human readable description of the alert. Must be between 3 and 25 characters.
Interval int `json:"interval"` //The number of minutes of past traffic to examine. Must be 1, 10 or 60.
Threshold int `json:"threshold"` //The number of occurrences of the tag in the interval needed to trigger the alert.
BlockDurationSeconds int `json:"blockDurationSeconds"` //The number of seconds this alert is active.
Enabled bool `json:"enabled"` //A flag to toggle this alert.
Action string `json:"action,omitempty"` //A flag that describes what happens when the alert is triggered. 'info' creates an incident in the dashboard. 'flagged' creates an incident and blocks traffic for 24 hours.
Type string `json:"type,omitempty"` //Type of alert (siteAlert, template, rateLimit, siteMetric)
SkipNotifications bool `json:"skipNotifications"` //A flag to disable external notifications - slack, webhooks, emails, etc.
TagName string `json:"tagName,omitempty"` //The name of the tag whose occurrences the alert is watching. Must match an existing tag
LongName string `json:"longName,omitempty"` //A human readable description of the alert. Must be between 3 and 25 characters.
Interval int `json:"interval"` //The number of minutes of past traffic to examine. Must be 1, 10 or 60.
Threshold int `json:"threshold"` //The number of occurrences of the tag in the interval needed to trigger the alert.
BlockDurationSeconds int `json:"blockDurationSeconds,omitempty"` //The number of seconds this alert is active. empty means default value
Enabled bool `json:"enabled"` //A flag to toggle this alert.
Action string `json:"action,omitempty"` //A flag that describes what happens when the alert is triggered. 'info' creates an incident in the dashboard. 'flagged' creates an incident and blocks traffic for 24 hours.
Type string `json:"type,omitempty"` //Type of alert (siteAlert, template, rateLimit, siteMetric)
SkipNotifications bool `json:"skipNotifications"` //A flag to disable external notifications - slack, webhooks, emails, etc.
FieldName string `json:"fieldName,omitempty"`
CreatedBy string `json:"createdBy,omitempty"` //The email of the user that created the alert
Created time.Time `json:"created,omitempty"` //RFC3339 date time
Operator string
Operator string `json:"operator,omitempty"`
}

// customAlertsResponse is the response for the alerts endpoint
Expand All @@ -573,12 +573,13 @@ func (sc *Client) ListCustomAlerts(corpName, siteName string) ([]CustomAlert, er

// CustomAlertBody is the body for creating a custom alert.
type CustomAlertBody struct {
TagName string `json:"tagName"`
LongName string `json:"longName"`
Interval int `json:"interval"`
Threshold int `json:"threshold"`
Enabled bool `json:"enabled"`
Action string `json:"action"`
TagName string `json:"tagName"`
LongName string `json:"longName"`
Interval int `json:"interval"`
Threshold int `json:"threshold"`
Enabled bool `json:"enabled"`
Action string `json:"action"`
SkipNotifications bool `json:"skipNotifications"`
}

// CreateCustomAlert creates a custom alert.
Expand Down

0 comments on commit a202798

Please sign in to comment.