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 "strconv"
28
29 "github.com/go-openapi/errors"
30 "github.com/go-openapi/strfmt"
31 "github.com/go-openapi/swag"
32 "github.com/go-openapi/validate"
33 )
34
35
36
37
38
39
40 type IntotoV002Schema struct {
41
42
43
44 Content *IntotoV002SchemaContent `json:"content"`
45 }
46
47
48 func (m *IntotoV002Schema) Validate(formats strfmt.Registry) error {
49 var res []error
50
51 if err := m.validateContent(formats); err != nil {
52 res = append(res, err)
53 }
54
55 if len(res) > 0 {
56 return errors.CompositeValidationError(res...)
57 }
58 return nil
59 }
60
61 func (m *IntotoV002Schema) validateContent(formats strfmt.Registry) error {
62
63 if err := validate.Required("content", "body", m.Content); err != nil {
64 return err
65 }
66
67 if m.Content != nil {
68 if err := m.Content.Validate(formats); err != nil {
69 if ve, ok := err.(*errors.Validation); ok {
70 return ve.ValidateName("content")
71 } else if ce, ok := err.(*errors.CompositeError); ok {
72 return ce.ValidateName("content")
73 }
74 return err
75 }
76 }
77
78 return nil
79 }
80
81
82 func (m *IntotoV002Schema) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
83 var res []error
84
85 if err := m.contextValidateContent(ctx, formats); err != nil {
86 res = append(res, err)
87 }
88
89 if len(res) > 0 {
90 return errors.CompositeValidationError(res...)
91 }
92 return nil
93 }
94
95 func (m *IntotoV002Schema) contextValidateContent(ctx context.Context, formats strfmt.Registry) error {
96
97 if m.Content != nil {
98
99 if err := m.Content.ContextValidate(ctx, formats); err != nil {
100 if ve, ok := err.(*errors.Validation); ok {
101 return ve.ValidateName("content")
102 } else if ce, ok := err.(*errors.CompositeError); ok {
103 return ce.ValidateName("content")
104 }
105 return err
106 }
107 }
108
109 return nil
110 }
111
112
113 func (m *IntotoV002Schema) MarshalBinary() ([]byte, error) {
114 if m == nil {
115 return nil, nil
116 }
117 return swag.WriteJSON(m)
118 }
119
120
121 func (m *IntotoV002Schema) UnmarshalBinary(b []byte) error {
122 var res IntotoV002Schema
123 if err := swag.ReadJSON(b, &res); err != nil {
124 return err
125 }
126 *m = res
127 return nil
128 }
129
130
131
132
133 type IntotoV002SchemaContent struct {
134
135
136
137 Envelope *IntotoV002SchemaContentEnvelope `json:"envelope"`
138
139
140 Hash *IntotoV002SchemaContentHash `json:"hash,omitempty"`
141
142
143 PayloadHash *IntotoV002SchemaContentPayloadHash `json:"payloadHash,omitempty"`
144 }
145
146
147 func (m *IntotoV002SchemaContent) Validate(formats strfmt.Registry) error {
148 var res []error
149
150 if err := m.validateEnvelope(formats); err != nil {
151 res = append(res, err)
152 }
153
154 if err := m.validateHash(formats); err != nil {
155 res = append(res, err)
156 }
157
158 if err := m.validatePayloadHash(formats); err != nil {
159 res = append(res, err)
160 }
161
162 if len(res) > 0 {
163 return errors.CompositeValidationError(res...)
164 }
165 return nil
166 }
167
168 func (m *IntotoV002SchemaContent) validateEnvelope(formats strfmt.Registry) error {
169
170 if err := validate.Required("content"+"."+"envelope", "body", m.Envelope); err != nil {
171 return err
172 }
173
174 if m.Envelope != nil {
175 if err := m.Envelope.Validate(formats); err != nil {
176 if ve, ok := err.(*errors.Validation); ok {
177 return ve.ValidateName("content" + "." + "envelope")
178 } else if ce, ok := err.(*errors.CompositeError); ok {
179 return ce.ValidateName("content" + "." + "envelope")
180 }
181 return err
182 }
183 }
184
185 return nil
186 }
187
188 func (m *IntotoV002SchemaContent) validateHash(formats strfmt.Registry) error {
189 if swag.IsZero(m.Hash) {
190 return nil
191 }
192
193 if m.Hash != nil {
194 if err := m.Hash.Validate(formats); err != nil {
195 if ve, ok := err.(*errors.Validation); ok {
196 return ve.ValidateName("content" + "." + "hash")
197 } else if ce, ok := err.(*errors.CompositeError); ok {
198 return ce.ValidateName("content" + "." + "hash")
199 }
200 return err
201 }
202 }
203
204 return nil
205 }
206
207 func (m *IntotoV002SchemaContent) validatePayloadHash(formats strfmt.Registry) error {
208 if swag.IsZero(m.PayloadHash) {
209 return nil
210 }
211
212 if m.PayloadHash != nil {
213 if err := m.PayloadHash.Validate(formats); err != nil {
214 if ve, ok := err.(*errors.Validation); ok {
215 return ve.ValidateName("content" + "." + "payloadHash")
216 } else if ce, ok := err.(*errors.CompositeError); ok {
217 return ce.ValidateName("content" + "." + "payloadHash")
218 }
219 return err
220 }
221 }
222
223 return nil
224 }
225
226
227 func (m *IntotoV002SchemaContent) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
228 var res []error
229
230 if err := m.contextValidateEnvelope(ctx, formats); err != nil {
231 res = append(res, err)
232 }
233
234 if err := m.contextValidateHash(ctx, formats); err != nil {
235 res = append(res, err)
236 }
237
238 if err := m.contextValidatePayloadHash(ctx, formats); err != nil {
239 res = append(res, err)
240 }
241
242 if len(res) > 0 {
243 return errors.CompositeValidationError(res...)
244 }
245 return nil
246 }
247
248 func (m *IntotoV002SchemaContent) contextValidateEnvelope(ctx context.Context, formats strfmt.Registry) error {
249
250 if m.Envelope != nil {
251
252 if err := m.Envelope.ContextValidate(ctx, formats); err != nil {
253 if ve, ok := err.(*errors.Validation); ok {
254 return ve.ValidateName("content" + "." + "envelope")
255 } else if ce, ok := err.(*errors.CompositeError); ok {
256 return ce.ValidateName("content" + "." + "envelope")
257 }
258 return err
259 }
260 }
261
262 return nil
263 }
264
265 func (m *IntotoV002SchemaContent) contextValidateHash(ctx context.Context, formats strfmt.Registry) error {
266
267 if m.Hash != nil {
268
269 if swag.IsZero(m.Hash) {
270 return nil
271 }
272
273 if err := m.Hash.ContextValidate(ctx, formats); err != nil {
274 if ve, ok := err.(*errors.Validation); ok {
275 return ve.ValidateName("content" + "." + "hash")
276 } else if ce, ok := err.(*errors.CompositeError); ok {
277 return ce.ValidateName("content" + "." + "hash")
278 }
279 return err
280 }
281 }
282
283 return nil
284 }
285
286 func (m *IntotoV002SchemaContent) contextValidatePayloadHash(ctx context.Context, formats strfmt.Registry) error {
287
288 if m.PayloadHash != nil {
289
290 if swag.IsZero(m.PayloadHash) {
291 return nil
292 }
293
294 if err := m.PayloadHash.ContextValidate(ctx, formats); err != nil {
295 if ve, ok := err.(*errors.Validation); ok {
296 return ve.ValidateName("content" + "." + "payloadHash")
297 } else if ce, ok := err.(*errors.CompositeError); ok {
298 return ce.ValidateName("content" + "." + "payloadHash")
299 }
300 return err
301 }
302 }
303
304 return nil
305 }
306
307
308 func (m *IntotoV002SchemaContent) MarshalBinary() ([]byte, error) {
309 if m == nil {
310 return nil, nil
311 }
312 return swag.WriteJSON(m)
313 }
314
315
316 func (m *IntotoV002SchemaContent) UnmarshalBinary(b []byte) error {
317 var res IntotoV002SchemaContent
318 if err := swag.ReadJSON(b, &res); err != nil {
319 return err
320 }
321 *m = res
322 return nil
323 }
324
325
326
327
328 type IntotoV002SchemaContentEnvelope struct {
329
330
331
332 Payload strfmt.Base64 `json:"payload,omitempty"`
333
334
335
336 PayloadType *string `json:"payloadType"`
337
338
339
340
341 Signatures []*IntotoV002SchemaContentEnvelopeSignaturesItems0 `json:"signatures"`
342 }
343
344
345 func (m *IntotoV002SchemaContentEnvelope) Validate(formats strfmt.Registry) error {
346 var res []error
347
348 if err := m.validatePayloadType(formats); err != nil {
349 res = append(res, err)
350 }
351
352 if err := m.validateSignatures(formats); err != nil {
353 res = append(res, err)
354 }
355
356 if len(res) > 0 {
357 return errors.CompositeValidationError(res...)
358 }
359 return nil
360 }
361
362 func (m *IntotoV002SchemaContentEnvelope) validatePayloadType(formats strfmt.Registry) error {
363
364 if err := validate.Required("content"+"."+"envelope"+"."+"payloadType", "body", m.PayloadType); err != nil {
365 return err
366 }
367
368 return nil
369 }
370
371 func (m *IntotoV002SchemaContentEnvelope) validateSignatures(formats strfmt.Registry) error {
372
373 if err := validate.Required("content"+"."+"envelope"+"."+"signatures", "body", m.Signatures); err != nil {
374 return err
375 }
376
377 iSignaturesSize := int64(len(m.Signatures))
378
379 if err := validate.MinItems("content"+"."+"envelope"+"."+"signatures", "body", iSignaturesSize, 1); err != nil {
380 return err
381 }
382
383 for i := 0; i < len(m.Signatures); i++ {
384 if swag.IsZero(m.Signatures[i]) {
385 continue
386 }
387
388 if m.Signatures[i] != nil {
389 if err := m.Signatures[i].Validate(formats); err != nil {
390 if ve, ok := err.(*errors.Validation); ok {
391 return ve.ValidateName("content" + "." + "envelope" + "." + "signatures" + "." + strconv.Itoa(i))
392 } else if ce, ok := err.(*errors.CompositeError); ok {
393 return ce.ValidateName("content" + "." + "envelope" + "." + "signatures" + "." + strconv.Itoa(i))
394 }
395 return err
396 }
397 }
398
399 }
400
401 return nil
402 }
403
404
405 func (m *IntotoV002SchemaContentEnvelope) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
406 var res []error
407
408 if err := m.contextValidateSignatures(ctx, formats); err != nil {
409 res = append(res, err)
410 }
411
412 if len(res) > 0 {
413 return errors.CompositeValidationError(res...)
414 }
415 return nil
416 }
417
418 func (m *IntotoV002SchemaContentEnvelope) contextValidateSignatures(ctx context.Context, formats strfmt.Registry) error {
419
420 for i := 0; i < len(m.Signatures); i++ {
421
422 if m.Signatures[i] != nil {
423
424 if swag.IsZero(m.Signatures[i]) {
425 return nil
426 }
427
428 if err := m.Signatures[i].ContextValidate(ctx, formats); err != nil {
429 if ve, ok := err.(*errors.Validation); ok {
430 return ve.ValidateName("content" + "." + "envelope" + "." + "signatures" + "." + strconv.Itoa(i))
431 } else if ce, ok := err.(*errors.CompositeError); ok {
432 return ce.ValidateName("content" + "." + "envelope" + "." + "signatures" + "." + strconv.Itoa(i))
433 }
434 return err
435 }
436 }
437
438 }
439
440 return nil
441 }
442
443
444 func (m *IntotoV002SchemaContentEnvelope) MarshalBinary() ([]byte, error) {
445 if m == nil {
446 return nil, nil
447 }
448 return swag.WriteJSON(m)
449 }
450
451
452 func (m *IntotoV002SchemaContentEnvelope) UnmarshalBinary(b []byte) error {
453 var res IntotoV002SchemaContentEnvelope
454 if err := swag.ReadJSON(b, &res); err != nil {
455 return err
456 }
457 *m = res
458 return nil
459 }
460
461
462
463
464 type IntotoV002SchemaContentEnvelopeSignaturesItems0 struct {
465
466
467 Keyid string `json:"keyid,omitempty"`
468
469
470
471
472 PublicKey *strfmt.Base64 `json:"publicKey"`
473
474
475
476
477 Sig *strfmt.Base64 `json:"sig"`
478 }
479
480
481 func (m *IntotoV002SchemaContentEnvelopeSignaturesItems0) Validate(formats strfmt.Registry) error {
482 var res []error
483
484 if err := m.validatePublicKey(formats); err != nil {
485 res = append(res, err)
486 }
487
488 if err := m.validateSig(formats); err != nil {
489 res = append(res, err)
490 }
491
492 if len(res) > 0 {
493 return errors.CompositeValidationError(res...)
494 }
495 return nil
496 }
497
498 func (m *IntotoV002SchemaContentEnvelopeSignaturesItems0) validatePublicKey(formats strfmt.Registry) error {
499
500 if err := validate.Required("publicKey", "body", m.PublicKey); err != nil {
501 return err
502 }
503
504 return nil
505 }
506
507 func (m *IntotoV002SchemaContentEnvelopeSignaturesItems0) validateSig(formats strfmt.Registry) error {
508
509 if err := validate.Required("sig", "body", m.Sig); err != nil {
510 return err
511 }
512
513 return nil
514 }
515
516
517 func (m *IntotoV002SchemaContentEnvelopeSignaturesItems0) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
518 return nil
519 }
520
521
522 func (m *IntotoV002SchemaContentEnvelopeSignaturesItems0) MarshalBinary() ([]byte, error) {
523 if m == nil {
524 return nil, nil
525 }
526 return swag.WriteJSON(m)
527 }
528
529
530 func (m *IntotoV002SchemaContentEnvelopeSignaturesItems0) UnmarshalBinary(b []byte) error {
531 var res IntotoV002SchemaContentEnvelopeSignaturesItems0
532 if err := swag.ReadJSON(b, &res); err != nil {
533 return err
534 }
535 *m = res
536 return nil
537 }
538
539
540
541
542 type IntotoV002SchemaContentHash struct {
543
544
545
546
547 Algorithm *string `json:"algorithm"`
548
549
550
551 Value *string `json:"value"`
552 }
553
554
555 func (m *IntotoV002SchemaContentHash) Validate(formats strfmt.Registry) error {
556 var res []error
557
558 if err := m.validateAlgorithm(formats); err != nil {
559 res = append(res, err)
560 }
561
562 if err := m.validateValue(formats); err != nil {
563 res = append(res, err)
564 }
565
566 if len(res) > 0 {
567 return errors.CompositeValidationError(res...)
568 }
569 return nil
570 }
571
572 var intotoV002SchemaContentHashTypeAlgorithmPropEnum []interface{}
573
574 func init() {
575 var res []string
576 if err := json.Unmarshal([]byte(`["sha256"]`), &res); err != nil {
577 panic(err)
578 }
579 for _, v := range res {
580 intotoV002SchemaContentHashTypeAlgorithmPropEnum = append(intotoV002SchemaContentHashTypeAlgorithmPropEnum, v)
581 }
582 }
583
584 const (
585
586
587 IntotoV002SchemaContentHashAlgorithmSha256 string = "sha256"
588 )
589
590
591 func (m *IntotoV002SchemaContentHash) validateAlgorithmEnum(path, location string, value string) error {
592 if err := validate.EnumCase(path, location, value, intotoV002SchemaContentHashTypeAlgorithmPropEnum, true); err != nil {
593 return err
594 }
595 return nil
596 }
597
598 func (m *IntotoV002SchemaContentHash) validateAlgorithm(formats strfmt.Registry) error {
599
600 if err := validate.Required("content"+"."+"hash"+"."+"algorithm", "body", m.Algorithm); err != nil {
601 return err
602 }
603
604
605 if err := m.validateAlgorithmEnum("content"+"."+"hash"+"."+"algorithm", "body", *m.Algorithm); err != nil {
606 return err
607 }
608
609 return nil
610 }
611
612 func (m *IntotoV002SchemaContentHash) validateValue(formats strfmt.Registry) error {
613
614 if err := validate.Required("content"+"."+"hash"+"."+"value", "body", m.Value); err != nil {
615 return err
616 }
617
618 return nil
619 }
620
621
622 func (m *IntotoV002SchemaContentHash) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
623 var res []error
624
625 if len(res) > 0 {
626 return errors.CompositeValidationError(res...)
627 }
628 return nil
629 }
630
631
632 func (m *IntotoV002SchemaContentHash) MarshalBinary() ([]byte, error) {
633 if m == nil {
634 return nil, nil
635 }
636 return swag.WriteJSON(m)
637 }
638
639
640 func (m *IntotoV002SchemaContentHash) UnmarshalBinary(b []byte) error {
641 var res IntotoV002SchemaContentHash
642 if err := swag.ReadJSON(b, &res); err != nil {
643 return err
644 }
645 *m = res
646 return nil
647 }
648
649
650
651
652 type IntotoV002SchemaContentPayloadHash struct {
653
654
655
656
657 Algorithm *string `json:"algorithm"`
658
659
660
661 Value *string `json:"value"`
662 }
663
664
665 func (m *IntotoV002SchemaContentPayloadHash) Validate(formats strfmt.Registry) error {
666 var res []error
667
668 if err := m.validateAlgorithm(formats); err != nil {
669 res = append(res, err)
670 }
671
672 if err := m.validateValue(formats); err != nil {
673 res = append(res, err)
674 }
675
676 if len(res) > 0 {
677 return errors.CompositeValidationError(res...)
678 }
679 return nil
680 }
681
682 var intotoV002SchemaContentPayloadHashTypeAlgorithmPropEnum []interface{}
683
684 func init() {
685 var res []string
686 if err := json.Unmarshal([]byte(`["sha256"]`), &res); err != nil {
687 panic(err)
688 }
689 for _, v := range res {
690 intotoV002SchemaContentPayloadHashTypeAlgorithmPropEnum = append(intotoV002SchemaContentPayloadHashTypeAlgorithmPropEnum, v)
691 }
692 }
693
694 const (
695
696
697 IntotoV002SchemaContentPayloadHashAlgorithmSha256 string = "sha256"
698 )
699
700
701 func (m *IntotoV002SchemaContentPayloadHash) validateAlgorithmEnum(path, location string, value string) error {
702 if err := validate.EnumCase(path, location, value, intotoV002SchemaContentPayloadHashTypeAlgorithmPropEnum, true); err != nil {
703 return err
704 }
705 return nil
706 }
707
708 func (m *IntotoV002SchemaContentPayloadHash) validateAlgorithm(formats strfmt.Registry) error {
709
710 if err := validate.Required("content"+"."+"payloadHash"+"."+"algorithm", "body", m.Algorithm); err != nil {
711 return err
712 }
713
714
715 if err := m.validateAlgorithmEnum("content"+"."+"payloadHash"+"."+"algorithm", "body", *m.Algorithm); err != nil {
716 return err
717 }
718
719 return nil
720 }
721
722 func (m *IntotoV002SchemaContentPayloadHash) validateValue(formats strfmt.Registry) error {
723
724 if err := validate.Required("content"+"."+"payloadHash"+"."+"value", "body", m.Value); err != nil {
725 return err
726 }
727
728 return nil
729 }
730
731
732 func (m *IntotoV002SchemaContentPayloadHash) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
733 var res []error
734
735 if len(res) > 0 {
736 return errors.CompositeValidationError(res...)
737 }
738 return nil
739 }
740
741
742 func (m *IntotoV002SchemaContentPayloadHash) MarshalBinary() ([]byte, error) {
743 if m == nil {
744 return nil, nil
745 }
746 return swag.WriteJSON(m)
747 }
748
749
750 func (m *IntotoV002SchemaContentPayloadHash) UnmarshalBinary(b []byte) error {
751 var res IntotoV002SchemaContentPayloadHash
752 if err := swag.ReadJSON(b, &res); err != nil {
753 return err
754 }
755 *m = res
756 return nil
757 }
758
View as plain text