-
Notifications
You must be signed in to change notification settings - Fork 8
/
events_types.go
52 lines (41 loc) · 1.17 KB
/
events_types.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 scalingo
import (
"context"
"gopkg.in/errgo.v1"
"github.com/Scalingo/go-scalingo/v7/http"
)
type EventCategory struct {
ID string `json:"id"`
Name string `json:"name"`
Position int `json:"position"`
}
type EventType struct {
ID string `json:"id"`
CategoryID string `json:"category_id"`
Name string `json:"name"`
DisplayName string `json:"display_name"`
Description string `json:"description"`
Template string `json:"template"`
}
func (c *Client) EventTypesList(ctx context.Context) ([]EventType, error) {
req := &http.APIRequest{
Endpoint: "/event_types",
}
var res map[string][]EventType
err := c.ScalingoAPI().DoRequest(ctx, req, &res)
if err != nil {
return nil, errgo.Notef(err, "fail to make request to Scalingo API")
}
return res["event_types"], nil
}
func (c *Client) EventCategoriesList(ctx context.Context) ([]EventCategory, error) {
req := &http.APIRequest{
Endpoint: "/event_categories",
}
var res map[string][]EventCategory
err := c.ScalingoAPI().DoRequest(ctx, req, &res)
if err != nil {
return nil, errgo.Notef(err, "fail to make request to Scalingo API")
}
return res["event_categories"], nil
}