1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package models
20
21
22
23
24 import (
25 "context"
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 LogEntry map[string]LogEntryAnon
37
38
39 func (m LogEntry) Validate(formats strfmt.Registry) error {
40 var res []error
41
42 for k := range m {
43
44 if swag.IsZero(m[k]) {
45 continue
46 }
47 if val, ok := m[k]; ok {
48 if err := val.Validate(formats); err != nil {
49 if ve, ok := err.(*errors.Validation); ok {
50 return ve.ValidateName(k)
51 } else if ce, ok := err.(*errors.CompositeError); ok {
52 return ce.ValidateName(k)
53 }
54 return err
55 }
56 }
57
58 }
59
60 if len(res) > 0 {
61 return errors.CompositeValidationError(res...)
62 }
63 return nil
64 }
65
66
67 func (m LogEntry) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
68 var res []error
69
70 for k := range m {
71
72 if val, ok := m[k]; ok {
73 if err := val.ContextValidate(ctx, formats); err != nil {
74 return err
75 }
76 }
77
78 }
79
80 if len(res) > 0 {
81 return errors.CompositeValidationError(res...)
82 }
83 return nil
84 }
85
86
87
88
89 type LogEntryAnon struct {
90
91
92 Attestation *LogEntryAnonAttestation `json:"attestation,omitempty"`
93
94
95
96 Body interface{} `json:"body"`
97
98
99
100 IntegratedTime *int64 `json:"integratedTime"`
101
102
103
104
105 LogID *string `json:"logID"`
106
107
108
109
110 LogIndex *int64 `json:"logIndex"`
111
112
113 Verification *LogEntryAnonVerification `json:"verification,omitempty"`
114 }
115
116
117 func (m *LogEntryAnon) Validate(formats strfmt.Registry) error {
118 var res []error
119
120 if err := m.validateAttestation(formats); err != nil {
121 res = append(res, err)
122 }
123
124 if err := m.validateBody(formats); err != nil {
125 res = append(res, err)
126 }
127
128 if err := m.validateIntegratedTime(formats); err != nil {
129 res = append(res, err)
130 }
131
132 if err := m.validateLogID(formats); err != nil {
133 res = append(res, err)
134 }
135
136 if err := m.validateLogIndex(formats); err != nil {
137 res = append(res, err)
138 }
139
140 if err := m.validateVerification(formats); err != nil {
141 res = append(res, err)
142 }
143
144 if len(res) > 0 {
145 return errors.CompositeValidationError(res...)
146 }
147 return nil
148 }
149
150 func (m *LogEntryAnon) validateAttestation(formats strfmt.Registry) error {
151 if swag.IsZero(m.Attestation) {
152 return nil
153 }
154
155 if m.Attestation != nil {
156 if err := m.Attestation.Validate(formats); err != nil {
157 if ve, ok := err.(*errors.Validation); ok {
158 return ve.ValidateName("attestation")
159 } else if ce, ok := err.(*errors.CompositeError); ok {
160 return ce.ValidateName("attestation")
161 }
162 return err
163 }
164 }
165
166 return nil
167 }
168
169 func (m *LogEntryAnon) validateBody(formats strfmt.Registry) error {
170
171 if m.Body == nil {
172 return errors.Required("body", "body", nil)
173 }
174
175 return nil
176 }
177
178 func (m *LogEntryAnon) validateIntegratedTime(formats strfmt.Registry) error {
179
180 if err := validate.Required("integratedTime", "body", m.IntegratedTime); err != nil {
181 return err
182 }
183
184 return nil
185 }
186
187 func (m *LogEntryAnon) validateLogID(formats strfmt.Registry) error {
188
189 if err := validate.Required("logID", "body", m.LogID); err != nil {
190 return err
191 }
192
193 if err := validate.Pattern("logID", "body", *m.LogID, `^[0-9a-fA-F]{64}$`); err != nil {
194 return err
195 }
196
197 return nil
198 }
199
200 func (m *LogEntryAnon) validateLogIndex(formats strfmt.Registry) error {
201
202 if err := validate.Required("logIndex", "body", m.LogIndex); err != nil {
203 return err
204 }
205
206 if err := validate.MinimumInt("logIndex", "body", *m.LogIndex, 0, false); err != nil {
207 return err
208 }
209
210 return nil
211 }
212
213 func (m *LogEntryAnon) validateVerification(formats strfmt.Registry) error {
214 if swag.IsZero(m.Verification) {
215 return nil
216 }
217
218 if m.Verification != nil {
219 if err := m.Verification.Validate(formats); err != nil {
220 if ve, ok := err.(*errors.Validation); ok {
221 return ve.ValidateName("verification")
222 } else if ce, ok := err.(*errors.CompositeError); ok {
223 return ce.ValidateName("verification")
224 }
225 return err
226 }
227 }
228
229 return nil
230 }
231
232
233 func (m *LogEntryAnon) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
234 var res []error
235
236 if err := m.contextValidateAttestation(ctx, formats); err != nil {
237 res = append(res, err)
238 }
239
240 if err := m.contextValidateVerification(ctx, formats); err != nil {
241 res = append(res, err)
242 }
243
244 if len(res) > 0 {
245 return errors.CompositeValidationError(res...)
246 }
247 return nil
248 }
249
250 func (m *LogEntryAnon) contextValidateAttestation(ctx context.Context, formats strfmt.Registry) error {
251
252 if m.Attestation != nil {
253
254 if swag.IsZero(m.Attestation) {
255 return nil
256 }
257
258 if err := m.Attestation.ContextValidate(ctx, formats); err != nil {
259 if ve, ok := err.(*errors.Validation); ok {
260 return ve.ValidateName("attestation")
261 } else if ce, ok := err.(*errors.CompositeError); ok {
262 return ce.ValidateName("attestation")
263 }
264 return err
265 }
266 }
267
268 return nil
269 }
270
271 func (m *LogEntryAnon) contextValidateVerification(ctx context.Context, formats strfmt.Registry) error {
272
273 if m.Verification != nil {
274
275 if swag.IsZero(m.Verification) {
276 return nil
277 }
278
279 if err := m.Verification.ContextValidate(ctx, formats); err != nil {
280 if ve, ok := err.(*errors.Validation); ok {
281 return ve.ValidateName("verification")
282 } else if ce, ok := err.(*errors.CompositeError); ok {
283 return ce.ValidateName("verification")
284 }
285 return err
286 }
287 }
288
289 return nil
290 }
291
292
293 func (m *LogEntryAnon) MarshalBinary() ([]byte, error) {
294 if m == nil {
295 return nil, nil
296 }
297 return swag.WriteJSON(m)
298 }
299
300
301 func (m *LogEntryAnon) UnmarshalBinary(b []byte) error {
302 var res LogEntryAnon
303 if err := swag.ReadJSON(b, &res); err != nil {
304 return err
305 }
306 *m = res
307 return nil
308 }
309
310
311
312
313 type LogEntryAnonAttestation struct {
314
315
316
317 Data strfmt.Base64 `json:"data,omitempty"`
318 }
319
320
321 func (m *LogEntryAnonAttestation) Validate(formats strfmt.Registry) error {
322 return nil
323 }
324
325
326 func (m *LogEntryAnonAttestation) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
327 return nil
328 }
329
330
331 func (m *LogEntryAnonAttestation) MarshalBinary() ([]byte, error) {
332 if m == nil {
333 return nil, nil
334 }
335 return swag.WriteJSON(m)
336 }
337
338
339 func (m *LogEntryAnonAttestation) UnmarshalBinary(b []byte) error {
340 var res LogEntryAnonAttestation
341 if err := swag.ReadJSON(b, &res); err != nil {
342 return err
343 }
344 *m = res
345 return nil
346 }
347
348
349
350
351 type LogEntryAnonVerification struct {
352
353
354 InclusionProof *InclusionProof `json:"inclusionProof,omitempty"`
355
356
357
358 SignedEntryTimestamp strfmt.Base64 `json:"signedEntryTimestamp,omitempty"`
359 }
360
361
362 func (m *LogEntryAnonVerification) Validate(formats strfmt.Registry) error {
363 var res []error
364
365 if err := m.validateInclusionProof(formats); err != nil {
366 res = append(res, err)
367 }
368
369 if len(res) > 0 {
370 return errors.CompositeValidationError(res...)
371 }
372 return nil
373 }
374
375 func (m *LogEntryAnonVerification) validateInclusionProof(formats strfmt.Registry) error {
376 if swag.IsZero(m.InclusionProof) {
377 return nil
378 }
379
380 if m.InclusionProof != nil {
381 if err := m.InclusionProof.Validate(formats); err != nil {
382 if ve, ok := err.(*errors.Validation); ok {
383 return ve.ValidateName("verification" + "." + "inclusionProof")
384 } else if ce, ok := err.(*errors.CompositeError); ok {
385 return ce.ValidateName("verification" + "." + "inclusionProof")
386 }
387 return err
388 }
389 }
390
391 return nil
392 }
393
394
395 func (m *LogEntryAnonVerification) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
396 var res []error
397
398 if err := m.contextValidateInclusionProof(ctx, formats); err != nil {
399 res = append(res, err)
400 }
401
402 if len(res) > 0 {
403 return errors.CompositeValidationError(res...)
404 }
405 return nil
406 }
407
408 func (m *LogEntryAnonVerification) contextValidateInclusionProof(ctx context.Context, formats strfmt.Registry) error {
409
410 if m.InclusionProof != nil {
411
412 if swag.IsZero(m.InclusionProof) {
413 return nil
414 }
415
416 if err := m.InclusionProof.ContextValidate(ctx, formats); err != nil {
417 if ve, ok := err.(*errors.Validation); ok {
418 return ve.ValidateName("verification" + "." + "inclusionProof")
419 } else if ce, ok := err.(*errors.CompositeError); ok {
420 return ce.ValidateName("verification" + "." + "inclusionProof")
421 }
422 return err
423 }
424 }
425
426 return nil
427 }
428
429
430 func (m *LogEntryAnonVerification) MarshalBinary() ([]byte, error) {
431 if m == nil {
432 return nil, nil
433 }
434 return swag.WriteJSON(m)
435 }
436
437
438 func (m *LogEntryAnonVerification) UnmarshalBinary(b []byte) error {
439 var res LogEntryAnonVerification
440 if err := swag.ReadJSON(b, &res); err != nil {
441 return err
442 }
443 *m = res
444 return nil
445 }
446
View as plain text