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