blob: d0c730b129cf48434d70872dba28b08f39564d0a [file] [log] [blame]
Serge Bazanskicc25bdf2018-10-25 14:02:58 +02001// Code generated by go-swagger; DO NOT EDIT.
2
3// Copyright 2018 The go-netbox Authors.
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
17package models
18
19// This file was generated by the swagger tool.
20// Editing this file might prove futile when you re-run the swagger generate command
21
22import (
23 "encoding/json"
24
25 strfmt "github.com/go-openapi/strfmt"
26
27 "github.com/go-openapi/errors"
28 "github.com/go-openapi/swag"
29 "github.com/go-openapi/validate"
30)
31
32// Aggregate aggregate
33// swagger:model Aggregate
34type Aggregate struct {
35
36 // Created
37 // Read Only: true
38 Created strfmt.Date `json:"created,omitempty"`
39
40 // Custom fields
41 CustomFields interface{} `json:"custom_fields,omitempty"`
42
43 // Date added
44 DateAdded strfmt.Date `json:"date_added,omitempty"`
45
46 // Description
47 // Max Length: 100
48 Description string `json:"description,omitempty"`
49
50 // Family
51 // Required: true
52 Family *int64 `json:"family"`
53
54 // ID
55 // Read Only: true
56 ID int64 `json:"id,omitempty"`
57
58 // Last updated
59 // Read Only: true
60 LastUpdated strfmt.DateTime `json:"last_updated,omitempty"`
61
62 // Prefix
63 // Required: true
64 Prefix *string `json:"prefix"`
65
66 // rir
67 // Required: true
68 Rir *NestedRIR `json:"rir"`
69}
70
71// Validate validates this aggregate
72func (m *Aggregate) Validate(formats strfmt.Registry) error {
73 var res []error
74
75 if err := m.validateDescription(formats); err != nil {
76 // prop
77 res = append(res, err)
78 }
79
80 if err := m.validateFamily(formats); err != nil {
81 // prop
82 res = append(res, err)
83 }
84
85 if err := m.validatePrefix(formats); err != nil {
86 // prop
87 res = append(res, err)
88 }
89
90 if err := m.validateRir(formats); err != nil {
91 // prop
92 res = append(res, err)
93 }
94
95 if len(res) > 0 {
96 return errors.CompositeValidationError(res...)
97 }
98 return nil
99}
100
101func (m *Aggregate) validateDescription(formats strfmt.Registry) error {
102
103 if swag.IsZero(m.Description) { // not required
104 return nil
105 }
106
107 if err := validate.MaxLength("description", "body", string(m.Description), 100); err != nil {
108 return err
109 }
110
111 return nil
112}
113
114var aggregateTypeFamilyPropEnum []interface{}
115
116func init() {
117 var res []int64
118 if err := json.Unmarshal([]byte(`[4,6]`), &res); err != nil {
119 panic(err)
120 }
121 for _, v := range res {
122 aggregateTypeFamilyPropEnum = append(aggregateTypeFamilyPropEnum, v)
123 }
124}
125
126// prop value enum
127func (m *Aggregate) validateFamilyEnum(path, location string, value int64) error {
128 if err := validate.Enum(path, location, value, aggregateTypeFamilyPropEnum); err != nil {
129 return err
130 }
131 return nil
132}
133
134func (m *Aggregate) validateFamily(formats strfmt.Registry) error {
135
136 if err := validate.Required("family", "body", m.Family); err != nil {
137 return err
138 }
139
140 // value enum
141 if err := m.validateFamilyEnum("family", "body", *m.Family); err != nil {
142 return err
143 }
144
145 return nil
146}
147
148func (m *Aggregate) validatePrefix(formats strfmt.Registry) error {
149
150 if err := validate.Required("prefix", "body", m.Prefix); err != nil {
151 return err
152 }
153
154 return nil
155}
156
157func (m *Aggregate) validateRir(formats strfmt.Registry) error {
158
159 if err := validate.Required("rir", "body", m.Rir); err != nil {
160 return err
161 }
162
163 if m.Rir != nil {
164
165 if err := m.Rir.Validate(formats); err != nil {
166 if ve, ok := err.(*errors.Validation); ok {
167 return ve.ValidateName("rir")
168 }
169 return err
170 }
171 }
172
173 return nil
174}
175
176// MarshalBinary interface implementation
177func (m *Aggregate) MarshalBinary() ([]byte, error) {
178 if m == nil {
179 return nil, nil
180 }
181 return swag.WriteJSON(m)
182}
183
184// UnmarshalBinary interface implementation
185func (m *Aggregate) UnmarshalBinary(b []byte) error {
186 var res Aggregate
187 if err := swag.ReadJSON(b, &res); err != nil {
188 return err
189 }
190 *m = res
191 return nil
192}