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 IntotoV001Schema struct {
40
41
42
43 Content *IntotoV001SchemaContent `json:"content"`
44
45
46
47
48 PublicKey *strfmt.Base64 `json:"publicKey"`
49 }
50
51
52 func (m *IntotoV001Schema) Validate(formats strfmt.Registry) error {
53 var res []error
54
55 if err := m.validateContent(formats); err != nil {
56 res = append(res, err)
57 }
58
59 if err := m.validatePublicKey(formats); err != nil {
60 res = append(res, err)
61 }
62
63 if len(res) > 0 {
64 return errors.CompositeValidationError(res...)
65 }
66 return nil
67 }
68
69 func (m *IntotoV001Schema) validateContent(formats strfmt.Registry) error {
70
71 if err := validate.Required("content", "body", m.Content); err != nil {
72 return err
73 }
74
75 if m.Content != nil {
76 if err := m.Content.Validate(formats); err != nil {
77 if ve, ok := err.(*errors.Validation); ok {
78 return ve.ValidateName("content")
79 } else if ce, ok := err.(*errors.CompositeError); ok {
80 return ce.ValidateName("content")
81 }
82 return err
83 }
84 }
85
86 return nil
87 }
88
89 func (m *IntotoV001Schema) validatePublicKey(formats strfmt.Registry) error {
90
91 if err := validate.Required("publicKey", "body", m.PublicKey); err != nil {
92 return err
93 }
94
95 return nil
96 }
97
98
99 func (m *IntotoV001Schema) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
100 var res []error
101
102 if err := m.contextValidateContent(ctx, formats); err != nil {
103 res = append(res, err)
104 }
105
106 if len(res) > 0 {
107 return errors.CompositeValidationError(res...)
108 }
109 return nil
110 }
111
112 func (m *IntotoV001Schema) contextValidateContent(ctx context.Context, formats strfmt.Registry) error {
113
114 if m.Content != nil {
115
116 if err := m.Content.ContextValidate(ctx, formats); err != nil {
117 if ve, ok := err.(*errors.Validation); ok {
118 return ve.ValidateName("content")
119 } else if ce, ok := err.(*errors.CompositeError); ok {
120 return ce.ValidateName("content")
121 }
122 return err
123 }
124 }
125
126 return nil
127 }
128
129
130 func (m *IntotoV001Schema) MarshalBinary() ([]byte, error) {
131 if m == nil {
132 return nil, nil
133 }
134 return swag.WriteJSON(m)
135 }
136
137
138 func (m *IntotoV001Schema) UnmarshalBinary(b []byte) error {
139 var res IntotoV001Schema
140 if err := swag.ReadJSON(b, &res); err != nil {
141 return err
142 }
143 *m = res
144 return nil
145 }
146
147
148
149
150 type IntotoV001SchemaContent struct {
151
152
153 Envelope string `json:"envelope,omitempty"`
154
155
156 Hash *IntotoV001SchemaContentHash `json:"hash,omitempty"`
157
158
159 PayloadHash *IntotoV001SchemaContentPayloadHash `json:"payloadHash,omitempty"`
160 }
161
162
163 func (m *IntotoV001SchemaContent) Validate(formats strfmt.Registry) error {
164 var res []error
165
166 if err := m.validateHash(formats); err != nil {
167 res = append(res, err)
168 }
169
170 if err := m.validatePayloadHash(formats); err != nil {
171 res = append(res, err)
172 }
173
174 if len(res) > 0 {
175 return errors.CompositeValidationError(res...)
176 }
177 return nil
178 }
179
180 func (m *IntotoV001SchemaContent) validateHash(formats strfmt.Registry) error {
181 if swag.IsZero(m.Hash) {
182 return nil
183 }
184
185 if m.Hash != nil {
186 if err := m.Hash.Validate(formats); err != nil {
187 if ve, ok := err.(*errors.Validation); ok {
188 return ve.ValidateName("content" + "." + "hash")
189 } else if ce, ok := err.(*errors.CompositeError); ok {
190 return ce.ValidateName("content" + "." + "hash")
191 }
192 return err
193 }
194 }
195
196 return nil
197 }
198
199 func (m *IntotoV001SchemaContent) validatePayloadHash(formats strfmt.Registry) error {
200 if swag.IsZero(m.PayloadHash) {
201 return nil
202 }
203
204 if m.PayloadHash != nil {
205 if err := m.PayloadHash.Validate(formats); err != nil {
206 if ve, ok := err.(*errors.Validation); ok {
207 return ve.ValidateName("content" + "." + "payloadHash")
208 } else if ce, ok := err.(*errors.CompositeError); ok {
209 return ce.ValidateName("content" + "." + "payloadHash")
210 }
211 return err
212 }
213 }
214
215 return nil
216 }
217
218
219 func (m *IntotoV001SchemaContent) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
220 var res []error
221
222 if err := m.contextValidateHash(ctx, formats); err != nil {
223 res = append(res, err)
224 }
225
226 if err := m.contextValidatePayloadHash(ctx, formats); err != nil {
227 res = append(res, err)
228 }
229
230 if len(res) > 0 {
231 return errors.CompositeValidationError(res...)
232 }
233 return nil
234 }
235
236 func (m *IntotoV001SchemaContent) contextValidateHash(ctx context.Context, formats strfmt.Registry) error {
237
238 if m.Hash != nil {
239
240 if swag.IsZero(m.Hash) {
241 return nil
242 }
243
244 if err := m.Hash.ContextValidate(ctx, formats); err != nil {
245 if ve, ok := err.(*errors.Validation); ok {
246 return ve.ValidateName("content" + "." + "hash")
247 } else if ce, ok := err.(*errors.CompositeError); ok {
248 return ce.ValidateName("content" + "." + "hash")
249 }
250 return err
251 }
252 }
253
254 return nil
255 }
256
257 func (m *IntotoV001SchemaContent) contextValidatePayloadHash(ctx context.Context, formats strfmt.Registry) error {
258
259 if m.PayloadHash != nil {
260
261 if swag.IsZero(m.PayloadHash) {
262 return nil
263 }
264
265 if err := m.PayloadHash.ContextValidate(ctx, formats); err != nil {
266 if ve, ok := err.(*errors.Validation); ok {
267 return ve.ValidateName("content" + "." + "payloadHash")
268 } else if ce, ok := err.(*errors.CompositeError); ok {
269 return ce.ValidateName("content" + "." + "payloadHash")
270 }
271 return err
272 }
273 }
274
275 return nil
276 }
277
278
279 func (m *IntotoV001SchemaContent) MarshalBinary() ([]byte, error) {
280 if m == nil {
281 return nil, nil
282 }
283 return swag.WriteJSON(m)
284 }
285
286
287 func (m *IntotoV001SchemaContent) UnmarshalBinary(b []byte) error {
288 var res IntotoV001SchemaContent
289 if err := swag.ReadJSON(b, &res); err != nil {
290 return err
291 }
292 *m = res
293 return nil
294 }
295
296
297
298
299 type IntotoV001SchemaContentHash struct {
300
301
302
303
304 Algorithm *string `json:"algorithm"`
305
306
307
308 Value *string `json:"value"`
309 }
310
311
312 func (m *IntotoV001SchemaContentHash) Validate(formats strfmt.Registry) error {
313 var res []error
314
315 if err := m.validateAlgorithm(formats); err != nil {
316 res = append(res, err)
317 }
318
319 if err := m.validateValue(formats); err != nil {
320 res = append(res, err)
321 }
322
323 if len(res) > 0 {
324 return errors.CompositeValidationError(res...)
325 }
326 return nil
327 }
328
329 var intotoV001SchemaContentHashTypeAlgorithmPropEnum []interface{}
330
331 func init() {
332 var res []string
333 if err := json.Unmarshal([]byte(`["sha256"]`), &res); err != nil {
334 panic(err)
335 }
336 for _, v := range res {
337 intotoV001SchemaContentHashTypeAlgorithmPropEnum = append(intotoV001SchemaContentHashTypeAlgorithmPropEnum, v)
338 }
339 }
340
341 const (
342
343
344 IntotoV001SchemaContentHashAlgorithmSha256 string = "sha256"
345 )
346
347
348 func (m *IntotoV001SchemaContentHash) validateAlgorithmEnum(path, location string, value string) error {
349 if err := validate.EnumCase(path, location, value, intotoV001SchemaContentHashTypeAlgorithmPropEnum, true); err != nil {
350 return err
351 }
352 return nil
353 }
354
355 func (m *IntotoV001SchemaContentHash) validateAlgorithm(formats strfmt.Registry) error {
356
357 if err := validate.Required("content"+"."+"hash"+"."+"algorithm", "body", m.Algorithm); err != nil {
358 return err
359 }
360
361
362 if err := m.validateAlgorithmEnum("content"+"."+"hash"+"."+"algorithm", "body", *m.Algorithm); err != nil {
363 return err
364 }
365
366 return nil
367 }
368
369 func (m *IntotoV001SchemaContentHash) validateValue(formats strfmt.Registry) error {
370
371 if err := validate.Required("content"+"."+"hash"+"."+"value", "body", m.Value); err != nil {
372 return err
373 }
374
375 return nil
376 }
377
378
379 func (m *IntotoV001SchemaContentHash) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
380 var res []error
381
382 if len(res) > 0 {
383 return errors.CompositeValidationError(res...)
384 }
385 return nil
386 }
387
388
389 func (m *IntotoV001SchemaContentHash) MarshalBinary() ([]byte, error) {
390 if m == nil {
391 return nil, nil
392 }
393 return swag.WriteJSON(m)
394 }
395
396
397 func (m *IntotoV001SchemaContentHash) UnmarshalBinary(b []byte) error {
398 var res IntotoV001SchemaContentHash
399 if err := swag.ReadJSON(b, &res); err != nil {
400 return err
401 }
402 *m = res
403 return nil
404 }
405
406
407
408
409 type IntotoV001SchemaContentPayloadHash struct {
410
411
412
413
414 Algorithm *string `json:"algorithm"`
415
416
417
418 Value *string `json:"value"`
419 }
420
421
422 func (m *IntotoV001SchemaContentPayloadHash) Validate(formats strfmt.Registry) error {
423 var res []error
424
425 if err := m.validateAlgorithm(formats); err != nil {
426 res = append(res, err)
427 }
428
429 if err := m.validateValue(formats); err != nil {
430 res = append(res, err)
431 }
432
433 if len(res) > 0 {
434 return errors.CompositeValidationError(res...)
435 }
436 return nil
437 }
438
439 var intotoV001SchemaContentPayloadHashTypeAlgorithmPropEnum []interface{}
440
441 func init() {
442 var res []string
443 if err := json.Unmarshal([]byte(`["sha256"]`), &res); err != nil {
444 panic(err)
445 }
446 for _, v := range res {
447 intotoV001SchemaContentPayloadHashTypeAlgorithmPropEnum = append(intotoV001SchemaContentPayloadHashTypeAlgorithmPropEnum, v)
448 }
449 }
450
451 const (
452
453
454 IntotoV001SchemaContentPayloadHashAlgorithmSha256 string = "sha256"
455 )
456
457
458 func (m *IntotoV001SchemaContentPayloadHash) validateAlgorithmEnum(path, location string, value string) error {
459 if err := validate.EnumCase(path, location, value, intotoV001SchemaContentPayloadHashTypeAlgorithmPropEnum, true); err != nil {
460 return err
461 }
462 return nil
463 }
464
465 func (m *IntotoV001SchemaContentPayloadHash) validateAlgorithm(formats strfmt.Registry) error {
466
467 if err := validate.Required("content"+"."+"payloadHash"+"."+"algorithm", "body", m.Algorithm); err != nil {
468 return err
469 }
470
471
472 if err := m.validateAlgorithmEnum("content"+"."+"payloadHash"+"."+"algorithm", "body", *m.Algorithm); err != nil {
473 return err
474 }
475
476 return nil
477 }
478
479 func (m *IntotoV001SchemaContentPayloadHash) validateValue(formats strfmt.Registry) error {
480
481 if err := validate.Required("content"+"."+"payloadHash"+"."+"value", "body", m.Value); err != nil {
482 return err
483 }
484
485 return nil
486 }
487
488
489 func (m *IntotoV001SchemaContentPayloadHash) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
490 var res []error
491
492 if len(res) > 0 {
493 return errors.CompositeValidationError(res...)
494 }
495 return nil
496 }
497
498
499 func (m *IntotoV001SchemaContentPayloadHash) MarshalBinary() ([]byte, error) {
500 if m == nil {
501 return nil, nil
502 }
503 return swag.WriteJSON(m)
504 }
505
506
507 func (m *IntotoV001SchemaContentPayloadHash) UnmarshalBinary(b []byte) error {
508 var res IntotoV001SchemaContentPayloadHash
509 if err := swag.ReadJSON(b, &res); err != nil {
510 return err
511 }
512 *m = res
513 return nil
514 }
515
View as plain text