Skip to content

Commit

Permalink
add incidents acknowledge
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Kooi <thomas@containerinfra.com>
  • Loading branch information
thojkooi committed Nov 15, 2023
1 parent 8a561fc commit 98d3898
Show file tree
Hide file tree
Showing 36 changed files with 167 additions and 59 deletions.
55 changes: 55 additions & 0 deletions cmd/incidents/acknowledge.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package incidents

import (
"fmt"

"github.com/spf13/cobra"
"github.com/uptime-cli/uptimectl/pkg/betteruptime"
)

var (
acknowledgeAll bool
acknowledgedBy string
)

// acknowledgeCmd represents the get command
var acknowledgeCmd = &cobra.Command{
Use: "acknowledge",
Short: "acknowledge an incident",
Long: "This will acknowledge an ongoing incident, preventing further escalations",
Aliases: []string{"ack"},
Args: cobra.MinimumNArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
client := betteruptime.NewClient()

if acknowledgeAll {
activeIncidents, err := client.ListIncidents(false, 14, 0)
if err != nil {
return err
}
for _, incident := range activeIncidents {
fmt.Printf("acknowleding incident %s (%s)\n", incident.Attributes.Name, incident.Id)
err := client.AcknowledgeIncident(cmd.Context(), incident.Id, acknowledgedBy)
if err != nil {
return err
}
}
return nil
}

for _, incidentID := range args {
err := client.AcknowledgeIncident(cmd.Context(), incidentID, acknowledgedBy)
if err != nil {
return err
}
}
return nil
},
}

