github.com/digitalocean/go-netbox@v0.0.2/netbox/models/writable_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 "strconv" 26 27 "github.com/go-openapi/errors" 28 "github.com/go-openapi/strfmt" 29 "github.com/go-openapi/swag" 30 "github.com/go-openapi/validate" 31 ) 32 33 // WritableConfigContext writable config context 34 // 35 // swagger:model WritableConfigContext 36 type WritableConfigContext struct { 37 38 // cluster groups 39 // Unique: true 40 ClusterGroups []int64 `json:"cluster_groups"` 41 42 // clusters 43 // Unique: true 44 Clusters []int64 `json:"clusters"` 45 46 // Created 47 // Read Only: true 48 // Format: date 49 Created strfmt.Date `json:"created,omitempty"` 50 51 // Data 52 // Required: true 53 Data *string `json:"data"` 54 55 // Description 56 // Max Length: 200 57 Description string `json:"description,omitempty"` 58 59 // device types 60 // Unique: true 61 DeviceTypes []int64 `json:"device_types"` 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 // Is active 72 IsActive bool `json:"is_active,omitempty"` 73 74 // Last updated 75 // Read Only: true 76 // Format: date-time 77 LastUpdated strfmt.DateTime `json:"last_updated,omitempty"` 78 79 // Name 80 // Required: true 81 // Max Length: 100 82 // Min Length: 1 83 Name *string `json:"name"` 84 85 // platforms 86 // Unique: true 87 Platforms []int64 `json:"platforms"` 88 89 // regions 90 // Unique: true 91 Regions []int64 `json:"regions"` 92 93 // roles 94 // Unique: true 95 Roles []int64 `json:"roles"` 96 97 // site groups 98 // Unique: true 99 SiteGroups []int64 `json:"site_groups"` 100 101 // sites 102 // Unique: true 103 Sites []int64 `json:"sites"` 104 105 // tags 106 // Unique: true 107 Tags []string `json:"tags"` 108 109 // tenant groups 110 // Unique: true 111 TenantGroups []int64 `json:"tenant_groups"` 112 113 // tenants 114 // Unique: true 115 Tenants []int64 `json:"tenants"` 116 117 // Url 118 // Read Only: true 119 // Format: uri 120 URL strfmt.URI `json:"url,omitempty"` 121 122 // Weight 123 // Maximum: 32767 124 // Minimum: 0 125 Weight *int64 `json:"weight,omitempty"` 126 } 127 128 // Validate validates this writable config context 129 func (m *WritableConfigContext) Validate(formats strfmt.Registry) error { 130 var res []error 131 132 if err := m.validateClusterGroups(formats); err != nil { 133 res = append(res, err) 134 } 135 136 if err := m.validateClusters(formats); err != nil { 137 res = append(res, err) 138 } 139 140 if err := m.validateCreated(formats); err != nil { 141 res = append(res, err) 142 } 143 144 if err := m.validateData(formats); err != nil { 145 res = append(res, err) 146 } 147 148 if err := m.validateDescription(formats); err != nil { 149 res = append(res, err) 150 } 151 152 if err := m.validateDeviceTypes(formats); err != nil { 153 res = append(res, err) 154 } 155 156 if err := m.validateLastUpdated(formats); err != nil { 157 res = append(res, err) 158 } 159 160 if err := m.validateName(formats); err != nil { 161 res = append(res, err) 162 } 163 164 if err := m.validatePlatforms(formats); err != nil { 165 res = append(res, err) 166 } 167 168 if err := m.validateRegions(formats); err != nil { 169 res = append(res, err) 170 } 171 172 if err := m.validateRoles(formats); err != nil { 173 res = append(res, err) 174 } 175 176 if err := m.validateSiteGroups(formats); err != nil { 177 res = append(res, err) 178 } 179 180 if err := m.validateSites(formats); err != nil { 181 res = append(res, err) 182 } 183 184 if err := m.validateTags(formats); err != nil { 185 res = append(res, err) 186 } 187 188 if err := m.validateTenantGroups(formats); err != nil { 189 res = append(res, err) 190 } 191 192 if err := m.validateTenants(formats); err != nil { 193 res = append(res, err) 194 } 195 196 if err := m.validateURL(formats); err != nil { 197 res = append(res, err) 198 } 199 200 if err := m.validateWeight(formats); err != nil { 201 res = append(res, err) 202 } 203 204 if len(res) > 0 { 205 return errors.CompositeValidationError(res...) 206 } 207 return nil 208 } 209 210 func (m *WritableConfigContext) validateClusterGroups(formats strfmt.Registry) error { 211 if swag.IsZero(m.ClusterGroups) { // not required 212 return nil 213 } 214 215 if err := validate.UniqueItems("cluster_groups", "body", m.ClusterGroups); err != nil { 216 return err 217 } 218 219 return nil 220 } 221 222 func (m *WritableConfigContext) validateClusters(formats strfmt.Registry) error { 223 if swag.IsZero(m.Clusters) { // not required 224 return nil 225 } 226 227 if err := validate.UniqueItems("clusters", "body", m.Clusters); err != nil { 228 return err 229 } 230 231 return nil 232 } 233 234 func (m *WritableConfigContext) validateCreated(formats strfmt.Registry) error { 235 if swag.IsZero(m.Created) { // not required 236 return nil 237 } 238 239 if err := validate.FormatOf("created", "body", "date", m.Created.String(), formats); err != nil { 240 return err 241 } 242 243 return nil 244 } 245 246 func (m *WritableConfigContext) validateData(formats strfmt.Registry) error { 247 248 if err := validate.Required("data", "body", m.Data); err != nil { 249 return err 250 } 251 252 return nil 253 } 254 255 func (m *WritableConfigContext) validateDescription(formats strfmt.Registry) error { 256 if swag.IsZero(m.Description) { // not required 257 return nil 258 } 259 260 if err := validate.MaxLength("description", "body", m.Description, 200); err != nil { 261 return err 262 } 263 264 return nil 265 } 266 267 func (m *WritableConfigContext) validateDeviceTypes(formats strfmt.Registry) error { 268 if swag.IsZero(m.DeviceTypes) { // not required 269 return nil 270 } 271 272 if err := validate.UniqueItems("device_types", "body", m.DeviceTypes); err != nil { 273 return err 274 } 275 276 return nil 277 } 278 279 func (m *WritableConfigContext) validateLastUpdated(formats strfmt.Registry) error { 280 if swag.IsZero(m.LastUpdated) { // not required 281 return nil 282 } 283 284 if err := validate.FormatOf("last_updated", "body", "date-time", m.LastUpdated.String(), formats); err != nil { 285 return err 286 } 287 288 return nil 289 } 290 291 func (m *WritableConfigContext) validateName(formats strfmt.Registry) error { 292 293 if err := validate.Required("name", "body", m.Name); err != nil { 294 return err 295 } 296 297 if err := validate.MinLength("name", "body", *m.Name, 1); err != nil { 298 return err 299 } 300 301 if err := validate.MaxLength("name", "body", *m.Name, 100); err != nil { 302 return err 303 } 304 305 return nil 306 } 307 308 func (m *WritableConfigContext) validatePlatforms(formats strfmt.Registry) error { 309 if swag.IsZero(m.Platforms) { // not required 310 return nil 311 } 312 313 if err := validate.UniqueItems("platforms", "body", m.Platforms); err != nil { 314 return err 315 } 316 317 return nil 318 } 319 320 func (m *WritableConfigContext) validateRegions(formats strfmt.Registry) error { 321 if swag.IsZero(m.Regions) { // not required 322 return nil 323 } 324 325 if err := validate.UniqueItems("regions", "body", m.Regions); err != nil { 326 return err 327 } 328 329 return nil 330 } 331 332 func (m *WritableConfigContext) validateRoles(formats strfmt.Registry) error { 333 if swag.IsZero(m.Roles) { // not required 334 return nil 335 } 336 337 if err := validate.UniqueItems("roles", "body", m.Roles); err != nil { 338 return err 339 } 340 341 return nil 342 } 343 344 func (m *WritableConfigContext) validateSiteGroups(formats strfmt.Registry) error { 345 if swag.IsZero(m.SiteGroups) { // not required 346 return nil 347 } 348 349 if err := validate.UniqueItems("site_groups", "body", m.SiteGroups); err != nil { 350 return err 351 } 352 353 return nil 354 } 355 356 func (m *WritableConfigContext) validateSites(formats strfmt.Registry) error { 357 if swag.IsZero(m.Sites) { // not required 358 return nil 359 } 360 361 if err := validate.UniqueItems("sites", "body", m.Sites); err != nil { 362 return err 363 } 364 365 return nil 366 } 367 368 func (m *WritableConfigContext) validateTags(formats strfmt.Registry) error { 369 if swag.IsZero(m.Tags) { // not required 370 return nil 371 } 372 373 if err := validate.UniqueItems("tags", "body", m.Tags); err != nil { 374 return err 375 } 376 377 for i := 0; i < len(m.Tags); i++ { 378 379 if err := validate.Pattern("tags"+"."+strconv.Itoa(i), "body", m.Tags[i], `^[-a-zA-Z0-9_]+$`); err != nil { 380 return err 381 } 382 383 } 384 385 return nil 386 } 387 388 func (m *WritableConfigContext) validateTenantGroups(formats strfmt.Registry) error { 389 if swag.IsZero(m.TenantGroups) { // not required 390 return nil 391 } 392 393 if err := validate.UniqueItems("tenant_groups", "body", m.TenantGroups); err != nil { 394 return err 395 } 396 397 return nil 398 } 399 400 func (m *WritableConfigContext) validateTenants(formats strfmt.Registry) error { 401 if swag.IsZero(m.Tenants) { // not required 402 return nil 403 } 404 405 if err := validate.UniqueItems("tenants", "body", m.Tenants); err != nil { 406 return err 407 } 408 409 return nil 410 } 411 412 func (m *WritableConfigContext) validateURL(formats strfmt.Registry) error { 413 if swag.IsZero(m.URL) { // not required 414 return nil 415 } 416 417 if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil { 418 return err 419 } 420 421 return nil 422 } 423 424 func (m *WritableConfigContext) validateWeight(formats strfmt.Registry) error { 425 if swag.IsZero(m.Weight) { // not required 426 return nil 427 } 428 429 if err := validate.MinimumInt("weight", "body", *m.Weight, 0, false); err != nil { 430 return err 431 } 432 433 if err := validate.MaximumInt("weight", "body", *m.Weight, 32767, false); err != nil { 434 return err 435 } 436 437 return nil 438 } 439 440 // ContextValidate validate this writable config context based on the context it is used 441 func (m *WritableConfigContext) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 442 var res []error 443 444 if err := m.contextValidateCreated(ctx, formats); err != nil { 445 res = append(res, err) 446 } 447 448 if err := m.contextValidateDisplay(ctx, formats); err != nil { 449 res = append(res, err) 450 } 451 452 if err := m.contextValidateID(ctx, formats); err != nil { 453 res = append(res, err) 454 } 455 456 if err := m.contextValidateLastUpdated(ctx, formats); err != nil { 457 res = append(res, err) 458 } 459 460 if err := m.contextValidateURL(ctx, formats); err != nil { 461 res = append(res, err) 462 } 463 464 if len(res) > 0 { 465 return errors.CompositeValidationError(res...) 466 } 467 return nil 468 } 469 470 func (m *WritableConfigContext) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error { 471 472 if err := validate.ReadOnly(ctx, "created", "body", strfmt.Date(m.Created)); err != nil { 473 return err 474 } 475 476 return nil 477 } 478 479 func (m *WritableConfigContext) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error { 480 481 if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil { 482 return err 483 } 484 485 return nil 486 } 487 488 func (m *WritableConfigContext) contextValidateID(ctx context.Context, formats strfmt.Registry) error { 489 490 if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil { 491 return err 492 } 493 494 return nil 495 } 496 497 func (m *WritableConfigContext) contextValidateLastUpdated(ctx context.Context, formats strfmt.Registry) error { 498 499 if err := validate.ReadOnly(ctx, "last_updated", "body", strfmt.DateTime(m.LastUpdated)); err != nil { 500 return err 501 } 502 503 return nil 504 } 505 506 func (m *WritableConfigContext) contextValidateURL(ctx context.Context, formats strfmt.Registry) error { 507 508 if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil { 509 return err 510 } 511 512 return nil 513 } 514 515 // MarshalBinary interface implementation 516 func (m *WritableConfigContext) MarshalBinary() ([]byte, error) { 517 if m == nil { 518 return nil, nil 519 } 520 return swag.WriteJSON(m) 521 } 522 523 // UnmarshalBinary interface implementation 524 func (m *WritableConfigContext) UnmarshalBinary(b []byte) error { 525 var res WritableConfigContext 526 if err := swag.ReadJSON(b, &res); err != nil { 527 return err 528 } 529 *m = res 530 return nil 531 }