forked from Bonial-International-GmbH/site24x7-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
current_status.go
71 lines (59 loc) · 1.53 KB
/
current_status.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package endpoints
import (
"github.com/Bonial-International-GmbH/site24x7-go/api"
"github.com/Bonial-International-GmbH/site24x7-go/rest"
)
type CurrentStatus interface {
Get(monitorID string) (*api.MonitorStatus, error)
ListGroup(groupID string) (*api.MonitorsStatus, error)
ListType(monitorType string) (*api.MonitorsStatus, error)
List(options *api.CurrentStatusListOptions) (*api.MonitorsStatus, error)
}
type currentStatus struct {
client rest.Client
}
func NewCurrentStatus(client rest.Client) CurrentStatus {
return ¤tStatus{
client: client,
}
}
func (c *currentStatus) Get(monitorID string) (*api.MonitorStatus, error) {
status := &api.MonitorStatus{}
err := c.client.
Get().
Resource("current_status").
ResourceID(monitorID).
Do().
Into(status)
return status, err
}
func (c *currentStatus) ListGroup(groupID string) (*api.MonitorsStatus, error) {
status := &api.MonitorsStatus{}
err := c.client.
Get().
Resource("current_status/group").
ResourceID(groupID).
Do().
Into(status)
return status, err
}
func (c *currentStatus) ListType(monitorType string) (*api.MonitorsStatus, error) {
status := &api.MonitorsStatus{}
err := c.client.
Get().
Resource("current_status/type").
ResourceID(monitorType).
Do().
Into(status)
return status, err
}
func (c *currentStatus) List(options *api.CurrentStatusListOptions) (*api.MonitorsStatus, error) {
status := &api.MonitorsStatus{}
err := c.client.
Get().
Resource("current_status").
QueryParams(options).
Do().
Into(status)
return status, err
}