forked from netbox-community/go-netbox
-
Notifications
You must be signed in to change notification settings - Fork 21
/
site.go
968 lines (738 loc) · 21.4 KB
/
site.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
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
// Code generated by go-swagger; DO NOT EDIT.
// Copyright 2020 The go-netbox Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
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"
)
// Site site
//
// swagger:model Site
type Site struct {
// asns
// Unique: true
Asns []*NestedASN `json:"asns"`
// Circuit count
// Read Only: true
CircuitCount int64 `json:"circuit_count,omitempty"`
// Comments
Comments string `json:"comments,omitempty"`
// 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"`
// Device count
// Read Only: true
DeviceCount int64 `json:"device_count,omitempty"`
// Display
// Read Only: true
Display string `json:"display,omitempty"`
// Facility
//
// Local facility ID or description
// Max Length: 50
Facility string `json:"facility,omitempty"`
// group
Group *NestedSiteGroup `json:"group,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"`
// Latitude
//
// GPS coordinate (latitude)
Latitude *float64 `json:"latitude,omitempty"`
// Longitude
//
// GPS coordinate (longitude)
Longitude *float64 `json:"longitude,omitempty"`
// Name
// Required: true
// Max Length: 100
// Min Length: 1
Name *string `json:"name"`
// Physical address
// Max Length: 200
PhysicalAddress string `json:"physical_address,omitempty"`
// Prefix count
// Read Only: true
PrefixCount int64 `json:"prefix_count,omitempty"`
// Rack count
// Read Only: true
RackCount int64 `json:"rack_count,omitempty"`
// region
Region *NestedRegion `json:"region,omitempty"`
// Shipping address
// Max Length: 200
ShippingAddress string `json:"shipping_address,omitempty"`
// Slug
// Required: true
// Max Length: 100
// Min Length: 1
// Pattern: ^[-a-zA-Z0-9_]+$
Slug *string `json:"slug"`
// status
Status *SiteStatus `json:"status,omitempty"`
// tags
Tags []*NestedTag `json:"tags"`
// tenant
Tenant *NestedTenant `json:"tenant,omitempty"`
// Time zone
TimeZone *string `json:"time_zone,omitempty"`
// Url
// Read Only: true
// Format: uri
URL strfmt.URI `json:"url,omitempty"`
// Virtualmachine count
// Read Only: true
VirtualmachineCount int64 `json:"virtualmachine_count,omitempty"`
// Vlan count
// Read Only: true
VlanCount int64 `json:"vlan_count,omitempty"`
}
// Validate validates this site
func (m *Site) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateAsns(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.validateFacility(formats); err != nil {
res = append(res, err)
}
if err := m.validateGroup(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.validatePhysicalAddress(formats); err != nil {
res = append(res, err)
}
if err := m.validateRegion(formats); err != nil {
res = append(res, err)
}
if err := m.validateShippingAddress(formats); err != nil {
res = append(res, err)
}
if err := m.validateSlug(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.validateTenant(formats); err != nil {
res = append(res, err)
}
if err := m.validateURL(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Site) validateAsns(formats strfmt.Registry) error {
if swag.IsZero(m.Asns) { // not required
return nil
}
if err := validate.UniqueItems("asns", "body", m.Asns); err != nil {
return err
}
for i := 0; i < len(m.Asns); i++ {
if swag.IsZero(m.Asns[i]) { // not required
continue
}
if m.Asns[i] != nil {
if err := m.Asns[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("asns" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("asns" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
func (m *Site) 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 *Site) 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 *Site) validateFacility(formats strfmt.Registry) error {
if swag.IsZero(m.Facility) { // not required
return nil
}
if err := validate.MaxLength("facility", "body", m.Facility, 50); err != nil {
return err
}
return nil
}
func (m *Site) validateGroup(formats strfmt.Registry) error {
if swag.IsZero(m.Group) { // not required
return nil
}
if m.Group != nil {
if err := m.Group.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("group")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("group")
}
return err
}
}
return nil
}
func (m *Site) 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 *Site) 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, 100); err != nil {
return err
}
return nil
}
func (m *Site) validatePhysicalAddress(formats strfmt.Registry) error {
if swag.IsZero(m.PhysicalAddress) { // not required
return nil
}
if err := validate.MaxLength("physical_address", "body", m.PhysicalAddress, 200); err != nil {
return err
}
return nil
}
func (m *Site) validateRegion(formats strfmt.Registry) error {
if swag.IsZero(m.Region) { // not required
return nil
}
if m.Region != nil {
if err := m.Region.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("region")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("region")
}
return err
}
}
return nil
}
func (m *Site) validateShippingAddress(formats strfmt.Registry) error {
if swag.IsZero(m.ShippingAddress) { // not required
return nil
}
if err := validate.MaxLength("shipping_address", "body", m.ShippingAddress, 200); err != nil {
return err
}
return nil
}
func (m *Site) validateSlug(formats strfmt.Registry) error {
if err := validate.Required("slug", "body", m.Slug); err != nil {
return err
}
if err := validate.MinLength("slug", "body", *m.Slug, 1); err != nil {
return err
}
if err := validate.MaxLength("slug", "body", *m.Slug, 100); err != nil {
return err
}
if err := validate.Pattern("slug", "body", *m.Slug, `^[-a-zA-Z0-9_]+$`); err != nil {
return err
}
return nil
}
func (m *Site) validateStatus(formats strfmt.Registry) error {
if swag.IsZero(m.Status) { // not required
return nil
}
if m.Status != nil {
if err := m.Status.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("status")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("status")
}
return err
}
}
return nil
}
func (m *Site) 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 *Site) validateTenant(formats strfmt.Registry) error {
if swag.IsZero(m.Tenant) { // not required
return nil
}
if m.Tenant != nil {
if err := m.Tenant.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("tenant")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("tenant")
}
return err
}
}
return nil
}
func (m *Site) 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
}
// ContextValidate validate this site based on the context it is used
func (m *Site) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateAsns(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateCircuitCount(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateCreated(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateDeviceCount(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateDisplay(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateGroup(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.contextValidatePrefixCount(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateRackCount(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateRegion(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateStatus(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateTags(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateTenant(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateURL(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateVirtualmachineCount(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateVlanCount(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Site) contextValidateAsns(ctx context.Context, formats strfmt.Registry) error {
for i := 0; i < len(m.Asns); i++ {
if m.Asns[i] != nil {
if swag.IsZero(m.Asns[i]) { // not required
return nil
}
if err := m.Asns[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("asns" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("asns" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
func (m *Site) contextValidateCircuitCount(ctx context.Context, formats strfmt.Registry) error {
if err := validate.ReadOnly(ctx, "circuit_count", "body", int64(m.CircuitCount)); err != nil {
return err
}
return nil
}
func (m *Site) 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 *Site) contextValidateDeviceCount(ctx context.Context, formats strfmt.Registry) error {
if err := validate.ReadOnly(ctx, "device_count", "body", int64(m.DeviceCount)); err != nil {
return err
}
return nil
}
func (m *Site) 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 *Site) contextValidateGroup(ctx context.Context, formats strfmt.Registry) error {
if m.Group != nil {
if swag.IsZero(m.Group) { // not required
return nil
}
if err := m.Group.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("group")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("group")
}
return err
}
}
return nil
}
func (m *Site) 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 *Site) 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 *Site) contextValidatePrefixCount(ctx context.Context, formats strfmt.Registry) error {
if err := validate.ReadOnly(ctx, "prefix_count", "body", int64(m.PrefixCount)); err != nil {
return err
}
return nil
}
func (m *Site) contextValidateRackCount(ctx context.Context, formats strfmt.Registry) error {
if err := validate.ReadOnly(ctx, "rack_count", "body", int64(m.RackCount)); err != nil {
return err
}
return nil
}
func (m *Site) contextValidateRegion(ctx context.Context, formats strfmt.Registry) error {
if m.Region != nil {
if swag.IsZero(m.Region) { // not required
return nil
}
if err := m.Region.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("region")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("region")
}
return err
}
}
return nil
}
func (m *Site) contextValidateStatus(ctx context.Context, formats strfmt.Registry) error {
if m.Status != nil {
if swag.IsZero(m.Status) { // not required
return nil
}
if err := m.Status.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("status")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("status")
}
return err
}
}
return nil
}
func (m *Site) contextValidateTags(ctx context.Context, formats strfmt.Registry) error {
for i := 0; i < len(m.Tags); i++ {
if m.Tags[i] != nil {
if swag.IsZero(m.Tags[i]) { // not required
return 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 *Site) contextValidateTenant(ctx context.Context, formats strfmt.Registry) error {
if m.Tenant != nil {
if swag.IsZero(m.Tenant) { // not required
return nil
}
if err := m.Tenant.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("tenant")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("tenant")
}
return err
}
}
return nil
}
func (m *Site) 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
}
func (m *Site) contextValidateVirtualmachineCount(ctx context.Context, formats strfmt.Registry) error {
if err := validate.ReadOnly(ctx, "virtualmachine_count", "body", int64(m.VirtualmachineCount)); err != nil {
return err
}
return nil
}
func (m *Site) contextValidateVlanCount(ctx context.Context, formats strfmt.Registry) error {
if err := validate.ReadOnly(ctx, "vlan_count", "body", int64(m.VlanCount)); err != nil {
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *Site) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *Site) UnmarshalBinary(b []byte) error {
var res Site
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}
// SiteStatus Status
//
// swagger:model SiteStatus
type SiteStatus struct {
// label
// Required: true
// Enum: ["Planned","Staging","Active","Decommissioning","Retired"]
Label *string `json:"label"`
// value
// Required: true
// Enum: ["planned","staging","active","decommissioning","retired"]
Value *string `json:"value"`
}
// Validate validates this site status
func (m *SiteStatus) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateLabel(formats); err != nil {
res = append(res, err)
}
if err := m.validateValue(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
var siteStatusTypeLabelPropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["Planned","Staging","Active","Decommissioning","Retired"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
siteStatusTypeLabelPropEnum = append(siteStatusTypeLabelPropEnum, v)
}
}
const (
// SiteStatusLabelPlanned captures enum value "Planned"
SiteStatusLabelPlanned string = "Planned"
// SiteStatusLabelStaging captures enum value "Staging"
SiteStatusLabelStaging string = "Staging"
// SiteStatusLabelActive captures enum value "Active"
SiteStatusLabelActive string = "Active"
// SiteStatusLabelDecommissioning captures enum value "Decommissioning"
SiteStatusLabelDecommissioning string = "Decommissioning"
// SiteStatusLabelRetired captures enum value "Retired"
SiteStatusLabelRetired string = "Retired"
)
// prop value enum
func (m *SiteStatus) validateLabelEnum(path, location string, value string) error {
if err := validate.EnumCase(path, location, value, siteStatusTypeLabelPropEnum, true); err != nil {
return err
}
return nil
}
func (m *SiteStatus) validateLabel(formats strfmt.Registry) error {
if err := validate.Required("status"+"."+"label", "body", m.Label); err != nil {
return err
}
// value enum
if err := m.validateLabelEnum("status"+"."+"label", "body", *m.Label); err != nil {
return err
}
return nil
}
var siteStatusTypeValuePropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["planned","staging","active","decommissioning","retired"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
siteStatusTypeValuePropEnum = append(siteStatusTypeValuePropEnum, v)
}
}
const (
// SiteStatusValuePlanned captures enum value "planned"
SiteStatusValuePlanned string = "planned"
// SiteStatusValueStaging captures enum value "staging"
SiteStatusValueStaging string = "staging"
// SiteStatusValueActive captures enum value "active"
SiteStatusValueActive string = "active"
// SiteStatusValueDecommissioning captures enum value "decommissioning"
SiteStatusValueDecommissioning string = "decommissioning"
// SiteStatusValueRetired captures enum value "retired"
SiteStatusValueRetired string = "retired"
)
// prop value enum
func (m *SiteStatus) validateValueEnum(path, location string, value string) error {
if err := validate.EnumCase(path, location, value, siteStatusTypeValuePropEnum, true); err != nil {
return err
}
return nil
}
func (m *SiteStatus) validateValue(formats strfmt.Registry) error {
if err := validate.Required("status"+"."+"value", "body", m.Value); err != nil {
return err
}
// value enum
if err := m.validateValueEnum("status"+"."+"value", "body", *m.Value); err != nil {
return err
}
return nil
}
// ContextValidate validates this site status based on context it is used
func (m *SiteStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *SiteStatus) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *SiteStatus) UnmarshalBinary(b []byte) error {
var res SiteStatus
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}