github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/models/artifact.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package models 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the swagger generate command 7 8 import ( 9 "context" 10 "strconv" 11 12 "github.com/go-openapi/errors" 13 "github.com/go-openapi/strfmt" 14 "github.com/go-openapi/swag" 15 "github.com/go-openapi/validate" 16 ) 17 18 // Artifact artifact 19 // 20 // swagger:model Artifact 21 type Artifact struct { 22 23 // accessories 24 Accessories []*Accessory `json:"accessories"` 25 26 // addition links 27 AdditionLinks AdditionLinks `json:"addition_links,omitempty"` 28 29 // annotations 30 Annotations Annotations `json:"annotations,omitempty"` 31 32 // The digest of the artifact 33 Digest string `json:"digest,omitempty"` 34 35 // extra attrs 36 ExtraAttrs ExtraAttrs `json:"extra_attrs,omitempty"` 37 38 // The digest of the icon 39 Icon string `json:"icon,omitempty"` 40 41 // The ID of the artifact 42 ID int64 `json:"id,omitempty"` 43 44 // labels 45 Labels []*Label `json:"labels"` 46 47 // The manifest media type of the artifact 48 ManifestMediaType string `json:"manifest_media_type,omitempty"` 49 50 // The media type of the artifact 51 MediaType string `json:"media_type,omitempty"` 52 53 // The ID of the project that the artifact belongs to 54 ProjectID int64 `json:"project_id,omitempty"` 55 56 // The latest pull time of the artifact 57 // Format: date-time 58 PullTime strfmt.DateTime `json:"pull_time,omitempty"` 59 60 // The push time of the artifact 61 // Format: date-time 62 PushTime strfmt.DateTime `json:"push_time,omitempty"` 63 64 // references 65 References []*Reference `json:"references"` 66 67 // The ID of the repository that the artifact belongs to 68 RepositoryID int64 `json:"repository_id,omitempty"` 69 70 // The overview of the scan result. 71 ScanOverview ScanOverview `json:"scan_overview,omitempty"` 72 73 // The size of the artifact 74 Size int64 `json:"size,omitempty"` 75 76 // tags 77 Tags []*Tag `json:"tags"` 78 79 // The type of the artifact, e.g. image, chart, etc 80 Type string `json:"type,omitempty"` 81 } 82 83 // Validate validates this artifact 84 func (m *Artifact) Validate(formats strfmt.Registry) error { 85 var res []error 86 87 if err := m.validateAccessories(formats); err != nil { 88 res = append(res, err) 89 } 90 91 if err := m.validateAdditionLinks(formats); err != nil { 92 res = append(res, err) 93 } 94 95 if err := m.validateAnnotations(formats); err != nil { 96 res = append(res, err) 97 } 98 99 if err := m.validateExtraAttrs(formats); err != nil { 100 res = append(res, err) 101 } 102 103 if err := m.validateLabels(formats); err != nil { 104 res = append(res, err) 105 } 106 107 if err := m.validatePullTime(formats); err != nil { 108 res = append(res, err) 109 } 110 111 if err := m.validatePushTime(formats); err != nil { 112 res = append(res, err) 113 } 114 115 if err := m.validateReferences(formats); err != nil { 116 res = append(res, err) 117 } 118 119 if err := m.validateScanOverview(formats); err != nil { 120 res = append(res, err) 121 } 122 123 if err := m.validateTags(formats); err != nil { 124 res = append(res, err) 125 } 126 127 if len(res) > 0 { 128 return errors.CompositeValidationError(res...) 129 } 130 return nil 131 } 132 133 func (m *Artifact) validateAccessories(formats strfmt.Registry) error { 134 if swag.IsZero(m.Accessories) { // not required 135 return nil 136 } 137 138 for i := 0; i < len(m.Accessories); i++ { 139 if swag.IsZero(m.Accessories[i]) { // not required 140 continue 141 } 142 143 if m.Accessories[i] != nil { 144 if err := m.Accessories[i].Validate(formats); err != nil { 145 if ve, ok := err.(*errors.Validation); ok { 146 return ve.ValidateName("accessories" + "." + strconv.Itoa(i)) 147 } else if ce, ok := err.(*errors.CompositeError); ok { 148 return ce.ValidateName("accessories" + "." + strconv.Itoa(i)) 149 } 150 return err 151 } 152 } 153 154 } 155 156 return nil 157 } 158 159 func (m *Artifact) validateAdditionLinks(formats strfmt.Registry) error { 160 if swag.IsZero(m.AdditionLinks) { // not required 161 return nil 162 } 163 164 if m.AdditionLinks != nil { 165 if err := m.AdditionLinks.Validate(formats); err != nil { 166 if ve, ok := err.(*errors.Validation); ok { 167 return ve.ValidateName("addition_links") 168 } else if ce, ok := err.(*errors.CompositeError); ok { 169 return ce.ValidateName("addition_links") 170 } 171 return err 172 } 173 } 174 175 return nil 176 } 177 178 func (m *Artifact) validateAnnotations(formats strfmt.Registry) error { 179 if swag.IsZero(m.Annotations) { // not required 180 return nil 181 } 182 183 if m.Annotations != nil { 184 if err := m.Annotations.Validate(formats); err != nil { 185 if ve, ok := err.(*errors.Validation); ok { 186 return ve.ValidateName("annotations") 187 } else if ce, ok := err.(*errors.CompositeError); ok { 188 return ce.ValidateName("annotations") 189 } 190 return err 191 } 192 } 193 194 return nil 195 } 196 197 func (m *Artifact) validateExtraAttrs(formats strfmt.Registry) error { 198 if swag.IsZero(m.ExtraAttrs) { // not required 199 return nil 200 } 201 202 if m.ExtraAttrs != nil { 203 if err := m.ExtraAttrs.Validate(formats); err != nil { 204 if ve, ok := err.(*errors.Validation); ok { 205 return ve.ValidateName("extra_attrs") 206 } else if ce, ok := err.(*errors.CompositeError); ok { 207 return ce.ValidateName("extra_attrs") 208 } 209 return err 210 } 211 } 212 213 return nil 214 } 215 216 func (m *Artifact) validateLabels(formats strfmt.Registry) error { 217 if swag.IsZero(m.Labels) { // not required 218 return nil 219 } 220 221 for i := 0; i < len(m.Labels); i++ { 222 if swag.IsZero(m.Labels[i]) { // not required 223 continue 224 } 225 226 if m.Labels[i] != nil { 227 if err := m.Labels[i].Validate(formats); err != nil { 228 if ve, ok := err.(*errors.Validation); ok { 229 return ve.ValidateName("labels" + "." + strconv.Itoa(i)) 230 } else if ce, ok := err.(*errors.CompositeError); ok { 231 return ce.ValidateName("labels" + "." + strconv.Itoa(i)) 232 } 233 return err 234 } 235 } 236 237 } 238 239 return nil 240 } 241 242 func (m *Artifact) validatePullTime(formats strfmt.Registry) error { 243 if swag.IsZero(m.PullTime) { // not required 244 return nil 245 } 246 247 if err := validate.FormatOf("pull_time", "body", "date-time", m.PullTime.String(), formats); err != nil { 248 return err 249 } 250 251 return nil 252 } 253 254 func (m *Artifact) validatePushTime(formats strfmt.Registry) error { 255 if swag.IsZero(m.PushTime) { // not required 256 return nil 257 } 258 259 if err := validate.FormatOf("push_time", "body", "date-time", m.PushTime.String(), formats); err != nil { 260 return err 261 } 262 263 return nil 264 } 265 266 func (m *Artifact) validateReferences(formats strfmt.Registry) error { 267 if swag.IsZero(m.References) { // not required 268 return nil 269 } 270 271 for i := 0; i < len(m.References); i++ { 272 if swag.IsZero(m.References[i]) { // not required 273 continue 274 } 275 276 if m.References[i] != nil { 277 if err := m.References[i].Validate(formats); err != nil { 278 if ve, ok := err.(*errors.Validation); ok { 279 return ve.ValidateName("references" + "." + strconv.Itoa(i)) 280 } else if ce, ok := err.(*errors.CompositeError); ok { 281 return ce.ValidateName("references" + "." + strconv.Itoa(i)) 282 } 283 return err 284 } 285 } 286 287 } 288 289 return nil 290 } 291 292 func (m *Artifact) validateScanOverview(formats strfmt.Registry) error { 293 if swag.IsZero(m.ScanOverview) { // not required 294 return nil 295 } 296 297 if m.ScanOverview != nil { 298 if err := m.ScanOverview.Validate(formats); err != nil { 299 if ve, ok := err.(*errors.Validation); ok { 300 return ve.ValidateName("scan_overview") 301 } else if ce, ok := err.(*errors.CompositeError); ok { 302 return ce.ValidateName("scan_overview") 303 } 304 return err 305 } 306 } 307 308 return nil 309 } 310 311 func (m *Artifact) 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 // ContextValidate validate this artifact based on the context it is used 338 func (m *Artifact) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 339 var res []error 340 341 if err := m.contextValidateAccessories(ctx, formats); err != nil { 342 res = append(res, err) 343 } 344 345 if err := m.contextValidateAdditionLinks(ctx, formats); err != nil { 346 res = append(res, err) 347 } 348 349 if err := m.contextValidateAnnotations(ctx, formats); err != nil { 350 res = append(res, err) 351 } 352 353 if err := m.contextValidateExtraAttrs(ctx, formats); err != nil { 354 res = append(res, err) 355 } 356 357 if err := m.contextValidateLabels(ctx, formats); err != nil { 358 res = append(res, err) 359 } 360 361 if err := m.contextValidateReferences(ctx, formats); err != nil { 362 res = append(res, err) 363 } 364 365 if err := m.contextValidateScanOverview(ctx, formats); err != nil { 366 res = append(res, err) 367 } 368 369 if err := m.contextValidateTags(ctx, formats); err != nil { 370 res = append(res, err) 371 } 372 373 if len(res) > 0 { 374 return errors.CompositeValidationError(res...) 375 } 376 return nil 377 } 378 379 func (m *Artifact) contextValidateAccessories(ctx context.Context, formats strfmt.Registry) error { 380 381 for i := 0; i < len(m.Accessories); i++ { 382 383 if m.Accessories[i] != nil { 384 if err := m.Accessories[i].ContextValidate(ctx, formats); err != nil { 385 if ve, ok := err.(*errors.Validation); ok { 386 return ve.ValidateName("accessories" + "." + strconv.Itoa(i)) 387 } else if ce, ok := err.(*errors.CompositeError); ok { 388 return ce.ValidateName("accessories" + "." + strconv.Itoa(i)) 389 } 390 return err 391 } 392 } 393 394 } 395 396 return nil 397 } 398 399 func (m *Artifact) contextValidateAdditionLinks(ctx context.Context, formats strfmt.Registry) error { 400 401 if err := m.AdditionLinks.ContextValidate(ctx, formats); err != nil { 402 if ve, ok := err.(*errors.Validation); ok { 403 return ve.ValidateName("addition_links") 404 } else if ce, ok := err.(*errors.CompositeError); ok { 405 return ce.ValidateName("addition_links") 406 } 407 return err 408 } 409 410 return nil 411 } 412 413 func (m *Artifact) contextValidateAnnotations(ctx context.Context, formats strfmt.Registry) error { 414 415 if err := m.Annotations.ContextValidate(ctx, formats); err != nil { 416 if ve, ok := err.(*errors.Validation); ok { 417 return ve.ValidateName("annotations") 418 } else if ce, ok := err.(*errors.CompositeError); ok { 419 return ce.ValidateName("annotations") 420 } 421 return err 422 } 423 424 return nil 425 } 426 427 func (m *Artifact) contextValidateExtraAttrs(ctx context.Context, formats strfmt.Registry) error { 428 429 if err := m.ExtraAttrs.ContextValidate(ctx, formats); err != nil { 430 if ve, ok := err.(*errors.Validation); ok { 431 return ve.ValidateName("extra_attrs") 432 } else if ce, ok := err.(*errors.CompositeError); ok { 433 return ce.ValidateName("extra_attrs") 434 } 435 return err 436 } 437 438 return nil 439 } 440 441 func (m *Artifact) contextValidateLabels(ctx context.Context, formats strfmt.Registry) error { 442 443 for i := 0; i < len(m.Labels); i++ { 444 445 if m.Labels[i] != nil { 446 if err := m.Labels[i].ContextValidate(ctx, formats); err != nil { 447 if ve, ok := err.(*errors.Validation); ok { 448 return ve.ValidateName("labels" + "." + strconv.Itoa(i)) 449 } else if ce, ok := err.(*errors.CompositeError); ok { 450 return ce.ValidateName("labels" + "." + strconv.Itoa(i)) 451 } 452 return err 453 } 454 } 455 456 } 457 458 return nil 459 } 460 461 func (m *Artifact) contextValidateReferences(ctx context.Context, formats strfmt.Registry) error { 462 463 for i := 0; i < len(m.References); i++ { 464 465 if m.References[i] != nil { 466 if err := m.References[i].ContextValidate(ctx, formats); err != nil { 467 if ve, ok := err.(*errors.Validation); ok { 468 return ve.ValidateName("references" + "." + strconv.Itoa(i)) 469 } else if ce, ok := err.(*errors.CompositeError); ok { 470 return ce.ValidateName("references" + "." + strconv.Itoa(i)) 471 } 472 return err 473 } 474 } 475 476 } 477 478 return nil 479 } 480 481 func (m *Artifact) contextValidateScanOverview(ctx context.Context, formats strfmt.Registry) error { 482 483 if err := m.ScanOverview.ContextValidate(ctx, formats); err != nil { 484 if ve, ok := err.(*errors.Validation); ok { 485 return ve.ValidateName("scan_overview") 486 } else if ce, ok := err.(*errors.CompositeError); ok { 487 return ce.ValidateName("scan_overview") 488 } 489 return err 490 } 491 492 return nil 493 } 494 495 func (m *Artifact) contextValidateTags(ctx context.Context, formats strfmt.Registry) error { 496 497 for i := 0; i < len(m.Tags); i++ { 498 499 if m.Tags[i] != nil { 500 if err := m.Tags[i].ContextValidate(ctx, formats); err != nil { 501 if ve, ok := err.(*errors.Validation); ok { 502 return ve.ValidateName("tags" + "." + strconv.Itoa(i)) 503 } else if ce, ok := err.(*errors.CompositeError); ok { 504 return ce.ValidateName("tags" + "." + strconv.Itoa(i)) 505 } 506 return err 507 } 508 } 509 510 } 511 512 return nil 513 } 514 515 // MarshalBinary interface implementation 516 func (m *Artifact) 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 *Artifact) UnmarshalBinary(b []byte) error { 525 var res Artifact 526 if err := swag.ReadJSON(b, &res); err != nil { 527 return err 528 } 529 *m = res 530 return nil 531 }