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 "encoding/json"
27
28 "github.com/go-openapi/errors"
29 "github.com/go-openapi/strfmt"
30 "github.com/go-openapi/swag"
31 "github.com/go-openapi/validate"
32 )
33
34
35
36
37
38
39 type RekordV001Schema struct {
40
41
42
43 Data *RekordV001SchemaData `json:"data"`
44
45
46
47 Signature *RekordV001SchemaSignature `json:"signature"`
48 }
49
50
51 func (m *RekordV001Schema) Validate(formats strfmt.Registry) error {
52 var res []error
53
54 if err := m.validateData(formats); err != nil {
55 res = append(res, err)
56 }
57
58 if err := m.validateSignature(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 *RekordV001Schema) validateData(formats strfmt.Registry) error {
69
70 if err := validate.Required("data", "body", m.Data); err != nil {
71 return err
72 }
73
74 if m.Data != nil {
75 if err := m.Data.Validate(formats); err != nil {
76 if ve, ok := err.(*errors.Validation); ok {
77 return ve.ValidateName("data")
78 } else if ce, ok := err.(*errors.CompositeError); ok {
79 return ce.ValidateName("data")
80 }
81 return err
82 }
83 }
84
85 return nil
86 }
87
88 func (m *RekordV001Schema) validateSignature(formats strfmt.Registry) error {
89
90 if err := validate.Required("signature", "body", m.Signature); err != nil {
91 return err
92 }
93
94 if m.Signature != nil {
95 if err := m.Signature.Validate(formats); err != nil {
96 if ve, ok := err.(*errors.Validation); ok {
97 return ve.ValidateName("signature")
98 } else if ce, ok := err.(*errors.CompositeError); ok {
99 return ce.ValidateName("signature")
100 }
101 return err
102 }
103 }
104
105 return nil
106 }
107
108
109 func (m *RekordV001Schema) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
110 var res []error
111
112 if err := m.contextValidateData(ctx, formats); err != nil {
113 res = append(res, err)
114 }
115
116 if err := m.contextValidateSignature(ctx, formats); err != nil {
117 res = append(res, err)
118 }
119
120 if len(res) > 0 {
121 return errors.CompositeValidationError(res...)
122 }
123 return nil
124 }
125
126 func (m *RekordV001Schema) contextValidateData(ctx context.Context, formats strfmt.Registry) error {
127
128 if m.Data != nil {
129
130 if err := m.Data.ContextValidate(ctx, formats); err != nil {
131 if ve, ok := err.(*errors.Validation); ok {
132 return ve.ValidateName("data")
133 } else if ce, ok := err.(*errors.CompositeError); ok {
134 return ce.ValidateName("data")
135 }
136 return err
137 }
138 }
139
140 return nil
141 }
142
143 func (m *RekordV001Schema) contextValidateSignature(ctx context.Context, formats strfmt.Registry) error {
144
145 if m.Signature != nil {
146
147 if err := m.Signature.ContextValidate(ctx, formats); err != nil {
148 if ve, ok := err.(*errors.Validation); ok {
149 return ve.ValidateName("signature")
150 } else if ce, ok := err.(*errors.CompositeError); ok {
151 return ce.ValidateName("signature")
152 }
153 return err
154 }
155 }
156
157 return nil
158 }
159
160
161 func (m *RekordV001Schema) MarshalBinary() ([]byte, error) {
162 if m == nil {
163 return nil, nil
164 }
165 return swag.WriteJSON(m)
166 }
167
168
169 func (m *RekordV001Schema) UnmarshalBinary(b []byte) error {
170 var res RekordV001Schema
171 if err := swag.ReadJSON(b, &res); err != nil {
172 return err
173 }
174 *m = res
175 return nil
176 }
177
178
179
180
181 type RekordV001SchemaData struct {
182
183
184
185 Content strfmt.Base64 `json:"content,omitempty"`
186
187
188 Hash *RekordV001SchemaDataHash `json:"hash,omitempty"`
189 }
190
191
192 func (m *RekordV001SchemaData) Validate(formats strfmt.Registry) error {
193 var res []error
194
195 if err := m.validateHash(formats); err != nil {
196 res = append(res, err)
197 }
198
199 if len(res) > 0 {
200 return errors.CompositeValidationError(res...)
201 }
202 return nil
203 }
204
205 func (m *RekordV001SchemaData) validateHash(formats strfmt.Registry) error {
206 if swag.IsZero(m.Hash) {
207 return nil
208 }
209
210 if m.Hash != nil {
211 if err := m.Hash.Validate(formats); err != nil {
212 if ve, ok := err.(*errors.Validation); ok {
213 return ve.ValidateName("data" + "." + "hash")
214 } else if ce, ok := err.(*errors.CompositeError); ok {
215 return ce.ValidateName("data" + "." + "hash")
216 }
217 return err
218 }
219 }
220
221 return nil
222 }
223
224
225 func (m *RekordV001SchemaData) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
226 var res []error
227
228 if err := m.contextValidateHash(ctx, formats); err != nil {
229 res = append(res, err)
230 }
231
232 if len(res) > 0 {
233 return errors.CompositeValidationError(res...)
234 }
235 return nil
236 }
237
238 func (m *RekordV001SchemaData) contextValidateHash(ctx context.Context, formats strfmt.Registry) error {
239
240 if m.Hash != nil {
241
242 if swag.IsZero(m.Hash) {
243 return nil
244 }
245
246 if err := m.Hash.ContextValidate(ctx, formats); err != nil {
247 if ve, ok := err.(*errors.Validation); ok {
248 return ve.ValidateName("data" + "." + "hash")
249 } else if ce, ok := err.(*errors.CompositeError); ok {
250 return ce.ValidateName("data" + "." + "hash")
251 }
252 return err
253 }
254 }
255
256 return nil
257 }
258
259
260 func (m *RekordV001SchemaData) MarshalBinary() ([]byte, error) {
261 if m == nil {
262 return nil, nil
263 }
264 return swag.WriteJSON(m)
265 }
266
267
268 func (m *RekordV001SchemaData) UnmarshalBinary(b []byte) error {
269 var res RekordV001SchemaData
270 if err := swag.ReadJSON(b, &res); err != nil {
271 return err
272 }
273 *m = res
274 return nil
275 }
276
277
278
279
280 type RekordV001SchemaDataHash struct {
281
282
283
284
285 Algorithm *string `json:"algorithm"`
286
287
288
289 Value *string `json:"value"`
290 }
291
292
293 func (m *RekordV001SchemaDataHash) Validate(formats strfmt.Registry) error {
294 var res []error
295
296 if err := m.validateAlgorithm(formats); err != nil {
297 res = append(res, err)
298 }
299
300 if err := m.validateValue(formats); err != nil {
301 res = append(res, err)
302 }
303
304 if len(res) > 0 {
305 return errors.CompositeValidationError(res...)
306 }
307 return nil
308 }
309
310 var rekordV001SchemaDataHashTypeAlgorithmPropEnum []interface{}
311
312 func init() {
313 var res []string
314 if err := json.Unmarshal([]byte(`["sha256"]`), &res); err != nil {
315 panic(err)
316 }
317 for _, v := range res {
318 rekordV001SchemaDataHashTypeAlgorithmPropEnum = append(rekordV001SchemaDataHashTypeAlgorithmPropEnum, v)
319 }
320 }
321
322 const (
323
324
325 RekordV001SchemaDataHashAlgorithmSha256 string = "sha256"
326 )
327
328
329 func (m *RekordV001SchemaDataHash) validateAlgorithmEnum(path, location string, value string) error {
330 if err := validate.EnumCase(path, location, value, rekordV001SchemaDataHashTypeAlgorithmPropEnum, true); err != nil {
331 return err
332 }
333 return nil
334 }
335
336 func (m *RekordV001SchemaDataHash) validateAlgorithm(formats strfmt.Registry) error {
337
338 if err := validate.Required("data"+"."+"hash"+"."+"algorithm", "body", m.Algorithm); err != nil {
339 return err
340 }
341
342
343 if err := m.validateAlgorithmEnum("data"+"."+"hash"+"."+"algorithm", "body", *m.Algorithm); err != nil {
344 return err
345 }
346
347 return nil
348 }
349
350 func (m *RekordV001SchemaDataHash) validateValue(formats strfmt.Registry) error {
351
352 if err := validate.Required("data"+"."+"hash"+"."+"value", "body", m.Value); err != nil {
353 return err
354 }
355
356 return nil
357 }
358
359
360 func (m *RekordV001SchemaDataHash) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
361 var res []error
362
363 if len(res) > 0 {
364 return errors.CompositeValidationError(res...)
365 }
366 return nil
367 }
368
369
370 func (m *RekordV001SchemaDataHash) MarshalBinary() ([]byte, error) {
371 if m == nil {
372 return nil, nil
373 }
374 return swag.WriteJSON(m)
375 }
376
377
378 func (m *RekordV001SchemaDataHash) UnmarshalBinary(b []byte) error {
379 var res RekordV001SchemaDataHash
380 if err := swag.ReadJSON(b, &res); err != nil {
381 return err
382 }
383 *m = res
384 return nil
385 }
386
387
388
389
390 type RekordV001SchemaSignature struct {
391
392
393
394
395 Content *strfmt.Base64 `json:"content"`
396
397
398
399
400 Format *string `json:"format"`
401
402
403
404 PublicKey *RekordV001SchemaSignaturePublicKey `json:"publicKey"`
405 }
406
407
408 func (m *RekordV001SchemaSignature) Validate(formats strfmt.Registry) error {
409 var res []error
410
411 if err := m.validateContent(formats); err != nil {
412 res = append(res, err)
413 }
414
415 if err := m.validateFormat(formats); err != nil {
416 res = append(res, err)
417 }
418
419 if err := m.validatePublicKey(formats); err != nil {
420 res = append(res, err)
421 }
422
423 if len(res) > 0 {
424 return errors.CompositeValidationError(res...)
425 }
426 return nil
427 }
428
429 func (m *RekordV001SchemaSignature) validateContent(formats strfmt.Registry) error {
430
431 if err := validate.Required("signature"+"."+"content", "body", m.Content); err != nil {
432 return err
433 }
434
435 return nil
436 }
437
438 var rekordV001SchemaSignatureTypeFormatPropEnum []interface{}
439
440 func init() {
441 var res []string
442 if err := json.Unmarshal([]byte(`["pgp","minisign","x509","ssh"]`), &res); err != nil {
443 panic(err)
444 }
445 for _, v := range res {
446 rekordV001SchemaSignatureTypeFormatPropEnum = append(rekordV001SchemaSignatureTypeFormatPropEnum, v)
447 }
448 }
449
450 const (
451
452
453 RekordV001SchemaSignatureFormatPgp string = "pgp"
454
455
456 RekordV001SchemaSignatureFormatMinisign string = "minisign"
457
458
459 RekordV001SchemaSignatureFormatX509 string = "x509"
460
461
462 RekordV001SchemaSignatureFormatSSH string = "ssh"
463 )
464
465
466 func (m *RekordV001SchemaSignature) validateFormatEnum(path, location string, value string) error {
467 if err := validate.EnumCase(path, location, value, rekordV001SchemaSignatureTypeFormatPropEnum, true); err != nil {
468 return err
469 }
470 return nil
471 }
472
473 func (m *RekordV001SchemaSignature) validateFormat(formats strfmt.Registry) error {
474
475 if err := validate.Required("signature"+"."+"format", "body", m.Format); err != nil {
476 return err
477 }
478
479
480 if err := m.validateFormatEnum("signature"+"."+"format", "body", *m.Format); err != nil {
481 return err
482 }
483
484 return nil
485 }
486
487 func (m *RekordV001SchemaSignature) validatePublicKey(formats strfmt.Registry) error {
488
489 if err := validate.Required("signature"+"."+"publicKey", "body", m.PublicKey); err != nil {
490 return err
491 }
492
493 if m.PublicKey != nil {
494 if err := m.PublicKey.Validate(formats); err != nil {
495 if ve, ok := err.(*errors.Validation); ok {
496 return ve.ValidateName("signature" + "." + "publicKey")
497 } else if ce, ok := err.(*errors.CompositeError); ok {
498 return ce.ValidateName("signature" + "." + "publicKey")
499 }
500 return err
501 }
502 }
503
504 return nil
505 }
506
507
508 func (m *RekordV001SchemaSignature) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
509 var res []error
510
511 if err := m.contextValidatePublicKey(ctx, formats); err != nil {
512 res = append(res, err)
513 }
514
515 if len(res) > 0 {
516 return errors.CompositeValidationError(res...)
517 }
518 return nil
519 }
520
521 func (m *RekordV001SchemaSignature) contextValidatePublicKey(ctx context.Context, formats strfmt.Registry) error {
522
523 if m.PublicKey != nil {
524
525 if err := m.PublicKey.ContextValidate(ctx, formats); err != nil {
526 if ve, ok := err.(*errors.Validation); ok {
527 return ve.ValidateName("signature" + "." + "publicKey")
528 } else if ce, ok := err.(*errors.CompositeError); ok {
529 return ce.ValidateName("signature" + "." + "publicKey")
530 }
531 return err
532 }
533 }
534
535 return nil
536 }
537
538
539 func (m *RekordV001SchemaSignature) MarshalBinary() ([]byte, error) {
540 if m == nil {
541 return nil, nil
542 }
543 return swag.WriteJSON(m)
544 }
545
546
547 func (m *RekordV001SchemaSignature) UnmarshalBinary(b []byte) error {
548 var res RekordV001SchemaSignature
549 if err := swag.ReadJSON(b, &res); err != nil {
550 return err
551 }
552 *m = res
553 return nil
554 }
555
556
557
558
559 type RekordV001SchemaSignaturePublicKey struct {
560
561
562
563
564 Content *strfmt.Base64 `json:"content"`
565 }
566
567
568 func (m *RekordV001SchemaSignaturePublicKey) Validate(formats strfmt.Registry) error {
569 var res []error
570
571 if err := m.validateContent(formats); err != nil {
572 res = append(res, err)
573 }
574
575 if len(res) > 0 {
576 return errors.CompositeValidationError(res...)
577 }
578 return nil
579 }
580
581 func (m *RekordV001SchemaSignaturePublicKey) validateContent(formats strfmt.Registry) error {
582
583 if err := validate.Required("signature"+"."+"publicKey"+"."+"content", "body", m.Content); err != nil {
584 return err
585 }
586
587 return nil
588 }
589
590
591 func (m *RekordV001SchemaSignaturePublicKey) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
592 return nil
593 }
594
595
596 func (m *RekordV001SchemaSignaturePublicKey) MarshalBinary() ([]byte, error) {
597 if m == nil {
598 return nil, nil
599 }
600 return swag.WriteJSON(m)
601 }
602
603
604 func (m *RekordV001SchemaSignaturePublicKey) UnmarshalBinary(b []byte) error {
605 var res RekordV001SchemaSignaturePublicKey
606 if err := swag.ReadJSON(b, &res); err != nil {
607 return err
608 }
609 *m = res
610 return nil
611 }
612
View as plain text