github.com/digitalocean/go-netbox@v0.0.2/netbox/models/writable_v_l_a_n.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 // Copyright 2020 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 // 17 18 package models 19 20 // This file was generated by the swagger tool. 21 // Editing this file might prove futile when you re-run the swagger generate command 22 23 import ( 24 "context" 25 "encoding/json" 26 "strconv" 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 // WritableVLAN writable v l a n 35 // 36 // swagger:model WritableVLAN 37 type WritableVLAN struct { 38 39 // Created 40 // Read Only: true 41 // Format: date 42 Created strfmt.Date `json:"created,omitempty"` 43 44 // Custom fields 45 CustomFields interface{} `json:"custom_fields,omitempty"` 46 47 // Description 48 // Max Length: 200 49 Description string `json:"description,omitempty"` 50 51 // Display 52 // Read Only: true 53 Display string `json:"display,omitempty"` 54 55 // Display name 56 // Read Only: true 57 DisplayName string `json:"display_name,omitempty"` 58 59 // Group 60 Group *int64 `json:"group,omitempty"` 61 62 // Id 63 // Read Only: true 64 ID int64 `json:"id,omitempty"` 65 66 // Last updated 67 // Read Only: true 68 // Format: date-time 69 LastUpdated strfmt.DateTime `json:"last_updated,omitempty"` 70 71 // Name 72 // Required: true 73 // Max Length: 64 74 // Min Length: 1 75 Name *string `json:"name"` 76 77 // Prefix count 78 // Read Only: true 79 PrefixCount int64 `json:"prefix_count,omitempty"` 80 81 // Role 82 Role *int64 `json:"role,omitempty"` 83 84 // Site 85 Site *int64 `json:"site,omitempty"` 86 87 // Status 88 // Enum: [active reserved deprecated] 89 Status string `json:"status,omitempty"` 90 91 // tags 92 Tags []*NestedTag `json:"tags"` 93 94 // Tenant 95 Tenant *int64 `json:"tenant,omitempty"` 96 97 // Url 98 // Read Only: true 99 // Format: uri 100 URL strfmt.URI `json:"url,omitempty"` 101 102 // ID 103 // Required: true 104 // Maximum: 4094 105 // Minimum: 1 106 Vid *int64 `json:"vid"` 107 } 108 109 // Validate validates this writable v l a n 110 func (m *WritableVLAN) Validate(formats strfmt.Registry) error { 111 var res []error 112 113 if err := m.validateCreated(formats); err != nil { 114 res = append(res, err) 115 } 116 117 if err := m.validateDescription(formats); err != nil { 118 res = append(res, err) 119 } 120 121 if err := m.validateLastUpdated(formats); err != nil { 122 res = append(res, err) 123 } 124 125 if err := m.validateName(formats); err != nil { 126 res = append(res, err) 127 } 128 129 if err := m.validateStatus(formats); err != nil { 130 res = append(res, err) 131 } 132 133 if err := m.validateTags(formats); err != nil { 134 res = append(res, err) 135 } 136 137 if err := m.validateURL(formats); err != nil { 138 res = append(res, err) 139 } 140 141 if err := m.validateVid(formats); err != nil { 142 res = append(res, err) 143 } 144 145 if len(res) > 0 { 146 return errors.CompositeValidationError(res...) 147 } 148 return nil 149 } 150 151 func (m *WritableVLAN) validateCreated(formats strfmt.Registry) error { 152 if swag.IsZero(m.Created) { // not required 153 return nil 154 } 155 156 if err := validate.FormatOf("created", "body", "date", m.Created.String(), formats); err != nil { 157 return err 158 } 159 160 return nil 161 } 162 163 func (m *WritableVLAN) validateDescription(formats strfmt.Registry) error { 164 if swag.IsZero(m.Description) { // not required 165 return nil 166 } 167 168 if err := validate.MaxLength("description", "body", m.Description, 200); err != nil { 169 return err 170 } 171 172 return nil 173 } 174 175 func (m *WritableVLAN) validateLastUpdated(formats strfmt.Registry) error { 176 if swag.IsZero(m.LastUpdated) { // not required 177 return nil 178 } 179 180 if err := validate.FormatOf("last_updated", "body", "date-time", m.LastUpdated.String(), formats); err != nil { 181 return err 182 } 183 184 return nil 185 } 186 187 func (m *WritableVLAN) validateName(formats strfmt.Registry) error { 188 189 if err := validate.Required("name", "body", m.Name); err != nil { 190 return err 191 } 192 193 if err := validate.MinLength("name", "body", *m.Name, 1); err != nil { 194 return err 195 } 196 197 if err := validate.MaxLength("name", "body", *m.Name, 64); err != nil { 198 return err 199 } 200 201 return nil 202 } 203 204 var writableVLANTypeStatusPropEnum []interface{} 205 206 func init() { 207 var res []string 208 if err := json.Unmarshal([]byte(`["active","reserved","deprecated"]`), &res); err != nil { 209 panic(err) 210 } 211 for _, v := range res { 212 writableVLANTypeStatusPropEnum = append(writableVLANTypeStatusPropEnum, v) 213 } 214 } 215 216 const ( 217 218 // WritableVLANStatusActive captures enum value "active" 219 WritableVLANStatusActive string = "active" 220 221 // WritableVLANStatusReserved captures enum value "reserved" 222 WritableVLANStatusReserved string = "reserved" 223 224 // WritableVLANStatusDeprecated captures enum value "deprecated" 225 WritableVLANStatusDeprecated string = "deprecated" 226 ) 227 228 // prop value enum 229 func (m *WritableVLAN) validateStatusEnum(path, location string, value string) error { 230 if err := validate.EnumCase(path, location, value, writableVLANTypeStatusPropEnum, true); err != nil { 231 return err 232 } 233 return nil 234 } 235 236 func (m *WritableVLAN) validateStatus(formats strfmt.Registry) error { 237 if swag.IsZero(m.Status) { // not required 238 return nil 239 } 240 241 // value enum 242 if err := m.validateStatusEnum("status", "body", m.Status); err != nil { 243 return err 244 } 245 246 return nil 247 } 248 249 func (m *WritableVLAN) validateTags(formats strfmt.Registry) error { 250 if swag.IsZero(m.Tags) { // not required 251 return nil 252 } 253 254 for i := 0; i < len(m.Tags); i++ { 255 if swag.IsZero(m.Tags[i]) { // not required 256 continue 257 } 258 259 if m.Tags[i] != nil { 260 if err := m.Tags[i].Validate(formats); err != nil { 261 if ve, ok := err.(*errors.Validation); ok { 262 return ve.ValidateName("tags" + "." + strconv.Itoa(i)) 263 } else if ce, ok := err.(*errors.CompositeError); ok { 264 return ce.ValidateName("tags" + "." + strconv.Itoa(i)) 265 } 266 return err 267 } 268 } 269 270 } 271 272 return nil 273 } 274 275 func (m *WritableVLAN) validateURL(formats strfmt.Registry) error { 276 if swag.IsZero(m.URL) { // not required 277 return nil 278 } 279 280 if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil { 281 return err 282 } 283 284 return nil 285 } 286 287 func (m *WritableVLAN) validateVid(formats strfmt.Registry) error { 288 289 if err := validate.Required("vid", "body", m.Vid); err != nil { 290 return err 291 } 292 293 if err := validate.MinimumInt("vid", "body", *m.Vid, 1, false); err != nil { 294 return err 295 } 296 297 if err := validate.MaximumInt("vid", "body", *m.Vid, 4094, false); err != nil { 298 return err 299 } 300 301 return nil 302 } 303 304 // ContextValidate validate this writable v l a n based on the context it is used 305 func (m *WritableVLAN) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 306 var res []error 307 308 if err := m.contextValidateCreated(ctx, formats); err != nil { 309 res = append(res, err) 310 } 311 312 if err := m.contextValidateDisplay(ctx, formats); err != nil { 313 res = append(res, err) 314 } 315 316 if err := m.contextValidateDisplayName(ctx, formats); err != nil { 317 res = append(res, err) 318 } 319 320 if err := m.contextValidateID(ctx, formats); err != nil { 321 res = append(res, err) 322 } 323 324 if err := m.contextValidateLastUpdated(ctx, formats); err != nil { 325 res = append(res, err) 326 } 327 328 if err := m.contextValidatePrefixCount(ctx, formats); err != nil { 329 res = append(res, err) 330 } 331 332 if err := m.contextValidateTags(ctx, formats); err != nil { 333 res = append(res, err) 334 } 335 336 if err := m.contextValidateURL(ctx, formats); err != nil { 337 res = append(res, err) 338 } 339 340 if len(res) > 0 { 341 return errors.CompositeValidationError(res...) 342 } 343 return nil 344 } 345 346 func (m *WritableVLAN) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error { 347 348 if err := validate.ReadOnly(ctx, "created", "body", strfmt.Date(m.Created)); err != nil { 349 return err 350 } 351 352 return nil 353 } 354 355 func (m *WritableVLAN) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error { 356 357 if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil { 358 return err 359 } 360 361 return nil 362 } 363 364 func (m *WritableVLAN) contextValidateDisplayName(ctx context.Context, formats strfmt.Registry) error { 365 366 if err := validate.ReadOnly(ctx, "display_name", "body", string(m.DisplayName)); err != nil { 367 return err 368 } 369 370 return nil 371 } 372 373 func (m *WritableVLAN) contextValidateID(ctx context.Context, formats strfmt.Registry) error { 374 375 if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil { 376 return err 377 } 378 379 return nil 380 } 381 382 func (m *WritableVLAN) contextValidateLastUpdated(ctx context.Context, formats strfmt.Registry) error { 383 384 if err := validate.ReadOnly(ctx, "last_updated", "body", strfmt.DateTime(m.LastUpdated)); err != nil { 385 return err 386 } 387 388 return nil 389 } 390 391 func (m *WritableVLAN) contextValidatePrefixCount(ctx context.Context, formats strfmt.Registry) error { 392 393 if err := validate.ReadOnly(ctx, "prefix_count", "body", int64(m.PrefixCount)); err != nil { 394 return err 395 } 396 397 return nil 398 } 399 400 func (m *WritableVLAN) contextValidateTags(ctx context.Context, formats strfmt.Registry) error { 401 402 for i := 0; i < len(m.Tags); i++ { 403 404 if m.Tags[i] != nil { 405 if err := m.Tags[i].ContextValidate(ctx, formats); err != nil { 406 if ve, ok := err.(*errors.Validation); ok { 407 return ve.ValidateName("tags" + "." + strconv.Itoa(i)) 408 } else if ce, ok := err.(*errors.CompositeError); ok { 409 return ce.ValidateName("tags" + "." + strconv.Itoa(i)) 410 } 411 return err 412 } 413 } 414 415 } 416 417 return nil 418 } 419 420 func (m *WritableVLAN) contextValidateURL(ctx context.Context, formats strfmt.Registry) error { 421 422 if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil { 423 return err 424 } 425 426 return nil 427 } 428 429 // MarshalBinary interface implementation 430 func (m *WritableVLAN) MarshalBinary() ([]byte, error) { 431 if m == nil { 432 return nil, nil 433 } 434 return swag.WriteJSON(m) 435 } 436 437 // UnmarshalBinary interface implementation 438 func (m *WritableVLAN) UnmarshalBinary(b []byte) error { 439 var res WritableVLAN 440 if err := swag.ReadJSON(b, &res); err != nil { 441 return err 442 } 443 *m = res 444 return nil 445 }