Skip to content

Commit

Permalink
Merge pull request #15 from iLert/feature/move-automation-rule_status…
Browse files Browse the repository at this point in the history
…-page-ip-filter

Feature/move automation rule status page ip filter
  • Loading branch information
yacut authored Nov 21, 2022
2 parents e94d751 + 9f33c68 commit 7168a09
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 39 deletions.
91 changes: 62 additions & 29 deletions alertaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,45 @@ type AlertActionOutput struct {

// AlertActionOutputParams definition
type AlertActionOutputParams struct {
BodyTemplate string `json:"bodyTemplate,omitempty"` // Custom, Jira, Email. Used to post data to external server
CallerID string `json:"callerId,omitempty"` // ServiceNow: user email
ChannelID string `json:"channelId,omitempty"` // Slack
ChannelName string `json:"channelName,omitempty"` // Slack
CompanyID int64 `json:"companyId,omitempty"` // Autotask: Company ID
EventFilter string `json:"eventFilter,omitempty"` // Sysdig
Impact string `json:"impact,omitempty"` // ServiceNow: 1 - High, 2 - Medium, 3 - Low (Default)
IssueType string `json:"issueType,omitempty"` // Jira: "Bug" | "Epic" | "Subtask" | "Story" | "Task"
IssueTypeNumber int64 `json:"issueTypeNumber,omitempty"` // Autotask: Issue type
Labels []string `json:"labels,omitempty"` // Github
Name string `json:"name,omitempty"` // Jira or MicrosoftTeams or Zendesk
Owner string `json:"owner,omitempty"` // Github
Priority string `json:"priority,omitempty"` // Datadog: "normal" | "low". Zendesk: "urgent" | "high" | "normal" | "low".
Project string `json:"project,omitempty"` // Jira
QueueID int64 `json:"queueId,omitempty"` // Autotask: Queue ID
Recipients []string `json:"recipients,omitempty"` // Email
Repository string `json:"repository,omitempty"` // Github
Site string `json:"site,omitempty"` // Datadog: default `US`. Values: `US` or `EU`
Status string `json:"status,omitempty"` // Topdesk: firstLine, secondLine, partial
Subject string `json:"subject,omitempty"` // Email
Tags []string `json:"tags,omitempty"` // Datadog or Sysdig
TeamDomain string `json:"teamDomain,omitempty"` // Slack
TeamID string `json:"teamId,omitempty"` // Slack
TicketCategory string `json:"ticketCategory,omitempty"` // Autotask
TicketType string `json:"ticketType,omitempty"` // Autotask
Urgency string `json:"urgency,omitempty"` // ServiceNow: 1 - High, 2 - Medium, 3 - Low (Default)
WebhookURL string `json:"webhookUrl,omitempty"` // Custom
Email string `json:"email,omitempty"` // Zammad
PageID string `json:"pageId,omitempty"` // StatusPage.io
AlertType string `json:"alertType"` // Automation rule
AtMobiles []string `json:"atMobiles,omitempty"` // DingTalk
BodyTemplate string `json:"bodyTemplate,omitempty"` // Custom, Jira, Email. Used to post data to external server
CallerID string `json:"callerId,omitempty"` // ServiceNow: user email
ChannelID string `json:"channelId,omitempty"` // Slack
ChannelName string `json:"channelName,omitempty"` // Slack
CompanyID int64 `json:"companyId,omitempty"` // Autotask: Company ID
Email string `json:"email,omitempty"` // Zammad
EventFilter string `json:"eventFilter,omitempty"` // Sysdig
Impact string `json:"impact,omitempty"` // ServiceNow: 1 - High, 2 - Medium, 3 - Low (Default)
IsAtAll bool `json:"isAtAll,omitempty"` // DingTalk
IssueType string `json:"issueType,omitempty"` // Jira: "Bug" | "Epic" | "Subtask" | "Story" | "Task"
IssueTypeNumber int64 `json:"issueTypeNumber,omitempty"` // Autotask: Issue type
Labels []string `json:"labels,omitempty"` // Github
Name string `json:"name,omitempty"` // Jira or MicrosoftTeams or Zendesk
Owner string `json:"owner,omitempty"` // Github
PageID string `json:"pageId,omitempty"` // StatusPage.io
Priority string `json:"priority,omitempty"` // Datadog: "normal" | "low". Zendesk: "urgent" | "high" | "normal" | "low".
Project string `json:"project,omitempty"` // Jira
QueueID int64 `json:"queueId,omitempty"` // Autotask: Queue ID
Recipients []string `json:"recipients,omitempty"` // Email
Repository string `json:"repository,omitempty"` // Github
ResolveIncident bool `json:"resolveIncident,omitempty"` // Automation rule
Secret string `json:"secret,omitempty"` // DingTalk
SendNotification bool `json:"sendNotification,omitempty"` // Automation rule
ServiceIds []int64 `json:"serviceIds"` // Automation rule
ServiceStatus string `json:"serviceStatus"` // Automation rule
Site string `json:"site,omitempty"` // Datadog: default `US`. Values: `US` or `EU`
Status string `json:"status,omitempty"` // Topdesk: firstLine, secondLine, partial
Subject string `json:"subject,omitempty"` // Email
Tags []string `json:"tags,omitempty"` // Datadog or Sysdig
TeamDomain string `json:"teamDomain,omitempty"` // Slack
TeamID string `json:"teamId,omitempty"` // Slack
TemplateId int64 `json:"templateId,omitempty"` // Automation rule
TicketCategory string `json:"ticketCategory,omitempty"` // Autotask
TicketType string `json:"ticketType,omitempty"` // Autotask
Urgency string `json:"urgency,omitempty"` // ServiceNow: 1 - High, 2 - Medium, 3 - Low (Default)
WebhookURL string `json:"webhookUrl,omitempty"` // Custom
URL string `json:"url,omitempty"` // DingTalk
}

// AlertActionParamsAutotask definition
Expand Down Expand Up @@ -180,6 +190,29 @@ type AlertActionParamsStatusPageIO struct {
PageID string `json:"pageId,omitempty"`
}

// AlertActionParamsDingTalk definition
type AlertActionParamsDingTalk struct {
URL string `json:"url,omitempty"`
Secret string `json:"secret,omitempty"`
IsAtAll bool `json:"isAtAll,omitempty"`
AtMobiles []string `json:"atMobiles,omitempty"`
}

// AlertActionParamsDingTalkAction definition
type AlertActionParamsDingTalkAction struct {
URL string `json:"url,omitempty"`
}

// AlertActionParamsAutomationRule definition
type AlertActionParamsAutomationRule struct {
AlertType string `json:"alertType"`
ResolveIncident bool `json:"resolveIncident,omitempty"`
ServiceStatus string `json:"serviceStatus"`
TemplateId int64 `json:"templateId,omitempty"`
SendNotification bool `json:"sendNotification,omitempty"`
ServiceIds []int64 `json:"serviceIds"`
}

// AlertActionResult definition
type AlertActionResult struct {
ID string `json:"id"`
Expand Down
12 changes: 6 additions & 6 deletions automationrule.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strconv"
)

// Automation Rules definition https://api.ilert.com/api-docs/#tag/Automation-Rules
// Legacy API - please use alert-actions of type 'automation_rule' - for more information see https://api.ilert.com/api-docs/#tag/Connectors/paths/~1connectors/post
type AutomationRule struct {
ID string `json:"id"`
AlertType string `json:"alertType"`
Expand Down Expand Up @@ -48,7 +48,7 @@ type CreateAutomationRuleOutput struct {
AutomationRule *AutomationRule
}

// CreateAutomationRule creates a new automationRule. https://api.ilert.com/api-docs/#tag/Automation-Rules/paths/~1automation-rules/post
// Legacy API - please use alert-actions of type 'automation_rule' - for more information see https://api.ilert.com/api-docs/#tag/Connectors/paths/~1connectors/post
func (c *Client) CreateAutomationRule(input *CreateAutomationRuleInput) (*CreateAutomationRuleOutput, error) {
if input == nil {
return nil, errors.New("input is required")
Expand Down Expand Up @@ -93,7 +93,7 @@ type GetAutomationRulesOutput struct {
AutomationRules []*AutomationRule
}

// GetAutomationRules lists automationRule sources. https://api.ilert.com/api-docs/#tag/Automation-Rules/paths/~1automation-rules/get
// Legacy API - please use alert-actions of type 'automation_rule' - for more information see https://api.ilert.com/api-docs/#tag/Connectors/paths/~1connectors/post
func (c *Client) GetAutomationRules(input *GetAutomationRulesInput) (*GetAutomationRulesOutput, error) {
if input == nil {
input = &GetAutomationRulesInput{}
Expand Down Expand Up @@ -142,7 +142,7 @@ type GetAutomationRuleOutput struct {
AutomationRule *AutomationRule
}

// GetAutomationRule gets a automationRule by ID. https://api.ilert.com/api-docs/#tag/Automation-Rules/paths/~1automation-rules~1{id}/get
// Legacy API - please use alert-actions of type 'automation_rule' - for more information see https://api.ilert.com/api-docs/#tag/Connectors/paths/~1connectors/post
func (c *Client) GetAutomationRule(input *GetAutomationRuleInput) (*GetAutomationRuleOutput, error) {
if input == nil {
return nil, errors.New("input is required")
Expand Down Expand Up @@ -185,7 +185,7 @@ type UpdateAutomationRuleOutput struct {
AutomationRule *AutomationRule
}

// UpdateAutomationRule updates the specific automationRule. https://api.ilert.com/api-docs/#tag/Automation-Rules/paths/~1automation-rules~1{id}/put
// Legacy API - please use alert-actions of type 'automation_rule' - for more information see https://api.ilert.com/api-docs/#tag/Connectors/paths/~1connectors/post
func (c *Client) UpdateAutomationRule(input *UpdateAutomationRuleInput) (*UpdateAutomationRuleOutput, error) {
if input == nil {
return nil, errors.New("input is required")
Expand Down Expand Up @@ -227,7 +227,7 @@ type DeleteAutomationRuleOutput struct {
_ struct{}
}

// DeleteAutomationRule deletes the specified automationRule. https://api.ilert.com/api-docs/#tag/Automation-Rules/paths/~1automation-rules~1{id}/delete
// Legacy API - please use alert-actions of type 'automation_rule' - for more information see https://api.ilert.com/api-docs/#tag/Connectors/paths/~1connectors/post
func (c *Client) DeleteAutomationRule(input *DeleteAutomationRuleInput) (*DeleteAutomationRuleOutput, error) {
if input == nil {
return nil, errors.New("input is required")
Expand Down
10 changes: 7 additions & 3 deletions connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type ConnectorOutputParams struct {
Email string `json:"email,omitempty"` // Jira or ServiceNow or Zendesk username or email
Username string `json:"username,omitempty"` // TOPdesk or ServiceNow or Autotask username
Password string `json:"password,omitempty"` // Jira or ServiceNow or Autotask user password or api token
Secret string `json:"secret,omitempty"` // DingTalk
}

// ConnectorParamsDatadog definition
Expand Down Expand Up @@ -130,6 +131,12 @@ type ConnectorParamsStatusPageIO struct {
APIKey string `json:"apiKey"`
}

// ConnectorParamsDingTalk definition
type ConnectorParamsDingTalk struct {
URL string `json:"url,omitempty"`
Secret string `json:"secret,omitempty"`
}

// ConnectorTypes defines connector types
var ConnectorTypes = struct {
AWSLambda string
Expand Down Expand Up @@ -157,7 +164,6 @@ var ConnectorTypes = struct {
StatusPageIO string
Webex string
DingTalk string
DingTalkAction string
}{
AWSLambda: "aws_lambda",
AzureFAAS: "azure_faas",
Expand All @@ -184,7 +190,6 @@ var ConnectorTypes = struct {
StatusPageIO: "status_page_io",
Webex: "webex",
DingTalk: "dingtalk",
DingTalkAction: "dingtalk_action",
}

// ConnectorTypesAll defines connector all types list
Expand Down Expand Up @@ -214,7 +219,6 @@ var ConnectorTypesAll = []string{
ConnectorTypes.StatusPageIO,
ConnectorTypes.Webex,
ConnectorTypes.DingTalk,
ConnectorTypes.DingTalkAction,
}

// CreateConnectorInput represents the input of a CreateConnector operation.
Expand Down
1 change: 1 addition & 0 deletions statuspage.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type StatusPage struct {
Timezone string `json:"timezone,omitempty"`
Services []Service `json:"services,omitempty"`
Subscribed bool `json:"subscribed,omitempty"`
IpWhitelist []string `json:"ipWhitelist,omitempty"`
}

// StatusPageVisibility defines status page visibility
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 = "v2.2.3"
const Version = "v2.3.0"

0 comments on commit 7168a09

Please sign in to comment.