-
Notifications
You must be signed in to change notification settings - Fork 1
/
heartbeat.go
52 lines (45 loc) · 1.19 KB
/
heartbeat.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package ilert
import (
"errors"
"fmt"
)
// HeartbeatMethods defines uptime monitor regions
var HeartbeatMethods = struct {
HEAD string
GET string
POST string
}{
HEAD: "HEAD",
GET: "GET",
POST: "POST",
}
// PingHeartbeatInput represents the input of a PingHeartbeat operation.
type PingHeartbeatInput struct {
_ struct{}
Method *string
APIKey *string
}
// PingHeartbeatOutput represents the output of a PingHeartbeat operation.
type PingHeartbeatOutput struct {
_ struct{}
}
// PingHeartbeat gets list available ilert phone numbers. https://api.ilert.com/api-docs/#tag/Heartbeats/paths/~1heartbeats~1{key}/get
func (c *Client) PingHeartbeat(input *PingHeartbeatInput) (*PingHeartbeatOutput, error) {
if input == nil {
return nil, errors.New("input is required")
}
if input.APIKey == nil {
return nil, errors.New("api key is required")
}
if input.Method == nil {
input.Method = String(HeartbeatMethods.HEAD)
}
resp, err := c.httpClient.R().Execute(*input.Method, fmt.Sprintf("%s/%s", apiRoutes.heartbeats, *input.APIKey))
if err != nil {
return nil, err
}
if apiErr := getGenericAPIError(resp, 202); apiErr != nil {
return nil, apiErr
}
return &PingHeartbeatOutput{}, nil
}