-
Notifications
You must be signed in to change notification settings - Fork 14
/
runstatus_event.go
37 lines (31 loc) · 1.14 KB
/
runstatus_event.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
package egoscale
import (
"context"
"fmt"
"time"
)
// RunstatusEvent is a runstatus event
type RunstatusEvent struct {
Created *time.Time `json:"created,omitempty"`
State string `json:"state,omitempty"`
Status string `json:"status"`
Text string `json:"text"`
}
// UpdateRunstatusIncident create runstatus incident event
// Events can be updates or final message with status completed.
func (client *Client) UpdateRunstatusIncident(ctx context.Context, incident RunstatusIncident, event RunstatusEvent) error {
if incident.EventsURL == "" {
return fmt.Errorf("empty Events URL for %#v", incident)
}
_, err := client.runstatusRequest(ctx, incident.EventsURL, event, "POST")
return err
}
// UpdateRunstatusMaintenance adds a event to a maintenance.
// Events can be updates or final message with status completed.
func (client *Client) UpdateRunstatusMaintenance(ctx context.Context, maintenance RunstatusMaintenance, event RunstatusEvent) error {
if maintenance.EventsURL == "" {
return fmt.Errorf("empty Events URL for %#v", maintenance)
}
_, err := client.runstatusRequest(ctx, maintenance.EventsURL, event, "POST")
return err
}