forked from keel-hq/keel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotification_jsonenums.go
77 lines (70 loc) · 3.15 KB
/
notification_jsonenums.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
// generated by jsonenums -type=Notification; DO NOT EDIT
package types
import (
"encoding/json"
"fmt"
)
var (
_NotificationNameToValue = map[string]Notification{
"PreProviderSubmitNotification": PreProviderSubmitNotification,
"PostProviderSubmitNotification": PostProviderSubmitNotification,
"NotificationPreDeploymentUpdate": NotificationPreDeploymentUpdate,
"NotificationDeploymentUpdate": NotificationDeploymentUpdate,
"NotificationPreReleaseUpdate": NotificationPreReleaseUpdate,
"NotificationReleaseUpdate": NotificationReleaseUpdate,
"NotificationSystemEvent": NotificationSystemEvent,
"NotificationUpdateApproved": NotificationUpdateApproved,
"NotificationUpdateRejected": NotificationUpdateRejected,
}
_NotificationValueToName = map[Notification]string{
PreProviderSubmitNotification: "PreProviderSubmitNotification",
PostProviderSubmitNotification: "PostProviderSubmitNotification",
NotificationPreDeploymentUpdate: "NotificationPreDeploymentUpdate",
NotificationDeploymentUpdate: "NotificationDeploymentUpdate",
NotificationPreReleaseUpdate: "NotificationPreReleaseUpdate",
NotificationReleaseUpdate: "NotificationReleaseUpdate",
NotificationSystemEvent: "NotificationSystemEvent",
NotificationUpdateApproved: "NotificationUpdateApproved",
NotificationUpdateRejected: "NotificationUpdateRejected",
}
)
func init() {
var v Notification
if _, ok := interface{}(v).(fmt.Stringer); ok {
_NotificationNameToValue = map[string]Notification{
interface{}(PreProviderSubmitNotification).(fmt.Stringer).String(): PreProviderSubmitNotification,
interface{}(PostProviderSubmitNotification).(fmt.Stringer).String(): PostProviderSubmitNotification,
interface{}(NotificationPreDeploymentUpdate).(fmt.Stringer).String(): NotificationPreDeploymentUpdate,
interface{}(NotificationDeploymentUpdate).(fmt.Stringer).String(): NotificationDeploymentUpdate,
interface{}(NotificationPreReleaseUpdate).(fmt.Stringer).String(): NotificationPreReleaseUpdate,
interface{}(NotificationReleaseUpdate).(fmt.Stringer).String(): NotificationReleaseUpdate,
interface{}(NotificationSystemEvent).(fmt.Stringer).String(): NotificationSystemEvent,
interface{}(NotificationUpdateApproved).(fmt.Stringer).String(): NotificationUpdateApproved,
interface{}(NotificationUpdateRejected).(fmt.Stringer).String(): NotificationUpdateRejected,
}
}
}
// MarshalJSON is generated so Notification satisfies json.Marshaler.
func (r Notification) MarshalJSON() ([]byte, error) {
if s, ok := interface{}(r).(fmt.Stringer); ok {
return json.Marshal(s.String())
}
s, ok := _NotificationValueToName[r]
if !ok {
return nil, fmt.Errorf("invalid Notification: %d", r)
}
return json.Marshal(s)
}
// UnmarshalJSON is generated so Notification satisfies json.Unmarshaler.
func (r *Notification) UnmarshalJSON(data []byte) error {
var s string
if err := json.Unmarshal(data, &s); err != nil {
return fmt.Errorf("Notification should be a string, got %s", data)
}
v, ok := _NotificationNameToValue[s]
if !ok {
return fmt.Errorf("invalid Notification %q", s)
}
*r = v
return nil
}