-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathevents.go
More file actions
42 lines (34 loc) · 1.22 KB
/
events.go
File metadata and controls
42 lines (34 loc) · 1.22 KB
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
// Package ps provides methods for managing app processes.
package events
import (
"encoding/json"
"fmt"
drycc "github.com/drycc/controller-sdk-go"
"github.com/drycc/controller-sdk-go/api"
)
// List events of an app process.
func ListPodEvents(c *drycc.Client, appID string, podName string, results int) (api.AppEvents, int, error) {
u := fmt.Sprintf("/v2/apps/%s/events/?pod_name=%s", appID, podName)
body, count, reqErr := c.LimitedRequest(u, results)
if reqErr != nil && !drycc.IsErrAPIMismatch(reqErr) {
return []api.AppEvent{}, -1, reqErr
}
var events []api.AppEvent
if err := json.Unmarshal([]byte(body), &events); err != nil {
return []api.AppEvent{}, -1, err
}
return events, count, reqErr
}
// List events of an app ptype.
func ListPtypeEvents(c *drycc.Client, appID string, ptype string, results int) (api.AppEvents, int, error) {
u := fmt.Sprintf("/v2/apps/%s/events/?ptype=%s-%s", appID, appID, ptype)
body, count, reqErr := c.LimitedRequest(u, results)
if reqErr != nil && !drycc.IsErrAPIMismatch(reqErr) {
return []api.AppEvent{}, -1, reqErr
}
var events []api.AppEvent
if err := json.Unmarshal([]byte(body), &events); err != nil {
return []api.AppEvent{}, -1, err
}
return events, count, reqErr
}