-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcomponent.go
65 lines (55 loc) · 1.7 KB
/
component.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
package statuspage
type Component struct {
Name *string `json:"name"`
Description *string `json:"description,omitempty"`
GroupID *string `json:"group_id,omitempty"`
Showcase *bool `json:"showcase,omitempty"`
Status *string `json:"status,omitempty"`
OnlyShowIfDegraded *bool `json:"only_show_if_degraded,omitempty"`
StartDate *string `json:"start_date,omitempty"`
}
type ComponentFull struct {
Component
ID *string `json:"id"`
PageID *string `json:"page_id"`
Position *int32 `json:"position"`
CreatedAt *string `json:"created_at"`
UpdatedAt *string `json:"updated_at"`
AutomationEmail *string `json:"automation_email"`
StartDate *string `json:"start_date,omitempty"`
}
func CreateComponent(client *Client, pageID string, component *Component) (*ComponentFull, error) {
var c ComponentFull
err := createResource(
client,
pageID,
"component",
struct {
Component *Component `json:"component"`
}{component},
&c,
)
return &c, err
}
func GetComponent(client *Client, pageID string, componentID string) (*ComponentFull, error) {
var c ComponentFull
err := readResource(client, pageID, componentID, "component", &c)
return &c, err
}
func UpdateComponent(client *Client, pageID, componentID string, component *Component) (*ComponentFull, error) {
var c ComponentFull
err := updateResource(
client,
pageID,
"component",
componentID,
struct {
Component *Component `json:"component"`
}{component},
&c,
)
return &c, err
}
func DeleteComponent(client *Client, pageID, componentID string) (err error) {
return deleteResource(client, pageID, "component", componentID)
}