github.com/digitalocean/go-netbox@v0.0.2/netbox/models/writable_virtual_machine_with_config_context.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 // WritableVirtualMachineWithConfigContext writable virtual machine with config context 35 // 36 // swagger:model WritableVirtualMachineWithConfigContext 37 type WritableVirtualMachineWithConfigContext struct { 38 39 // Cluster 40 // Required: true 41 Cluster *int64 `json:"cluster"` 42 43 // Comments 44 Comments string `json:"comments,omitempty"` 45 46 // Config context 47 // Read Only: true 48 ConfigContext map[string]*string `json:"config_context,omitempty"` 49 50 // Created 51 // Read Only: true 52 // Format: date 53 Created strfmt.Date `json:"created,omitempty"` 54 55 // Custom fields 56 CustomFields interface{} `json:"custom_fields,omitempty"` 57 58 // Disk (GB) 59 // Maximum: 2.147483647e+09 60 // Minimum: 0 61 Disk *int64 `json:"disk,omitempty"` 62 63 // Display 64 // Read Only: true 65 Display string `json:"display,omitempty"` 66 67 // Id 68 // Read Only: true 69 ID int64 `json:"id,omitempty"` 70 71 // Last updated 72 // Read Only: true 73 // Format: date-time 74 LastUpdated strfmt.DateTime `json:"last_updated,omitempty"` 75 76 // Local context data 77 LocalContextData *string `json:"local_context_data,omitempty"` 78 79 // Memory (MB) 80 // Maximum: 2.147483647e+09 81 // Minimum: 0 82 Memory *int64 `json:"memory,omitempty"` 83 84 // Name 85 // Required: true 86 // Max Length: 64 87 // Min Length: 1 88 Name *string `json:"name"` 89 90 // Platform 91 Platform *int64 `json:"platform,omitempty"` 92 93 // Primary ip 94 // Read Only: true 95 PrimaryIP string `json:"primary_ip,omitempty"` 96 97 // Primary IPv4 98 PrimaryIp4 *int64 `json:"primary_ip4,omitempty"` 99 100 // Primary IPv6 101 PrimaryIp6 *int64 `json:"primary_ip6,omitempty"` 102 103 // Role 104 Role *int64 `json:"role,omitempty"` 105 106 // Site 107 // Read Only: true 108 Site string `json:"site,omitempty"` 109 110 // Status 111 // Enum: [offline active planned staged failed decommissioning] 112 Status string `json:"status,omitempty"` 113 114 // tags 115 Tags []*NestedTag `json:"tags"` 116 117 // Tenant 118 Tenant *int64 `json:"tenant,omitempty"` 119 120 // Url 121 // Read Only: true 122 // Format: uri 123 URL strfmt.URI `json:"url,omitempty"` 124 125 // VCPUs 126 Vcpus *string `json:"vcpus,omitempty"` 127 } 128 129 // Validate validates this writable virtual machine with config context 130 func (m *WritableVirtualMachineWithConfigContext) Validate(formats strfmt.Registry) error { 131 var res []error 132 133 if err := m.validateCluster(formats); err != nil { 134 res = append(res, err) 135 } 136 137 if err := m.validateCreated(formats); err != nil { 138 res = append(res, err) 139 } 140 141 if err := m.validateDisk(formats); err != nil { 142 res = append(res, err) 143 } 144 145 if err := m.validateLastUpdated(formats); err != nil { 146 res = append(res, err) 147 } 148 149 if err := m.validateMemory(formats); err != nil { 150 res = append(res, err) 151 } 152 153 if err := m.validateName(formats); err != nil { 154 res = append(res, err) 155 } 156 157 if err := m.validateStatus(formats); err != nil { 158 res = append(res, err) 159 } 160 161 if err := m.validateTags(formats); err != nil { 162 res = append(res, err) 163 } 164 165 if err := m.validateURL(formats); err != nil { 166 res = append(res, err) 167 } 168 169 if len(res) > 0 { 170 return errors.CompositeValidationError(res...) 171 } 172 return nil 173 } 174 175 func (m *WritableVirtualMachineWithConfigContext) validateCluster(formats strfmt.Registry) error { 176 177 if err := validate.Required("cluster", "body", m.Cluster); err != nil { 178 return err 179 } 180 181 return nil 182 } 183 184 func (m *WritableVirtualMachineWithConfigContext) validateCreated(formats strfmt.Registry) error { 185 if swag.IsZero(m.Created) { // not required 186 return nil 187 } 188 189 if err := validate.FormatOf("created", "body", "date", m.Created.String(), formats); err != nil { 190 return err 191 } 192 193 return nil 194 } 195 196 func (m *WritableVirtualMachineWithConfigContext) validateDisk(formats strfmt.Registry) error { 197 if swag.IsZero(m.Disk) { // not required 198 return nil 199 } 200 201 if err := validate.MinimumInt("disk", "body", *m.Disk, 0, false); err != nil { 202 return err 203 } 204 205 if err := validate.MaximumInt("disk", "body", *m.Disk, 2.147483647e+09, false); err != nil { 206 return err 207 } 208 209 return nil 210 } 211 212 func (m *WritableVirtualMachineWithConfigContext) validateLastUpdated(formats strfmt.Registry) error { 213 if swag.IsZero(m.LastUpdated) { // not required 214 return nil 215 } 216 217 if err := validate.FormatOf("last_updated", "body", "date-time", m.LastUpdated.String(), formats); err != nil { 218 return err 219 } 220 221 return nil 222 } 223 224 func (m *WritableVirtualMachineWithConfigContext) validateMemory(formats strfmt.Registry) error { 225 if swag.IsZero(m.Memory) { // not required 226 return nil 227 } 228 229 if err := validate.MinimumInt("memory", "body", *m.Memory, 0, false); err != nil { 230 return err 231 } 232 233 if err := validate.MaximumInt("memory", "body", *m.Memory, 2.147483647e+09, false); err != nil { 234 return err 235 } 236 237 return nil 238 } 239 240 func (m *WritableVirtualMachineWithConfigContext) validateName(formats strfmt.Registry) error { 241 242 if err := validate.Required("name", "body", m.Name); err != nil { 243 return err 244 } 245 246 if err := validate.MinLength("name", "body", *m.Name, 1); err != nil { 247 return err 248 } 249 250 if err := validate.MaxLength("name", "body", *m.Name, 64); err != nil { 251 return err 252 } 253 254 return nil 255 } 256 257 var writableVirtualMachineWithConfigContextTypeStatusPropEnum []interface{} 258 259 func init() { 260 var res []string 261 if err := json.Unmarshal([]byte(`["offline","active","planned","staged","failed","decommissioning"]`), &res); err != nil { 262 panic(err) 263 } 264 for _, v := range res { 265 writableVirtualMachineWithConfigContextTypeStatusPropEnum = append(writableVirtualMachineWithConfigContextTypeStatusPropEnum, v) 266 } 267 } 268 269 const ( 270 271 // WritableVirtualMachineWithConfigContextStatusOffline captures enum value "offline" 272 WritableVirtualMachineWithConfigContextStatusOffline string = "offline" 273 274 // WritableVirtualMachineWithConfigContextStatusActive captures enum value "active" 275 WritableVirtualMachineWithConfigContextStatusActive string = "active" 276 277 // WritableVirtualMachineWithConfigContextStatusPlanned captures enum value "planned" 278 WritableVirtualMachineWithConfigContextStatusPlanned string = "planned" 279 280 // WritableVirtualMachineWithConfigContextStatusStaged captures enum value "staged" 281 WritableVirtualMachineWithConfigContextStatusStaged string = "staged" 282 283 // WritableVirtualMachineWithConfigContextStatusFailed captures enum value "failed" 284 WritableVirtualMachineWithConfigContextStatusFailed string = "failed" 285 286 // WritableVirtualMachineWithConfigContextStatusDecommissioning captures enum value "decommissioning" 287 WritableVirtualMachineWithConfigContextStatusDecommissioning string = "decommissioning" 288 ) 289 290 // prop value enum 291 func (m *WritableVirtualMachineWithConfigContext) validateStatusEnum(path, location string, value string) error { 292 if err := validate.EnumCase(path, location, value, writableVirtualMachineWithConfigContextTypeStatusPropEnum, true); err != nil { 293 return err 294 } 295 return nil 296 } 297 298 func (m *WritableVirtualMachineWithConfigContext) validateStatus(formats strfmt.Registry) error { 299 if swag.IsZero(m.Status) { // not required 300 return nil 301 } 302 303 // value enum 304 if err := m.validateStatusEnum("status", "body", m.Status); err != nil { 305 return err 306 } 307 308 return nil 309 } 310 311 func (m *WritableVirtualMachineWithConfigContext) validateTags(formats strfmt.Registry) error { 312 if swag.IsZero(m.Tags) { // not required 313 return nil 314 } 315 316 for i := 0; i < len(m.Tags); i++ { 317 if swag.IsZero(m.Tags[i]) { // not required 318 continue 319 } 320 321 if m.Tags[i] != nil { 322 if err := m.Tags[i].Validate(formats); err != nil { 323 if ve, ok := err.(*errors.Validation); ok { 324 return ve.ValidateName("tags" + "." + strconv.Itoa(i)) 325 } else if ce, ok := err.(*errors.CompositeError); ok { 326 return ce.ValidateName("tags" + "." + strconv.Itoa(i)) 327 } 328 return err 329 } 330 } 331 332 } 333 334 return nil 335 } 336 337 func (m *WritableVirtualMachineWithConfigContext) validateURL(formats strfmt.Registry) error { 338 if swag.IsZero(m.URL) { // not required 339 return nil 340 } 341 342 if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil { 343 return err 344 } 345 346 return nil 347 } 348 349 // ContextValidate validate this writable virtual machine with config context based on the context it is used 350 func (m *WritableVirtualMachineWithConfigContext) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 351 var res []error 352 353 if err := m.contextValidateConfigContext(ctx, formats); err != nil { 354 res = append(res, err) 355 } 356 357 if err := m.contextValidateCreated(ctx, formats); err != nil { 358 res = append(res, err) 359 } 360 361 if err := m.contextValidateDisplay(ctx, formats); err != nil { 362 res = append(res, err) 363 } 364 365 if err := m.contextValidateID(ctx, formats); err != nil { 366 res = append(res, err) 367 } 368 369 if err := m.contextValidateLastUpdated(ctx, formats); err != nil { 370 res = append(res, err) 371 } 372 373 if err := m.contextValidatePrimaryIP(ctx, formats); err != nil { 374 res = append(res, err) 375 } 376 377 if err := m.contextValidateSite(ctx, formats); err != nil { 378 res = append(res, err) 379 } 380 381 if err := m.contextValidateTags(ctx, formats); err != nil { 382 res = append(res, err) 383 } 384 385 if err := m.contextValidateURL(ctx, formats); err != nil { 386 res = append(res, err) 387 } 388 389 if len(res) > 0 { 390 return errors.CompositeValidationError(res...) 391 } 392 return nil 393 } 394 395 func (m *WritableVirtualMachineWithConfigContext) contextValidateConfigContext(ctx context.Context, formats strfmt.Registry) error { 396 397 return nil 398 } 399 400 func (m *WritableVirtualMachineWithConfigContext) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error { 401 402 if err := validate.ReadOnly(ctx, "created", "body", strfmt.Date(m.Created)); err != nil { 403 return err 404 } 405 406 return nil 407 } 408 409 func (m *WritableVirtualMachineWithConfigContext) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error { 410 411 if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil { 412 return err 413 } 414 415 return nil 416 } 417 418 func (m *WritableVirtualMachineWithConfigContext) contextValidateID(ctx context.Context, formats strfmt.Registry) error { 419 420 if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil { 421 return err 422 } 423 424 return nil 425 } 426 427 func (m *WritableVirtualMachineWithConfigContext) contextValidateLastUpdated(ctx context.Context, formats strfmt.Registry) error { 428 429 if err := validate.ReadOnly(ctx, "last_updated", "body", strfmt.DateTime(m.LastUpdated)); err != nil { 430 return err 431 } 432 433 return nil 434 } 435 436 func (m *WritableVirtualMachineWithConfigContext) contextValidatePrimaryIP(ctx context.Context, formats strfmt.Registry) error { 437 438 if err := validate.ReadOnly(ctx, "primary_ip", "body", string(m.PrimaryIP)); err != nil { 439 return err 440 } 441 442 return nil 443 } 444 445 func (m *WritableVirtualMachineWithConfigContext) contextValidateSite(ctx context.Context, formats strfmt.Registry) error { 446 447 if err := validate.ReadOnly(ctx, "site", "body", string(m.Site)); err != nil { 448 return err 449 } 450 451 return nil 452 } 453 454 func (m *WritableVirtualMachineWithConfigContext) contextValidateTags(ctx context.Context, formats strfmt.Registry) error { 455 456 for i := 0; i < len(m.Tags); i++ { 457 458 if m.Tags[i] != nil { 459 if err := m.Tags[i].ContextValidate(ctx, formats); err != nil { 460 if ve, ok := err.(*errors.Validation); ok { 461 return ve.ValidateName("tags" + "." + strconv.Itoa(i)) 462 } else if ce, ok := err.(*errors.CompositeError); ok { 463 return ce.ValidateName("tags" + "." + strconv.Itoa(i)) 464 } 465 return err 466 } 467 } 468 469 } 470 471 return nil 472 } 473 474 func (m *WritableVirtualMachineWithConfigContext) contextValidateURL(ctx context.Context, formats strfmt.Registry) error { 475 476 if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil { 477 return err 478 } 479 480 return nil 481 } 482 483 // MarshalBinary interface implementation 484 func (m *WritableVirtualMachineWithConfigContext) MarshalBinary() ([]byte, error) { 485 if m == nil { 486 return nil, nil 487 } 488 return swag.WriteJSON(m) 489 } 490 491 // UnmarshalBinary interface implementation 492 func (m *WritableVirtualMachineWithConfigContext) UnmarshalBinary(b []byte) error { 493 var res WritableVirtualMachineWithConfigContext 494 if err := swag.ReadJSON(b, &res); err != nil { 495 return err 496 } 497 *m = res 498 return nil 499 }