/
writable_record.go
730 lines (532 loc) · 18.4 KB
/
writable_record.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
// Code generated by go-swagger; DO NOT EDIT.
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"encoding/json"
"strconv"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// WritableRecord writable record
//
// swagger:model WritableRecord
type WritableRecord struct {
// Active
// Read Only: true
Active *bool `json:"active,omitempty"`
// Address record
// Required: true
AddressRecord *int64 `json:"address_record"`
// Created
// Read Only: true
// Format: date-time
Created *strfmt.DateTime `json:"created,omitempty"`
// Custom fields
CustomFields interface{} `json:"custom_fields,omitempty"`
// Description
// Max Length: 200
Description string `json:"description,omitempty"`
// Disable PTR
//
// Disable PTR record creation
DisablePtr bool `json:"disable_ptr,omitempty"`
// Display
// Read Only: true
Display string `json:"display,omitempty"`
// ID
// Read Only: true
ID int64 `json:"id,omitempty"`
// Last updated
// Read Only: true
// Format: date-time
LastUpdated *strfmt.DateTime `json:"last_updated,omitempty"`
// Managed
Managed bool `json:"managed,omitempty"`
// Name
// Required: true
// Max Length: 255
// Min Length: 1
Name *string `json:"name"`
// PTR record
PtrRecord *int64 `json:"ptr_record,omitempty"`
// Status
// Enum: [active inactive]
Status string `json:"status,omitempty"`
// tags
Tags []*NestedTag `json:"tags,omitempty"`
// TTL
// Maximum: 2.147483647e+09
// Minimum: 0
TTL *int64 `json:"ttl,omitempty"`
// Type
// Required: true
// Enum: [A A6 AAAA AFSDB AMTRELAY APL AVC CAA CDNSKEY CDS CERT CNAME CSYNC DHCID DLV DNAME DNSKEY DS EUI48 EUI64 GPOS HINFO HIP HTTPS IPSECKEY ISDN KEY KX L32 L64 LOC LP MB MD MF MG MINFO MR MX NAPTR NID NINFO NS NSAP NSAP_PTR NSEC NSEC3 NSEC3PARAM NULL NXT OPENPGPKEY PTR PX RP RRSIG RT SIG SMIMEA SOA SPF SRV SSHFP SVCB TA TLSA TXT TYPE0 UNSPEC URI WKS X25 ZONEMD]
Type *string `json:"type"`
// Url
// Read Only: true
// Format: uri
URL strfmt.URI `json:"url,omitempty"`
// Value
// Required: true
// Max Length: 1000
// Min Length: 1
Value *string `json:"value"`
// Zone
// Required: true
Zone *int64 `json:"zone"`
}
// Validate validates this writable record
func (m *WritableRecord) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateAddressRecord(formats); err != nil {
res = append(res, err)
}
if err := m.validateCreated(formats); err != nil {
res = append(res, err)
}
if err := m.validateDescription(formats); err != nil {
res = append(res, err)
}
if err := m.validateLastUpdated(formats); err != nil {
res = append(res, err)
}
if err := m.validateName(formats); err != nil {
res = append(res, err)
}
if err := m.validateStatus(formats); err != nil {
res = append(res, err)
}
if err := m.validateTags(formats); err != nil {
res = append(res, err)
}
if err := m.validateTTL(formats); err != nil {
res = append(res, err)
}
if err := m.validateType(formats); err != nil {
res = append(res, err)
}
if err := m.validateURL(formats); err != nil {
res = append(res, err)
}
if err := m.validateValue(formats); err != nil {
res = append(res, err)
}
if err := m.validateZone(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *WritableRecord) validateAddressRecord(formats strfmt.Registry) error {
if err := validate.Required("address_record", "body", m.AddressRecord); err != nil {
return err
}
return nil
}
func (m *WritableRecord) validateCreated(formats strfmt.Registry) error {
if swag.IsZero(m.Created) { // not required
return nil
}
if err := validate.FormatOf("created", "body", "date-time", m.Created.String(), formats); err != nil {
return err
}
return nil
}
func (m *WritableRecord) validateDescription(formats strfmt.Registry) error {
if swag.IsZero(m.Description) { // not required
return nil
}
if err := validate.MaxLength("description", "body", m.Description, 200); err != nil {
return err
}
return nil
}
func (m *WritableRecord) validateLastUpdated(formats strfmt.Registry) error {
if swag.IsZero(m.LastUpdated) { // not required
return nil
}
if err := validate.FormatOf("last_updated", "body", "date-time", m.LastUpdated.String(), formats); err != nil {
return err
}
return nil
}
func (m *WritableRecord) validateName(formats strfmt.Registry) error {
if err := validate.Required("name", "body", m.Name); err != nil {
return err
}
if err := validate.MinLength("name", "body", *m.Name, 1); err != nil {
return err
}
if err := validate.MaxLength("name", "body", *m.Name, 255); err != nil {
return err
}
return nil
}
var writableRecordTypeStatusPropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["active","inactive"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
writableRecordTypeStatusPropEnum = append(writableRecordTypeStatusPropEnum, v)
}
}
const (
// WritableRecordStatusActive captures enum value "active"
WritableRecordStatusActive string = "active"
// WritableRecordStatusInactive captures enum value "inactive"
WritableRecordStatusInactive string = "inactive"
)
// prop value enum
func (m *WritableRecord) validateStatusEnum(path, location string, value string) error {
if err := validate.EnumCase(path, location, value, writableRecordTypeStatusPropEnum, true); err != nil {
return err
}
return nil
}
func (m *WritableRecord) validateStatus(formats strfmt.Registry) error {
if swag.IsZero(m.Status) { // not required
return nil
}
// value enum
if err := m.validateStatusEnum("status", "body", m.Status); err != nil {
return err
}
return nil
}
func (m *WritableRecord) validateTags(formats strfmt.Registry) error {
if swag.IsZero(m.Tags) { // not required
return nil
}
for i := 0; i < len(m.Tags); i++ {
if swag.IsZero(m.Tags[i]) { // not required
continue
}
if m.Tags[i] != nil {
if err := m.Tags[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("tags" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("tags" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
func (m *WritableRecord) validateTTL(formats strfmt.Registry) error {
if swag.IsZero(m.TTL) { // not required
return nil
}
if err := validate.MinimumInt("ttl", "body", *m.TTL, 0, false); err != nil {
return err
}
if err := validate.MaximumInt("ttl", "body", *m.TTL, 2.147483647e+09, false); err != nil {
return err
}
return nil
}
var writableRecordTypeTypePropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["A","A6","AAAA","AFSDB","AMTRELAY","APL","AVC","CAA","CDNSKEY","CDS","CERT","CNAME","CSYNC","DHCID","DLV","DNAME","DNSKEY","DS","EUI48","EUI64","GPOS","HINFO","HIP","HTTPS","IPSECKEY","ISDN","KEY","KX","L32","L64","LOC","LP","MB","MD","MF","MG","MINFO","MR","MX","NAPTR","NID","NINFO","NS","NSAP","NSAP_PTR","NSEC","NSEC3","NSEC3PARAM","NULL","NXT","OPENPGPKEY","PTR","PX","RP","RRSIG","RT","SIG","SMIMEA","SOA","SPF","SRV","SSHFP","SVCB","TA","TLSA","TXT","TYPE0","UNSPEC","URI","WKS","X25","ZONEMD"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
writableRecordTypeTypePropEnum = append(writableRecordTypeTypePropEnum, v)
}
}
const (
// WritableRecordTypeA captures enum value "A"
WritableRecordTypeA string = "A"
// WritableRecordTypeA6 captures enum value "A6"
WritableRecordTypeA6 string = "A6"
// WritableRecordTypeAAAA captures enum value "AAAA"
WritableRecordTypeAAAA string = "AAAA"
// WritableRecordTypeAFSDB captures enum value "AFSDB"
WritableRecordTypeAFSDB string = "AFSDB"
// WritableRecordTypeAMTRELAY captures enum value "AMTRELAY"
WritableRecordTypeAMTRELAY string = "AMTRELAY"
// WritableRecordTypeAPL captures enum value "APL"
WritableRecordTypeAPL string = "APL"
// WritableRecordTypeAVC captures enum value "AVC"
WritableRecordTypeAVC string = "AVC"
// WritableRecordTypeCAA captures enum value "CAA"
WritableRecordTypeCAA string = "CAA"
// WritableRecordTypeCDNSKEY captures enum value "CDNSKEY"
WritableRecordTypeCDNSKEY string = "CDNSKEY"
// WritableRecordTypeCDS captures enum value "CDS"
WritableRecordTypeCDS string = "CDS"
// WritableRecordTypeCERT captures enum value "CERT"
WritableRecordTypeCERT string = "CERT"
// WritableRecordTypeCNAME captures enum value "CNAME"
WritableRecordTypeCNAME string = "CNAME"
// WritableRecordTypeCSYNC captures enum value "CSYNC"
WritableRecordTypeCSYNC string = "CSYNC"
// WritableRecordTypeDHCID captures enum value "DHCID"
WritableRecordTypeDHCID string = "DHCID"
// WritableRecordTypeDLV captures enum value "DLV"
WritableRecordTypeDLV string = "DLV"
// WritableRecordTypeDNAME captures enum value "DNAME"
WritableRecordTypeDNAME string = "DNAME"
// WritableRecordTypeDNSKEY captures enum value "DNSKEY"
WritableRecordTypeDNSKEY string = "DNSKEY"
// WritableRecordTypeDS captures enum value "DS"
WritableRecordTypeDS string = "DS"
// WritableRecordTypeEUI48 captures enum value "EUI48"
WritableRecordTypeEUI48 string = "EUI48"
// WritableRecordTypeEUI64 captures enum value "EUI64"
WritableRecordTypeEUI64 string = "EUI64"
// WritableRecordTypeGPOS captures enum value "GPOS"
WritableRecordTypeGPOS string = "GPOS"
// WritableRecordTypeHINFO captures enum value "HINFO"
WritableRecordTypeHINFO string = "HINFO"
// WritableRecordTypeHIP captures enum value "HIP"
WritableRecordTypeHIP string = "HIP"
// WritableRecordTypeHTTPS captures enum value "HTTPS"
WritableRecordTypeHTTPS string = "HTTPS"
// WritableRecordTypeIPSECKEY captures enum value "IPSECKEY"
WritableRecordTypeIPSECKEY string = "IPSECKEY"
// WritableRecordTypeISDN captures enum value "ISDN"
WritableRecordTypeISDN string = "ISDN"
// WritableRecordTypeKEY captures enum value "KEY"
WritableRecordTypeKEY string = "KEY"
// WritableRecordTypeKX captures enum value "KX"
WritableRecordTypeKX string = "KX"
// WritableRecordTypeL32 captures enum value "L32"
WritableRecordTypeL32 string = "L32"
// WritableRecordTypeL64 captures enum value "L64"
WritableRecordTypeL64 string = "L64"
// WritableRecordTypeLOC captures enum value "LOC"
WritableRecordTypeLOC string = "LOC"
// WritableRecordTypeLP captures enum value "LP"
WritableRecordTypeLP string = "LP"
// WritableRecordTypeMB captures enum value "MB"
WritableRecordTypeMB string = "MB"
// WritableRecordTypeMD captures enum value "MD"
WritableRecordTypeMD string = "MD"
// WritableRecordTypeMF captures enum value "MF"
WritableRecordTypeMF string = "MF"
// WritableRecordTypeMG captures enum value "MG"
WritableRecordTypeMG string = "MG"
// WritableRecordTypeMINFO captures enum value "MINFO"
WritableRecordTypeMINFO string = "MINFO"
// WritableRecordTypeMR captures enum value "MR"
WritableRecordTypeMR string = "MR"
// WritableRecordTypeMX captures enum value "MX"
WritableRecordTypeMX string = "MX"
// WritableRecordTypeNAPTR captures enum value "NAPTR"
WritableRecordTypeNAPTR string = "NAPTR"
// WritableRecordTypeNID captures enum value "NID"
WritableRecordTypeNID string = "NID"
// WritableRecordTypeNINFO captures enum value "NINFO"
WritableRecordTypeNINFO string = "NINFO"
// WritableRecordTypeNS captures enum value "NS"
WritableRecordTypeNS string = "NS"
// WritableRecordTypeNSAP captures enum value "NSAP"
WritableRecordTypeNSAP string = "NSAP"
// WritableRecordTypeNSAPPTR captures enum value "NSAP_PTR"
WritableRecordTypeNSAPPTR string = "NSAP_PTR"
// WritableRecordTypeNSEC captures enum value "NSEC"
WritableRecordTypeNSEC string = "NSEC"
// WritableRecordTypeNSEC3 captures enum value "NSEC3"
WritableRecordTypeNSEC3 string = "NSEC3"
// WritableRecordTypeNSEC3PARAM captures enum value "NSEC3PARAM"
WritableRecordTypeNSEC3PARAM string = "NSEC3PARAM"
// WritableRecordTypeNULL captures enum value "NULL"
WritableRecordTypeNULL string = "NULL"
// WritableRecordTypeNXT captures enum value "NXT"
WritableRecordTypeNXT string = "NXT"
// WritableRecordTypeOPENPGPKEY captures enum value "OPENPGPKEY"
WritableRecordTypeOPENPGPKEY string = "OPENPGPKEY"
// WritableRecordTypePTR captures enum value "PTR"
WritableRecordTypePTR string = "PTR"
// WritableRecordTypePX captures enum value "PX"
WritableRecordTypePX string = "PX"
// WritableRecordTypeRP captures enum value "RP"
WritableRecordTypeRP string = "RP"
// WritableRecordTypeRRSIG captures enum value "RRSIG"
WritableRecordTypeRRSIG string = "RRSIG"
// WritableRecordTypeRT captures enum value "RT"
WritableRecordTypeRT string = "RT"
// WritableRecordTypeSIG captures enum value "SIG"
WritableRecordTypeSIG string = "SIG"
// WritableRecordTypeSMIMEA captures enum value "SMIMEA"
WritableRecordTypeSMIMEA string = "SMIMEA"
// WritableRecordTypeSOA captures enum value "SOA"
WritableRecordTypeSOA string = "SOA"
// WritableRecordTypeSPF captures enum value "SPF"
WritableRecordTypeSPF string = "SPF"
// WritableRecordTypeSRV captures enum value "SRV"
WritableRecordTypeSRV string = "SRV"
// WritableRecordTypeSSHFP captures enum value "SSHFP"
WritableRecordTypeSSHFP string = "SSHFP"
// WritableRecordTypeSVCB captures enum value "SVCB"
WritableRecordTypeSVCB string = "SVCB"
// WritableRecordTypeTA captures enum value "TA"
WritableRecordTypeTA string = "TA"
// WritableRecordTypeTLSA captures enum value "TLSA"
WritableRecordTypeTLSA string = "TLSA"
// WritableRecordTypeTXT captures enum value "TXT"
WritableRecordTypeTXT string = "TXT"
// WritableRecordTypeTYPE0 captures enum value "TYPE0"
WritableRecordTypeTYPE0 string = "TYPE0"
// WritableRecordTypeUNSPEC captures enum value "UNSPEC"
WritableRecordTypeUNSPEC string = "UNSPEC"
// WritableRecordTypeURI captures enum value "URI"
WritableRecordTypeURI string = "URI"
// WritableRecordTypeWKS captures enum value "WKS"
WritableRecordTypeWKS string = "WKS"
// WritableRecordTypeX25 captures enum value "X25"
WritableRecordTypeX25 string = "X25"
// WritableRecordTypeZONEMD captures enum value "ZONEMD"
WritableRecordTypeZONEMD string = "ZONEMD"
)
// prop value enum
func (m *WritableRecord) validateTypeEnum(path, location string, value string) error {
if err := validate.EnumCase(path, location, value, writableRecordTypeTypePropEnum, true); err != nil {
return err
}
return nil
}
func (m *WritableRecord) validateType(formats strfmt.Registry) error {
if err := validate.Required("type", "body", m.Type); err != nil {
return err
}
// value enum
if err := m.validateTypeEnum("type", "body", *m.Type); err != nil {
return err
}
return nil
}
func (m *WritableRecord) validateURL(formats strfmt.Registry) error {
if swag.IsZero(m.URL) { // not required
return nil
}
if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil {
return err
}
return nil
}
func (m *WritableRecord) validateValue(formats strfmt.Registry) error {
if err := validate.Required("value", "body", m.Value); err != nil {
return err
}
if err := validate.MinLength("value", "body", *m.Value, 1); err != nil {
return err
}
if err := validate.MaxLength("value", "body", *m.Value, 1000); err != nil {
return err
}
return nil
}
func (m *WritableRecord) validateZone(formats strfmt.Registry) error {
if err := validate.Required("zone", "body", m.Zone); err != nil {
return err
}
return nil
}
// ContextValidate validate this writable record based on the context it is used
func (m *WritableRecord) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateActive(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateCreated(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateDisplay(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateID(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateLastUpdated(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateTags(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateURL(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *WritableRecord) contextValidateActive(ctx context.Context, formats strfmt.Registry) error {
if err := validate.ReadOnly(ctx, "active", "body", m.Active); err != nil {
return err
}
return nil
}
func (m *WritableRecord) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error {
if err := validate.ReadOnly(ctx, "created", "body", m.Created); err != nil {
return err
}
return nil
}
func (m *WritableRecord) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error {
if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil {
return err
}
return nil
}
func (m *WritableRecord) contextValidateID(ctx context.Context, formats strfmt.Registry) error {
if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil {
return err
}
return nil
}
func (m *WritableRecord) contextValidateLastUpdated(ctx context.Context, formats strfmt.Registry) error {
if err := validate.ReadOnly(ctx, "last_updated", "body", m.LastUpdated); err != nil {
return err
}
return nil
}
func (m *WritableRecord) contextValidateTags(ctx context.Context, formats strfmt.Registry) error {
for i := 0; i < len(m.Tags); i++ {
if m.Tags[i] != nil {
if err := m.Tags[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("tags" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("tags" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
func (m *WritableRecord) contextValidateURL(ctx context.Context, formats strfmt.Registry) error {
if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil {
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *WritableRecord) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *WritableRecord) UnmarshalBinary(b []byte) error {
var res WritableRecord
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}