...
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 "strconv"
26
27 "github.com/go-openapi/errors"
28 "github.com/go-openapi/strfmt"
29 "github.com/go-openapi/swag"
30 "github.com/go-openapi/validate"
31 )
32
33
34
35
36 type ClusterStatus struct {
37
38
39 Name string `json:"name,omitempty"`
40
41
42 Peers []*PeerStatus `json:"peers"`
43
44
45
46
47 Status *string `json:"status"`
48 }
49
50
51 func (m *ClusterStatus) Validate(formats strfmt.Registry) error {
52 var res []error
53
54 if err := m.validatePeers(formats); err != nil {
55 res = append(res, err)
56 }
57
58 if err := m.validateStatus(formats); err != nil {
59 res = append(res, err)
60 }
61
62 if len(res) > 0 {
63 return errors.CompositeValidationError(res...)
64 }
65 return nil
66 }
67
68 func (m *ClusterStatus) validatePeers(formats strfmt.Registry) error {
69 if swag.IsZero(m.Peers) {
70 return nil
71 }
72
73 for i := 0; i < len(m.Peers); i++ {
74 if swag.IsZero(m.Peers[i]) {
75 continue
76 }
77
78 if m.Peers[i] != nil {
79 if err := m.Peers[i].Validate(formats); err != nil {
80 if ve, ok := err.(*errors.Validation); ok {
81 return ve.ValidateName("peers" + "." + strconv.Itoa(i))
82 } else if ce, ok := err.(*errors.CompositeError); ok {
83 return ce.ValidateName("peers" + "." + strconv.Itoa(i))
84 }
85 return err
86 }
87 }
88
89 }
90
91 return nil
92 }
93
94 var clusterStatusTypeStatusPropEnum []interface{}
95
96 func init() {
97 var res []string
98 if err := json.Unmarshal([]byte(`["ready","settling","disabled"]`), &res); err != nil {
99 panic(err)
100 }
101 for _, v := range res {
102 clusterStatusTypeStatusPropEnum = append(clusterStatusTypeStatusPropEnum, v)
103 }
104 }
105
106 const (
107
108
109 ClusterStatusStatusReady string = "ready"
110
111
112 ClusterStatusStatusSettling string = "settling"
113
114
115 ClusterStatusStatusDisabled string = "disabled"
116 )
117
118
119 func (m *ClusterStatus) validateStatusEnum(path, location string, value string) error {
120 if err := validate.EnumCase(path, location, value, clusterStatusTypeStatusPropEnum, true); err != nil {
121 return err
122 }
123 return nil
124 }
125
126 func (m *ClusterStatus) validateStatus(formats strfmt.Registry) error {
127
128 if err := validate.Required("status", "body", m.Status); err != nil {
129 return err
130 }
131
132
133 if err := m.validateStatusEnum("status", "body", *m.Status); err != nil {
134 return err
135 }
136
137 return nil
138 }
139
140
141 func (m *ClusterStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
142 var res []error
143
144 if err := m.contextValidatePeers(ctx, formats); err != nil {
145 res = append(res, err)
146 }
147
148 if len(res) > 0 {
149 return errors.CompositeValidationError(res...)
150 }
151 return nil
152 }
153
154 func (m *ClusterStatus) contextValidatePeers(ctx context.Context, formats strfmt.Registry) error {
155
156 for i := 0; i < len(m.Peers); i++ {
157
158 if m.Peers[i] != nil {
159 if err := m.Peers[i].ContextValidate(ctx, formats); err != nil {
160 if ve, ok := err.(*errors.Validation); ok {
161 return ve.ValidateName("peers" + "." + strconv.Itoa(i))
162 } else if ce, ok := err.(*errors.CompositeError); ok {
163 return ce.ValidateName("peers" + "." + strconv.Itoa(i))
164 }
165 return err
166 }
167 }
168
169 }
170
171 return nil
172 }
173
174
175 func (m *ClusterStatus) MarshalBinary() ([]byte, error) {
176 if m == nil {
177 return nil, nil
178 }
179 return swag.WriteJSON(m)
180 }
181
182
183 func (m *ClusterStatus) UnmarshalBinary(b []byte) error {
184 var res ClusterStatus
185 if err := swag.ReadJSON(b, &res); err != nil {
186 return err
187 }
188 *m = res
189 return nil
190 }
191
View as plain text