Skip to content

Commit

Permalink
Merge pull request #19 from iLert/feature/status-page-service-groups
Browse files Browse the repository at this point in the history
Feature/status page service groups
  • Loading branch information
yacut authored Jan 12, 2023
2 parents ccc77fb + 42884fd commit 3a403d9
Show file tree
Hide file tree
Showing 10 changed files with 394 additions and 34 deletions.
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 12.01.2023, Version 2.5.0

- add status page groups
- add status page structure for groups

## 11.01.2023, Version 2.4.0

- add pagination for alert actions
Expand All @@ -17,6 +22,25 @@
- enforce pagination for services
- enforce pagination for status pages

## 28.11.2022, Version 2.3.3

- fix typo in dingtalk alert action type

## 25.11.2022, Version 2.3.2

- add alert action alert filter

## 24.11.2022, Version 2.3.1

- add missing connector types for Terraform provider

## 21.11.2022, Version 2.3.0

- deprecate automation rule
- add automation rule as connector type under alert action
- add status page ip filter
- add dingtalk as an alert action / connector

## 17.11.2022, Version 2.2.3

- add dingtalk alert action and connector support
Expand Down
14 changes: 7 additions & 7 deletions alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ type GetAlertsOutput struct {
Alerts []*Alert
}

// GetAlerts lists alert sources. https://api.ilert.com/api-docs/#tag/Alerts/paths/~1alerts/get
// GetAlerts lists alerts. https://api.ilert.com/api-docs/#tag/Alerts/paths/~1alerts/get
func (c *Client) GetAlerts(input *GetAlertsInput) (*GetAlertsOutput, error) {
if input == nil {
input = &GetAlertsInput{}
Expand Down Expand Up @@ -342,7 +342,7 @@ type GetAlertsCountOutput struct {
Count int
}

// GetAlertsCount gets list uptime monitors. https://api.ilert.com/api-docs/#tag/Alerts/paths/~1alerts~1count/get
// GetAlertsCount gets the alert count. https://api.ilert.com/api-docs/#tag/Alerts/paths/~1alerts~1count/get
func (c *Client) GetAlertsCount(input *GetAlertsCountInput) (*GetAlertsCountOutput, error) {
if input == nil {
input = &GetAlertsCountInput{}
Expand Down Expand Up @@ -402,7 +402,7 @@ type GetAlertResponderOutput struct {
Responders []*AlertResponder
}

// GetAlertResponder gets the alert source with specified id. https://api.ilert.com/api-docs/#tag/Alerts/paths/~1alerts~1{id}~1responder/get
// GetAlertResponder gets the responders on the alert with specified id. https://api.ilert.com/api-docs/#tag/Alerts/paths/~1alerts~1{id}~1suggested-responders/get
func (c *Client) GetAlertResponder(input *GetAlertResponderInput) (*GetAlertResponderOutput, error) {
if input == nil {
return nil, errors.New("input is required")
Expand All @@ -420,7 +420,7 @@ func (c *Client) GetAlertResponder(input *GetAlertResponderInput) (*GetAlertResp
}
}

resp, err := c.httpClient.R().Get(fmt.Sprintf("%s/%d/responder", apiRoutes.alerts, *input.AlertID))
resp, err := c.httpClient.R().Get(fmt.Sprintf("%s/%d/suggested-responders", apiRoutes.alerts, *input.AlertID))
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -453,7 +453,7 @@ type AssignAlertOutput struct {
Alert *Alert
}

// AssignAlert gets the alert source with specified id. https://api.ilert.com/api-docs/#tag/Alerts/paths/~1alerts~1{id}~1assign/put
// AssignAlert assigns an alert with specified id to specified entities. https://api.ilert.com/api-docs/#tag/Alerts/paths/~1alerts~1{id}~1assign/put
func (c *Client) AssignAlert(input *AssignAlertInput) (*AssignAlertOutput, error) {
if input == nil {
return nil, errors.New("input is required")
Expand Down Expand Up @@ -509,7 +509,7 @@ type AcceptAlertOutput struct {
Alert *Alert
}

// AcceptAlert gets the alert source with specified id. https://api.ilert.com/api-docs/#tag/Alerts/paths/~1alerts~1{id}~1accept/put
// AcceptAlert accepts an alert with specified id. https://api.ilert.com/api-docs/#tag/Alerts/paths/~1alerts~1{id}~1accept/put
func (c *Client) AcceptAlert(input *AcceptAlertInput) (*AcceptAlertOutput, error) {
if input == nil {
return nil, errors.New("input is required")
Expand Down Expand Up @@ -547,7 +547,7 @@ type ResolveAlertOutput struct {
Alert *Alert
}

// ResolveAlert gets the alert source with specified id. https://api.ilert.com/api-docs/#tag/Alerts/paths/~1alerts~1{id}~1resolve/put
// ResolveAlert resolves an alert with specified id. https://api.ilert.com/api-docs/#tag/Alerts/paths/~1alerts~1{id}~1resolve/put
func (c *Client) ResolveAlert(input *ResolveAlertInput) (*ResolveAlertOutput, error) {
if input == nil {
return nil, errors.New("input is required")
Expand Down
2 changes: 1 addition & 1 deletion alertaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ type DeleteAlertActionOutput struct {
_ struct{}
}

// DeleteAlertAction deletes the specified alert source. https://api.ilert.com/api-docs/#tag/Alert-Actions/paths/~1alert-actions~1{id}/delete
// DeleteAlertAction deletes the specified alert action. https://api.ilert.com/api-docs/#tag/Alert-Actions/paths/~1alert-actions~1{id}/delete
func (c *Client) DeleteAlertAction(input *DeleteAlertActionInput) (*DeleteAlertActionOutput, error) {
if input == nil {
return nil, errors.New("input is required")
Expand Down
2 changes: 1 addition & 1 deletion connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ type DeleteConnectorOutput struct {
_ struct{}
}

// DeleteConnector deletes the specified alert source. https://api.ilert.com/api-docs/#tag/Connectors/paths/~1connectors~1{id}/delete
// DeleteConnector deletes the specified connector. https://api.ilert.com/api-docs/#tag/Connectors/paths/~1connectors~1{id}/delete
func (c *Client) DeleteConnector(input *DeleteConnectorInput) (*DeleteConnectorOutput, error) {
if input == nil {
return nil, errors.New("input is required")
Expand Down
27 changes: 27 additions & 0 deletions examples/statuspage_group/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package main

import (
"fmt"
"log"

"github.com/iLert/ilert-go/v2"
)

func main() {
var apiToken = "your API token"
client := ilert.NewClient(ilert.WithAPIToken(apiToken))
newStatusPageGroup := &ilert.StatusPageGroup{
Name: "your status page group name",
}
statusPage := &ilert.StatusPage{ID: 0} // your status page id
input := &ilert.CreateStatusPageGroupInput{
StatusPageGroup: newStatusPageGroup,
StatusPageID: &statusPage.ID,
}
result, err := client.CreateStatusPageGroup(input)
if err != nil {
log.Println(result)
log.Fatalln("ERROR:", err)
}
log.Println(fmt.Sprintf("Statuspage Group:\n\n %+v\n", result.StatusPageGroup))
}
80 changes: 58 additions & 22 deletions statuspage.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,50 @@ import (
"strconv"
)

// Status-Page definition https://api.ilert.com/api-docs/#!/Status-Pages
// StatusPage definition https://api.ilert.com/api-docs/#!/Status-Pages
type StatusPage struct {
ID int64 `json:"id"`
Name string `json:"name"`
Domain string `json:"domain"`
Subdomain string `json:"subdomain"`
CustomCss string `json:"customCss"`
FaviconUrl string `json:"faviconUrl"`
LogoUrl string `json:"logoUrl"`
Visibility string `json:"visibility"`
HiddenFromSearch bool `json:"hiddenFromSearch"`
ShowSubscribeAction bool `json:"showSubscribeAction"`
ShowIncidentHistoryOption bool `json:"showIncidentHistoryOption"`
PageTitle string `json:"pageTitle"`
PageDescription string `json:"pageDescription"`
LogoRedirectUrl string `json:"logoRedirectUrl"`
Activated bool `json:"activated"`
Status string `json:"status"`
Teams []TeamShort `json:"teams"`
Timezone string `json:"timezone,omitempty"`
Services []Service `json:"services,omitempty"`
Subscribed bool `json:"subscribed,omitempty"`
IpWhitelist []string `json:"ipWhitelist,omitempty"`
ID int64 `json:"id"`
Name string `json:"name"`
Domain string `json:"domain"`
Subdomain string `json:"subdomain"`
CustomCss string `json:"customCss"`
FaviconUrl string `json:"faviconUrl"`
LogoUrl string `json:"logoUrl"`
Visibility string `json:"visibility"`
HiddenFromSearch bool `json:"hiddenFromSearch"`
ShowSubscribeAction bool `json:"showSubscribeAction"`
ShowIncidentHistoryOption bool `json:"showIncidentHistoryOption"`
PageTitle string `json:"pageTitle"`
PageDescription string `json:"pageDescription"`
LogoRedirectUrl string `json:"logoRedirectUrl"`
Activated bool `json:"activated"`
Status string `json:"status"`
Teams []TeamShort `json:"teams"`
Timezone string `json:"timezone,omitempty"`
Services []Service `json:"services,omitempty"`
Subscribed bool `json:"subscribed,omitempty"`
IpWhitelist []string `json:"ipWhitelist,omitempty"`
Structure *StatusPageStructure `json:"structure,omitempty"`
}

// StatusPageStructure defines status page structure
type StatusPageStructure struct {
Elements []StatusPageElement
}

// StatusPageElement defines status page element
type StatusPageElement struct {
// Must be either a service ID or status page service group ID.
// Provided service or status page service group must already be included in current status page
ID int64

// Must be either "SERVICE" or "GROUP", corresponding to given ID
Type string

// Can only contain StatusPageElement of type "SERVICE".
// Must not be set on type "SERVICE".
// Must be set on type "GROUP".
Children []StatusPageElement
}

// StatusPageVisibility defines status page visibility
Expand All @@ -48,6 +69,21 @@ var StatusPageVisibilityAll = []string{
StatusPageVisibility.Private,
}

// StatusPageElementType defines status page element type
var StatusPageElementType = struct {
Service string
Group string
}{
Service: "SERVICE",
Group: "GROUP",
}

// StatusPageElementTypeAll defines all status page element types
var StatusPageElementTypeAll = []string{
StatusPageElementType.Service,
StatusPageElementType.Group,
}

// CreateStatusPageInput represents the input of a CreateStatusPage operation.
type CreateStatusPageInput struct {
_ struct{}
Expand Down
Loading

0 comments on commit 3a403d9

Please sign in to comment.