-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathevents_addon.go
158 lines (131 loc) · 4 KB
/
events_addon.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
package scalingo
import "fmt"
type EventAddon struct {
AddonProviderName string `json:"addon_provider_name"`
PlanName string `json:"plan_name"`
ResourceID string `json:"resource_id"`
}
type EventNewAddonTypeData struct {
EventAddon
}
type EventNewAddonType struct {
Event
TypeData EventNewAddonTypeData `json:"type_data"`
}
func (ev *EventNewAddonType) String() string {
return fmt.Sprintf(
"'%s' (%s) has been added (plan '%s')",
ev.TypeData.ResourceID, ev.TypeData.AddonProviderName, ev.TypeData.PlanName,
)
}
type EventUpgradeAddonTypeData struct {
EventAddon
OldPlanName string `json:"old_plan_name"`
NewPlanName string `json:"new_plan_name"`
}
type EventUpgradeAddonType struct {
Event
TypeData EventUpgradeAddonTypeData `json:"type_data"`
}
func (ev *EventUpgradeAddonType) String() string {
return fmt.Sprintf(
"'%s' (%s) plan has been changed from '%s' to '%s'",
ev.TypeData.ResourceID, ev.TypeData.AddonProviderName, ev.TypeData.OldPlanName, ev.TypeData.NewPlanName,
)
}
type EventAddonUpdatedTypeData struct {
AddonID string `json:"addon_id"`
AddonPlanName string `json:"addon_plan_name"`
AddonResourceID string `json:"addon_resource_id"`
AddonProviderID string `json:"addon_provider_id"`
AddonProviderName string `json:"addon_provider_name"`
// Status has only two items when is updated, the old value and the new value, in this order
Status []AddonStatus `json:"status"`
// AttributesChanged contain names of changed attributes
AttributesChanged []string `json:"attributes_changed"`
}
type EventAddonUpdatedType struct {
Event
TypeData EventAddonUpdatedTypeData `json:"type_data"`
}
func (ev *EventAddonUpdatedType) String() string {
d := ev.TypeData
return fmt.Sprintf(
"Addon %s %s updated, status %v -> %v",
d.AddonProviderName, d.AddonResourceID, d.Status[0], d.Status[1],
)
}
type EventDeleteAddonTypeData struct {
EventAddon
}
type EventDeleteAddonType struct {
Event
TypeData EventDeleteAddonTypeData `json:"type_data"`
}
func (ev *EventDeleteAddonType) String() string {
return fmt.Sprintf(
"'%s' (%s) plan has been deleted",
ev.TypeData.ResourceID, ev.TypeData.AddonProviderName,
)
}
type EventResumeAddonTypeData struct {
EventAddon
}
type EventResumeAddonType struct {
Event
TypeData EventResumeAddonTypeData `json:"type_data"`
}
func (ev *EventResumeAddonType) String() string {
return fmt.Sprintf(
"'%s' (%s) has been resumed",
ev.TypeData.ResourceID, ev.TypeData.AddonProviderName,
)
}
type EventSuspendAddonTypeData struct {
EventAddon
Reason string `json:"reason"`
}
type EventSuspendAddonType struct {
Event
TypeData EventSuspendAddonTypeData `json:"type_data"`
}
func (ev *EventSuspendAddonType) String() string {
return fmt.Sprintf(
"'%s' (%s) has been suspended (reason: %s)",
ev.TypeData.ResourceID, ev.TypeData.AddonProviderName, ev.TypeData.Reason,
)
}
type EventDatabaseAddFeatureType struct {
Event
TypeData EventDatabaseAddFeatureTypeData `json:"type_data"`
}
type EventDatabaseAddFeatureTypeData struct {
Feature string `json:"feature"`
AddonProviderID string `json:"addon_provider_id"`
AddonProviderName string `json:"addon_provider_name"`
AddonUUID string `json:"addon_uuid"`
EventSecurityTypeData
}
func (ev *EventDatabaseAddFeatureType) String() string {
return fmt.Sprintf(
"Feature %s enabled for addon '%s' (%s) ",
ev.TypeData.Feature, ev.TypeData.AddonUUID, ev.TypeData.AddonProviderName,
)
}
type EventDatabaseRemoveFeatureType struct {
Event
TypeData EventDatabaseRemoveFeatureTypeData `json:"type_data"`
}
type EventDatabaseRemoveFeatureTypeData struct {
Feature string `json:"feature"`
AddonProviderID string `json:"addon_provider_id"`
AddonProviderName string `json:"addon_provider_name"`
AddonUUID string `json:"addon_uuid"`
EventSecurityTypeData
}
func (ev *EventDatabaseRemoveFeatureType) String() string {
return fmt.Sprintf(
"Feature %s disabled for addon '%s' (%s) ",
ev.TypeData.Feature, ev.TypeData.AddonUUID, ev.TypeData.AddonProviderName,
)
}