github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/models/reference.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 11 "github.com/go-openapi/errors" 12 "github.com/go-openapi/strfmt" 13 "github.com/go-openapi/swag" 14 ) 15 16 // Reference reference 17 // 18 // swagger:model Reference 19 type Reference struct { 20 21 // annotations 22 Annotations Annotations `json:"annotations,omitempty"` 23 24 // The digest of the child artifact 25 ChildDigest string `json:"child_digest,omitempty"` 26 27 // The child ID of the reference 28 ChildID int64 `json:"child_id,omitempty"` 29 30 // The parent ID of the reference 31 ParentID int64 `json:"parent_id,omitempty"` 32 33 // platform 34 Platform *Platform `json:"platform,omitempty"` 35 36 // The download URLs 37 Urls []string `json:"urls"` 38 } 39 40 // Validate validates this reference 41 func (m *Reference) Validate(formats strfmt.Registry) error { 42 var res []error 43 44 if err := m.validateAnnotations(formats); err != nil { 45 res = append(res, err) 46 } 47 48 if err := m.validatePlatform(formats); err != nil { 49 res = append(res, err) 50 } 51 52 if len(res) > 0 { 53 return errors.CompositeValidationError(res...) 54 } 55 return nil 56 } 57 58 func (m *Reference) validateAnnotations(formats strfmt.Registry) error { 59 if swag.IsZero(m.Annotations) { // not required 60 return nil 61 } 62 63 if m.Annotations != nil { 64 if err := m.Annotations.Validate(formats); err != nil { 65 if ve, ok := err.(*errors.Validation); ok { 66 return ve.ValidateName("annotations") 67 } else if ce, ok := err.(*errors.CompositeError); ok { 68 return ce.ValidateName("annotations") 69 } 70 return err 71 } 72 } 73 74 return nil 75 } 76 77 func (m *Reference) validatePlatform(formats strfmt.Registry) error { 78 if swag.IsZero(m.Platform) { // not required 79 return nil 80 } 81 82 if m.Platform != nil { 83 if err := m.Platform.Validate(formats); err != nil { 84 if ve, ok := err.(*errors.Validation); ok { 85 return ve.ValidateName("platform") 86 } else if ce, ok := err.(*errors.CompositeError); ok { 87 return ce.ValidateName("platform") 88 } 89 return err 90 } 91 } 92 93 return nil 94 } 95 96 // ContextValidate validate this reference based on the context it is used 97 func (m *Reference) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 98 var res []error 99 100 if err := m.contextValidateAnnotations(ctx, formats); err != nil { 101 res = append(res, err) 102 } 103 104 if err := m.contextValidatePlatform(ctx, formats); err != nil { 105 res = append(res, err) 106 } 107 108 if len(res) > 0 { 109 return errors.CompositeValidationError(res...) 110 } 111 return nil 112 } 113 114 func (m *Reference) contextValidateAnnotations(ctx context.Context, formats strfmt.Registry) error { 115 116 if err := m.Annotations.ContextValidate(ctx, formats); err != nil { 117 if ve, ok := err.(*errors.Validation); ok { 118 return ve.ValidateName("annotations") 119 } else if ce, ok := err.(*errors.CompositeError); ok { 120 return ce.ValidateName("annotations") 121 } 122 return err 123 } 124 125 return nil 126 } 127 128 func (m *Reference) contextValidatePlatform(ctx context.Context, formats strfmt.Registry) error { 129 130 if m.Platform != nil { 131 if err := m.Platform.ContextValidate(ctx, formats); err != nil { 132 if ve, ok := err.(*errors.Validation); ok { 133 return ve.ValidateName("platform") 134 } else if ce, ok := err.(*errors.CompositeError); ok { 135 return ce.ValidateName("platform") 136 } 137 return err 138 } 139 } 140 141 return nil 142 } 143 144 // MarshalBinary interface implementation 145 func (m *Reference) MarshalBinary() ([]byte, error) { 146 if m == nil { 147 return nil, nil 148 } 149 return swag.WriteJSON(m) 150 } 151 152 // UnmarshalBinary interface implementation 153 func (m *Reference) UnmarshalBinary(b []byte) error { 154 var res Reference 155 if err := swag.ReadJSON(b, &res); err != nil { 156 return err 157 } 158 *m = res 159 return nil 160 }