github.com/digitalocean/go-netbox@v0.0.2/netbox/models/journal_entry.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 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 // JournalEntry journal entry 34 // 35 // swagger:model JournalEntry 36 type JournalEntry struct { 37 38 // Assigned object 39 // Read Only: true 40 AssignedObject map[string]*string `json:"assigned_object,omitempty"` 41 42 // Assigned object id 43 // Required: true 44 // Maximum: 2.147483647e+09 45 // Minimum: 0 46 AssignedObjectID *int64 `json:"assigned_object_id"` 47 48 // Assigned object type 49 // Required: true 50 AssignedObjectType *string `json:"assigned_object_type"` 51 52 // Comments 53 // Required: true 54 // Min Length: 1 55 Comments *string `json:"comments"` 56 57 // Created 58 // Read Only: true 59 // Format: date-time 60 Created strfmt.DateTime `json:"created,omitempty"` 61 62 // Created by 63 CreatedBy *int64 `json:"created_by,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 // kind 74 Kind *JournalEntryKind `json:"kind,omitempty"` 75 76 // Url 77 // Read Only: true 78 // Format: uri 79 URL strfmt.URI `json:"url,omitempty"` 80 } 81 82 // Validate validates this journal entry 83 func (m *JournalEntry) Validate(formats strfmt.Registry) error { 84 var res []error 85 86 if err := m.validateAssignedObjectID(formats); err != nil { 87 res = append(res, err) 88 } 89 90 if err := m.validateAssignedObjectType(formats); err != nil { 91 res = append(res, err) 92 } 93 94 if err := m.validateComments(formats); err != nil { 95 res = append(res, err) 96 } 97 98 if err := m.validateCreated(formats); err != nil { 99 res = append(res, err) 100 } 101 102 if err := m.validateKind(formats); err != nil { 103 res = append(res, err) 104 } 105 106 if err := m.validateURL(formats); err != nil { 107 res = append(res, err) 108 } 109 110 if len(res) > 0 { 111 return errors.CompositeValidationError(res...) 112 } 113 return nil 114 } 115 116 func (m *JournalEntry) validateAssignedObjectID(formats strfmt.Registry) error { 117 118 if err := validate.Required("assigned_object_id", "body", m.AssignedObjectID); err != nil { 119 return err 120 } 121 122 if err := validate.MinimumInt("assigned_object_id", "body", *m.AssignedObjectID, 0, false); err != nil { 123 return err 124 } 125 126 if err := validate.MaximumInt("assigned_object_id", "body", *m.AssignedObjectID, 2.147483647e+09, false); err != nil { 127 return err 128 } 129 130 return nil 131 } 132 133 func (m *JournalEntry) validateAssignedObjectType(formats strfmt.Registry) error { 134 135 if err := validate.Required("assigned_object_type", "body", m.AssignedObjectType); err != nil { 136 return err 137 } 138 139 return nil 140 } 141 142 func (m *JournalEntry) validateComments(formats strfmt.Registry) error { 143 144 if err := validate.Required("comments", "body", m.Comments); err != nil { 145 return err 146 } 147 148 if err := validate.MinLength("comments", "body", *m.Comments, 1); err != nil { 149 return err 150 } 151 152 return nil 153 } 154 155 func (m *JournalEntry) validateCreated(formats strfmt.Registry) error { 156 if swag.IsZero(m.Created) { // not required 157 return nil 158 } 159 160 if err := validate.FormatOf("created", "body", "date-time", m.Created.String(), formats); err != nil { 161 return err 162 } 163 164 return nil 165 } 166 167 func (m *JournalEntry) validateKind(formats strfmt.Registry) error { 168 if swag.IsZero(m.Kind) { // not required 169 return nil 170 } 171 172 if m.Kind != nil { 173 if err := m.Kind.Validate(formats); err != nil { 174 if ve, ok := err.(*errors.Validation); ok { 175 return ve.ValidateName("kind") 176 } else if ce, ok := err.(*errors.CompositeError); ok { 177 return ce.ValidateName("kind") 178 } 179 return err 180 } 181 } 182 183 return nil 184 } 185 186 func (m *JournalEntry) validateURL(formats strfmt.Registry) error { 187 if swag.IsZero(m.URL) { // not required 188 return nil 189 } 190 191 if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil { 192 return err 193 } 194 195 return nil 196 } 197 198 // ContextValidate validate this journal entry based on the context it is used 199 func (m *JournalEntry) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 200 var res []error 201 202 if err := m.contextValidateAssignedObject(ctx, formats); err != nil { 203 res = append(res, err) 204 } 205 206 if err := m.contextValidateCreated(ctx, formats); err != nil { 207 res = append(res, err) 208 } 209 210 if err := m.contextValidateDisplay(ctx, formats); err != nil { 211 res = append(res, err) 212 } 213 214 if err := m.contextValidateID(ctx, formats); err != nil { 215 res = append(res, err) 216 } 217 218 if err := m.contextValidateKind(ctx, formats); err != nil { 219 res = append(res, err) 220 } 221 222 if err := m.contextValidateURL(ctx, formats); err != nil { 223 res = append(res, err) 224 } 225 226 if len(res) > 0 { 227 return errors.CompositeValidationError(res...) 228 } 229 return nil 230 } 231 232 func (m *JournalEntry) contextValidateAssignedObject(ctx context.Context, formats strfmt.Registry) error { 233 234 return nil 235 } 236 237 func (m *JournalEntry) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error { 238 239 if err := validate.ReadOnly(ctx, "created", "body", strfmt.DateTime(m.Created)); err != nil { 240 return err 241 } 242 243 return nil 244 } 245 246 func (m *JournalEntry) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error { 247 248 if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil { 249 return err 250 } 251 252 return nil 253 } 254 255 func (m *JournalEntry) contextValidateID(ctx context.Context, formats strfmt.Registry) error { 256 257 if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil { 258 return err 259 } 260 261 return nil 262 } 263 264 func (m *JournalEntry) contextValidateKind(ctx context.Context, formats strfmt.Registry) error { 265 266 if m.Kind != nil { 267 if err := m.Kind.ContextValidate(ctx, formats); err != nil { 268 if ve, ok := err.(*errors.Validation); ok { 269 return ve.ValidateName("kind") 270 } else if ce, ok := err.(*errors.CompositeError); ok { 271 return ce.ValidateName("kind") 272 } 273 return err 274 } 275 } 276 277 return nil 278 } 279 280 func (m *JournalEntry) contextValidateURL(ctx context.Context, formats strfmt.Registry) error { 281 282 if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil { 283 return err 284 } 285 286 return nil 287 } 288 289 // MarshalBinary interface implementation 290 func (m *JournalEntry) MarshalBinary() ([]byte, error) { 291 if m == nil { 292 return nil, nil 293 } 294 return swag.WriteJSON(m) 295 } 296 297 // UnmarshalBinary interface implementation 298 func (m *JournalEntry) UnmarshalBinary(b []byte) error { 299 var res JournalEntry 300 if err := swag.ReadJSON(b, &res); err != nil { 301 return err 302 } 303 *m = res 304 return nil 305 } 306 307 // JournalEntryKind Kind 308 // 309 // swagger:model JournalEntryKind 310 type JournalEntryKind struct { 311 312 // label 313 // Required: true 314 // Enum: [Info Success Warning Danger] 315 Label *string `json:"label"` 316 317 // value 318 // Required: true 319 // Enum: [info success warning danger] 320 Value *string `json:"value"` 321 } 322 323 // Validate validates this journal entry kind 324 func (m *JournalEntryKind) Validate(formats strfmt.Registry) error { 325 var res []error 326 327 if err := m.validateLabel(formats); err != nil { 328 res = append(res, err) 329 } 330 331 if err := m.validateValue(formats); err != nil { 332 res = append(res, err) 333 } 334 335 if len(res) > 0 { 336 return errors.CompositeValidationError(res...) 337 } 338 return nil 339 } 340 341 var journalEntryKindTypeLabelPropEnum []interface{} 342 343 func init() { 344 var res []string 345 if err := json.Unmarshal([]byte(`["Info","Success","Warning","Danger"]`), &res); err != nil { 346 panic(err) 347 } 348 for _, v := range res { 349 journalEntryKindTypeLabelPropEnum = append(journalEntryKindTypeLabelPropEnum, v) 350 } 351 } 352 353 const ( 354 355 // JournalEntryKindLabelInfo captures enum value "Info" 356 JournalEntryKindLabelInfo string = "Info" 357 358 // JournalEntryKindLabelSuccess captures enum value "Success" 359 JournalEntryKindLabelSuccess string = "Success" 360 361 // JournalEntryKindLabelWarning captures enum value "Warning" 362 JournalEntryKindLabelWarning string = "Warning" 363 364 // JournalEntryKindLabelDanger captures enum value "Danger" 365 JournalEntryKindLabelDanger string = "Danger" 366 ) 367 368 // prop value enum 369 func (m *JournalEntryKind) validateLabelEnum(path, location string, value string) error { 370 if err := validate.EnumCase(path, location, value, journalEntryKindTypeLabelPropEnum, true); err != nil { 371 return err 372 } 373 return nil 374 } 375 376 func (m *JournalEntryKind) validateLabel(formats strfmt.Registry) error { 377 378 if err := validate.Required("kind"+"."+"label", "body", m.Label); err != nil { 379 return err 380 } 381 382 // value enum 383 if err := m.validateLabelEnum("kind"+"."+"label", "body", *m.Label); err != nil { 384 return err 385 } 386 387 return nil 388 } 389 390 var journalEntryKindTypeValuePropEnum []interface{} 391 392 func init() { 393 var res []string 394 if err := json.Unmarshal([]byte(`["info","success","warning","danger"]`), &res); err != nil { 395 panic(err) 396 } 397 for _, v := range res { 398 journalEntryKindTypeValuePropEnum = append(journalEntryKindTypeValuePropEnum, v) 399 } 400 } 401 402 const ( 403 404 // JournalEntryKindValueInfo captures enum value "info" 405 JournalEntryKindValueInfo string = "info" 406 407 // JournalEntryKindValueSuccess captures enum value "success" 408 JournalEntryKindValueSuccess string = "success" 409 410 // JournalEntryKindValueWarning captures enum value "warning" 411 JournalEntryKindValueWarning string = "warning" 412 413 // JournalEntryKindValueDanger captures enum value "danger" 414 JournalEntryKindValueDanger string = "danger" 415 ) 416 417 // prop value enum 418 func (m *JournalEntryKind) validateValueEnum(path, location string, value string) error { 419 if err := validate.EnumCase(path, location, value, journalEntryKindTypeValuePropEnum, true); err != nil { 420 return err 421 } 422 return nil 423 } 424 425 func (m *JournalEntryKind) validateValue(formats strfmt.Registry) error { 426 427 if err := validate.Required("kind"+"."+"value", "body", m.Value); err != nil { 428 return err 429 } 430 431 // value enum 432 if err := m.validateValueEnum("kind"+"."+"value", "body", *m.Value); err != nil { 433 return err 434 } 435 436 return nil 437 } 438 439 // ContextValidate validates this journal entry kind based on context it is used 440 func (m *JournalEntryKind) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 441 return nil 442 } 443 444 // MarshalBinary interface implementation 445 func (m *JournalEntryKind) MarshalBinary() ([]byte, error) { 446 if m == nil { 447 return nil, nil 448 } 449 return swag.WriteJSON(m) 450 } 451 452 // UnmarshalBinary interface implementation 453 func (m *JournalEntryKind) UnmarshalBinary(b []byte) error { 454 var res JournalEntryKind 455 if err := swag.ReadJSON(b, &res); err != nil { 456 return err 457 } 458 *m = res 459 return nil 460 }