Skip to content

Commit

Permalink
Merge pull request #5 from STLVRTX/master
Browse files Browse the repository at this point in the history
fix uptimemonitor field, update readme
  • Loading branch information
yacut authored Jul 4, 2022
2 parents 6c340c5 + acbc7db commit a3f9e52
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 23 deletions.
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@

**The official iLert Go api bindings.**

## Legacy API

> If you want to use the old client with v1 resources, please install it with the following command: `go get github.com/iLert/ilert-go`

## Create an incident (manually)

```go
package main

import (
"log"
"github.com/iLert/ilert-go"
"github.com/iLert/ilert-go/v2"
)

func main() {
Expand All @@ -21,8 +26,8 @@ func main() {
event := &ilert.Event{
APIKey: apiKey,
EventType: ilert.EventTypes.Alert,
Summary: "My test incident summary",
IncidentKey: "123456",
Summary: "My test alert summary",
AlertKey: "123456",
}

input := &ilert.CreateEventInput{Event: event}
Expand All @@ -32,7 +37,7 @@ func main() {
log.Fatalln("ERROR:", err)
}

log.Println("Incident key:", result.EventResponse.IncidentKey)
log.Println("Event processed!")
}
```

Expand All @@ -43,7 +48,7 @@ package main

import (
"log"
"github.com/iLert/ilert-go"
"github.com/iLert/ilert-go/v2"
)

func main() {
Expand Down Expand Up @@ -72,7 +77,7 @@ package main

import (
"log"
"github.com/iLert/ilert-go"
"github.com/iLert/ilert-go/v2"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion event.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (c *Client) CreateEvent(input *CreateEventInput) (*CreateEventOutput, error
if err != nil {
return nil, err
}
if apiErr := getGenericAPIError(resp, 200); apiErr != nil {
if apiErr := getGenericAPIError(resp, 200, 202); apiErr != nil {
return nil, apiErr
}
eventResponse := &EventResponse{}
Expand Down
2 changes: 1 addition & 1 deletion examples/event/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ func main() {
}
}

log.Println("Incident key:", result.EventResponse.AlertKey)
log.Println("Alert key:", result.EventResponse.AlertKey)
}
30 changes: 15 additions & 15 deletions uptimemonitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ import (

// UptimeMonitor definition https://api.ilert.com/api-docs/#tag/Uptime-Monitors
type UptimeMonitor struct {
ID int64 `json:"id,omitempty"`
Name string `json:"name"`
Region string `json:"region"`
CheckType string `json:"checkType"`
CheckParams *UptimeMonitorCheckParams `json:"checkParams,omitempty"`
IntervalSec int `json:"intervalSec,omitempty"` // default: 300
TimeoutMs int `json:"timeoutMs,omitempty"` // default: 30000
CreateIncidentAfterFailedChecks int `json:"createIncidentAfterFailedChecks,omitempty"` // @deprecated
CreateAlertAfterFailedChecks int `json:"createAlertAfterFailedChecks,omitempty"` // default: 1
EscalationPolicy *EscalationPolicy `json:"escalationPolicy,omitempty"`
Paused bool `json:"paused,omitempty"` // default: false
EmbedURL string `json:"embedURL,omitempty"` // read only
ShareURL string `json:"shareURL,omitempty"` // read only
Status string `json:"status,omitempty"`
LastStatusChange string `json:"lastStatusChange,omitempty"` // Date time string in ISO format
ID int64 `json:"id,omitempty"`
Name string `json:"name"`
Region string `json:"region"`
CheckType string `json:"checkType"`
CheckParams UptimeMonitorCheckParams `json:"checkParams"`
IntervalSec int `json:"intervalSec,omitempty"` // default: 300
TimeoutMs int `json:"timeoutMs,omitempty"` // default: 30000
CreateIncidentAfterFailedChecks int `json:"createIncidentAfterFailedChecks,omitempty"` // @deprecated
CreateAlertAfterFailedChecks int `json:"createAlertAfterFailedChecks,omitempty"` // default: 1
EscalationPolicy *EscalationPolicy `json:"escalationPolicy,omitempty"`
Paused bool `json:"paused,omitempty"` // default: false
EmbedURL string `json:"embedURL,omitempty"` // read only
ShareURL string `json:"shareURL,omitempty"` // read only
Status string `json:"status,omitempty"`
LastStatusChange string `json:"lastStatusChange,omitempty"` // Date time string in ISO format
}

// UptimeMonitorCheckParams definition
Expand Down

0 comments on commit a3f9e52

Please sign in to comment.