Skip to content

Commit

Permalink
add includes for alert source api calls
Browse files Browse the repository at this point in the history
  • Loading branch information
STLVRTX committed Aug 22, 2024
1 parent 3fb5ff4 commit e34dc31
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions alert_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit e34dc31

Please sign in to comment.