...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package models
18
19
20
21
22 import (
23 "context"
24 "encoding/json"
25
26 "github.com/go-openapi/errors"
27 "github.com/go-openapi/strfmt"
28 "github.com/go-openapi/swag"
29 "github.com/go-openapi/validate"
30 )
31
32
33
34
35 type SilenceStatus struct {
36
37
38
39
40 State *string `json:"state"`
41 }
42
43
44 func (m *SilenceStatus) Validate(formats strfmt.Registry) error {
45 var res []error
46
47 if err := m.validateState(formats); err != nil {
48 res = append(res, err)
49 }
50
51 if len(res) > 0 {
52 return errors.CompositeValidationError(res...)
53 }
54 return nil
55 }
56
57 var silenceStatusTypeStatePropEnum []interface{}
58
59 func init() {
60 var res []string
61 if err := json.Unmarshal([]byte(`["expired","active","pending"]`), &res); err != nil {
62 panic(err)
63 }
64 for _, v := range res {
65 silenceStatusTypeStatePropEnum = append(silenceStatusTypeStatePropEnum, v)
66 }
67 }
68
69 const (
70
71
72 SilenceStatusStateExpired string = "expired"
73
74
75 SilenceStatusStateActive string = "active"
76
77
78 SilenceStatusStatePending string = "pending"
79 )
80
81
82 func (m *SilenceStatus) validateStateEnum(path, location string, value string) error {
83 if err := validate.EnumCase(path, location, value, silenceStatusTypeStatePropEnum, true); err != nil {
84 return err
85 }
86 return nil
87 }
88
89 func (m *SilenceStatus) validateState(formats strfmt.Registry) error {
90
91 if err := validate.Required("state", "body", m.State); err != nil {
92 return err
93 }
94
95
96 if err := m.validateStateEnum("state", "body", *m.State); err != nil {
97 return err
98 }
99
100 return nil
101 }
102
103
104 func (m *SilenceStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
105 return nil
106 }
107
108
109 func (m *SilenceStatus) MarshalBinary() ([]byte, error) {
110 if m == nil {
111 return nil, nil
112 }
113 return swag.WriteJSON(m)
114 }
115
116
117 func (m *SilenceStatus) UnmarshalBinary(b []byte) error {
118 var res SilenceStatus
119 if err := swag.ReadJSON(b, &res); err != nil {
120 return err
121 }
122 *m = res
123 return nil
124 }
125
View as plain text