func init() {
IncidentsCmd.AddCommand(acknowledgeCmd)

acknowledgeCmd.Flags().BoolVarP(&acknowledgeAll, "all", "a", false, "acknowledge all current active incidents")
acknowledgeCmd.Flags().StringVar(&acknowledgedBy, "acknowledged-by", "uptimectl", "User e-mail or a custom identifier of the entity that acknowledged the incident")
}
2 changes: 0 additions & 2 deletions cmd/incidents/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ var deleteCmd = &cobra.Command{
Aliases: []string{"del", "rm"},
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
// organisation := contextmanager.Organisation()
// clusters, err := platformapi.Client().GetClustersByOrg(organisation)
client := betteruptime.NewClient()

for _, incidentID := range args {
Expand Down
4 changes: 1 addition & 3 deletions cmd/incidents/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ var getCmd = &cobra.Command{
Use: "list",
Short: "Get a list of incidents",
Aliases: []string{"g", "get", "ls"},
Args: cobra.NoArgs, // TODO: allow to filter get cmd
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
// organisation := contextmanager.Organisation()
// clusters, err := platformapi.Client().GetClustersByOrg(organisation)
client := betteruptime.NewClient()
incidents, err := client.ListIncidents(showAll, showDays, showMax)
if err != nil {
Expand Down
4 changes: 1 addition & 3 deletions cmd/monitorgroups/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ var getCmd = &cobra.Command{
Use: "get",
Short: "Get a list of monitor groups",
Aliases: []string{"g", "list", "ls"},
Args: cobra.NoArgs, // TODO: allow to filter get cmd
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
// organisation := contextmanager.Organisation()
// clusters, err := platformapi.Client().GetClustersByOrg(organisation)
client := betteruptime.NewClient()
monitorGroups, err := client.ListMonitoringGroups()
if err != nil {
Expand Down
2 changes: 0 additions & 2 deletions cmd/statuspages/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ var getCmd = &cobra.Command{
Aliases: []string{"g", "list", "ls"},
Args: cobra.MaximumNArgs(10),
RunE: func(cmd *cobra.Command, args []string) error {
// organisation := contextmanager.Organisation()
// clusters, err := platformapi.Client().GetClustersByOrg(organisation)
client := betteruptime.NewClient()

statusPages := []betteruptime.StatusPage{}
Expand Down
2 changes: 0 additions & 2 deletions cmd/statuspages/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ var getResourcesCmd = &cobra.Command{
Aliases: []string{},
Args: cobra.MaximumNArgs(10),
RunE: func(cmd *cobra.Command, args []string) error {
// organisation := contextmanager.Organisation()
// clusters, err := platformapi.Client().GetClustersByOrg(organisation)
client := betteruptime.NewClient()

statusPageResources := []betteruptime.StatusPageResource{}
Expand Down
4 changes: 2 additions & 2 deletions docs/references/uptimectl.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
date: 2023-11-15T01:18:54+01:00
date: 2023-11-15T01:47:17+01:00
title: "uptimectl"
displayName: "uptimectl"
slug: uptimectl
url: /docs/references/uptimectl/uptimectl/
description: ""
lead: ""
weight: 732
weight: 731
toc: true
---
## uptimectl
Expand Down
2 changes: 1 addition & 1 deletion docs/references/uptimectl_auth.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
date: 2023-11-15T01:18:54+01:00
date: 2023-11-15T01:47:17+01:00
title: "uptimectl auth"
displayName: "auth"
slug: uptimectl_auth
Expand Down
2 changes: 1 addition & 1 deletion docs/references/uptimectl_auth_login.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
date: 2023-11-15T01:18:54+01:00
date: 2023-11-15T01:47:17+01:00
title: "uptimectl auth login"
displayName: "auth login"
slug: uptimectl_auth_login
Expand Down
2 changes: 1 addition & 1 deletion docs/references/uptimectl_auth_logout.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
date: 2023-11-15T01:18:54+01:00
date: 2023-11-15T01:47:17+01:00
title: "uptimectl auth logout"
displayName: "auth logout"
slug: uptimectl_auth_logout
Expand Down
2 changes: 1 addition & 1 deletion docs/references/uptimectl_config.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
date: 2023-11-15T01:18:54+01:00
date: 2023-11-15T01:47:17+01:00
title: "uptimectl config"
displayName: "config"
slug: uptimectl_config
Expand Down
2 changes: 1 addition & 1 deletion docs/references/uptimectl_config_current-context.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
date: 2023-11-15T01:18:54+01:00
date: 2023-11-15T01:47:17+01:00
title: "uptimectl config current-context"
displayName: "config current-context"
slug: uptimectl_config_current-context
Expand Down
2 changes: 1 addition & 1 deletion docs/references/uptimectl_config_get-contexts.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
date: 2023-11-15T01:18:54+01:00
date: 2023-11-15T01:47:17+01:00
title: "uptimectl config get-contexts"
displayName: "config get-contexts"
slug: uptimectl_config_get-contexts
Expand Down
2 changes: 1 addition & 1 deletion docs/references/uptimectl_config_use-context.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
date: 2023-11-15T01:18:54+01:00
date: 2023-11-15T01:47:17+01:00
title: "uptimectl config use-context"
displayName: "config use-context"
slug: uptimectl_config_use-context
Expand Down
2 changes: 1 addition & 1 deletion docs/references/uptimectl_config_use-organisation.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
date: 2023-11-15T01:18:54+01:00
date: 2023-11-15T01:47:17+01:00
title: "uptimectl config use-organisation"
displayName: "config use-organisation"
slug: uptimectl_config_use-organisation
Expand Down
2 changes: 1 addition & 1 deletion docs/references/uptimectl_config_view.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
date: 2023-11-15T01:18:54+01:00
date: 2023-11-15T01:47:17+01:00
title: "uptimectl config view"
displayName: "config view"
slug: uptimectl_config_view
Expand Down
5 changes: 3 additions & 2 deletions docs/references/uptimectl_incident.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
date: 2023-11-15T01:18:54+01:00
date: 2023-11-15T01:47:17+01:00
title: "uptimectl incident"
displayName: "incident"
slug: uptimectl_incident
url: /docs/references/uptimectl/uptimectl_incident/
description: ""
lead: ""
weight: 748
weight: 747
toc: true
---
## uptimectl incident
Expand All @@ -22,6 +22,7 @@ Manage incidents
### SEE ALSO

* [uptimectl](/docs/references/uptimectl/uptimectl/) - A command-line interface for working with Better Uptime
* [uptimectl incident acknowledge](/docs/references/uptimectl/uptimectl_incident_acknowledge/) - acknowledge an incident
* [uptimectl incident delete](/docs/references/uptimectl/uptimectl_incident_delete/) - Delete an incident
* [uptimectl incident list](/docs/references/uptimectl/uptimectl_incident_list/) - Get a list of incidents

35 changes: 35 additions & 0 deletions docs/references/uptimectl_incident_acknowledge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
date: 2023-11-15T01:47:17+01:00
title: "uptimectl incident acknowledge"
displayName: "incident acknowledge"
slug: uptimectl_incident_acknowledge
url: /docs/references/uptimectl/uptimectl_incident_acknowledge/
description: ""
lead: ""
weight: 750
toc: true
---
## uptimectl incident acknowledge

acknowledge an incident

### Synopsis

This will acknowledge an ongoing incident, preventing further escalations

```
uptimectl incident acknowledge [flags]
```

### Options

```
--acknowledged-by string User e-mail or a custom identifier of the entity that acknowledged the incident (default "uptimectl")
-a, --all acknowledge all current active incidents
-h, --help help for acknowledge
```

### SEE ALSO

* [uptimectl incident](/docs/references/uptimectl/uptimectl_incident/) - Manage incidents

4 changes: 2 additions & 2 deletions docs/references/uptimectl_incident_delete.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
date: 2023-11-15T01:18:54+01:00
date: 2023-11-15T01:47:17+01:00
title: "uptimectl incident delete"
displayName: "incident delete"
slug: uptimectl_incident_delete
url: /docs/references/uptimectl/uptimectl_incident_delete/
description: ""
lead: ""
weight: 750
weight: 749
toc: true
---
## uptimectl incident delete
Expand Down
4 changes: 2 additions & 2 deletions docs/references/uptimectl_incident_list.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
date: 2023-11-15T01:18:54+01:00
date: 2023-11-15T01:47:17+01:00
title: "uptimectl incident list"
displayName: "incident list"
slug: uptimectl_incident_list
url: /docs/references/uptimectl/uptimectl_incident_list/
description: ""
lead: ""
weight: 749
weight: 748
toc: true
---
## uptimectl incident list
Expand Down
4 changes: 2 additions & 2 deletions docs/references/uptimectl_monitor-groups.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
date: 2023-11-15T01:18:54+01:00
date: 2023-11-15T01:47:17+01:00
title: "uptimectl monitor-groups"
displayName: "monitor-groups"
slug: uptimectl_monitor-groups
url: /docs/references/uptimectl/uptimectl_monitor-groups/
description: ""
lead: ""
weight: 744
weight: 743
toc: true
---
## uptimectl monitor-groups
Expand Down
4 changes: 2 additions & 2 deletions docs/references/uptimectl_monitor-groups_create.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
date: 2023-11-15T01:18:54+01:00
date: 2023-11-15T01:47:17+01:00
title: "uptimectl monitor-groups create"
displayName: "monitor-groups create"
slug: uptimectl_monitor-groups_create
url: /docs/references/uptimectl/uptimectl_monitor-groups_create/
description: ""
lead: ""
weight: 747
weight: 746
toc: true
---
## uptimectl monitor-groups create
Expand Down
4 changes: 2 additions & 2 deletions docs/references/uptimectl_monitor-groups_delete.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
date: 2023-11-15T01:18:54+01:00
date: 2023-11-15T01:47:17+01:00
title: "uptimectl monitor-groups delete"
displayName: "monitor-groups delete"
slug: uptimectl_monitor-groups_delete
url: /docs/references/uptimectl/uptimectl_monitor-groups_delete/
description: ""
lead: ""
weight: 746
weight: 745
toc: true
---
## uptimectl monitor-groups delete
Expand Down
4 changes: 2 additions & 2 deletions docs/references/uptimectl_monitor-groups_get.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
date: 2023-11-15T01:18:54+01:00
date: 2023-11-15T01:47:17+01:00
title: "uptimectl monitor-groups get"
displayName: "monitor-groups get"
slug: uptimectl_monitor-groups_get
url: /docs/references/uptimectl/uptimectl_monitor-groups_get/
description: ""
lead: ""
weight: 745
weight: 744
toc: true
---
## uptimectl monitor-groups get
Expand Down
4 changes: 2 additions & 2 deletions docs/references/uptimectl_monitors.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
date: 2023-11-15T01:18:54+01:00
date: 2023-11-15T01:47:17+01:00
title: "uptimectl monitors"
displayName: "monitors"
slug: uptimectl_monitors
url: /docs/references/uptimectl/uptimectl_monitors/
description: ""
lead: ""
weight: 740
weight: 739
toc: true
---
## uptimectl monitors
Expand Down
4 changes: 2 additions & 2 deletions docs/references/uptimectl_monitors_create.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
date: 2023-11-15T01:18:54+01:00
date: 2023-11-15T01:47:17+01:00
title: "uptimectl monitors create"
displayName: "monitors create"
slug: uptimectl_monitors_create
url: /docs/references/uptimectl/uptimectl_monitors_create/
description: ""
lead: ""
weight: 743
weight: 742
toc: true
---
## uptimectl monitors create
Expand Down
4 changes: 2 additions & 2 deletions docs/references/uptimectl_monitors_delete.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
date: 2023-11-15T01:18:54+01:00
date: 2023-11-15T01:47:17+01:00
title: "uptimectl monitors delete"
displayName: "monitors delete"
slug: uptimectl_monitors_delete
url: /docs/references/uptimectl/uptimectl_monitors_delete/
description: ""
lead: ""
weight: 742
weight: 741
toc: true
---
## uptimectl monitors delete
Expand Down
4 changes: 2 additions & 2 deletions docs/references/uptimectl_monitors_get.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
date: 2023-11-15T01:18:54+01:00
date: 2023-11-15T01:47:17+01:00
title: "uptimectl monitors get"
displayName: "monitors get"
slug: uptimectl_monitors_get
url: /docs/references/uptimectl/uptimectl_monitors_get/
description: ""
lead: ""
weight: 741
weight: 740
toc: true
---
## uptimectl monitors get
Expand Down
Loading

0 comments on commit 98d3898

Please sign in to comment.