github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/models/security_summary.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 ) 16 17 // SecuritySummary the security summary 18 // 19 // swagger:model SecuritySummary 20 type SecuritySummary struct { 21 22 // the count of critical vulnerabilities 23 CriticalCnt int64 `json:"critical_cnt"` 24 25 // the list of dangerous artifacts 26 DangerousArtifacts []*DangerousArtifact `json:"dangerous_artifacts,omitempty"` 27 28 // the list of dangerous CVEs 29 DangerousCves []*DangerousCVE `json:"dangerous_cves,omitempty"` 30 31 // the count of fixable vulnerabilities 32 FixableCnt int64 `json:"fixable_cnt"` 33 34 // the count of high vulnerabilities 35 HighCnt int64 `json:"high_cnt,omitempty"` 36 37 // the count of low vulnerabilities 38 LowCnt int64 `json:"low_cnt"` 39 40 // the count of medium vulnerabilities 41 MediumCnt int64 `json:"medium_cnt"` 42 43 // the count of none vulnerabilities 44 NoneCnt int64 `json:"none_cnt,omitempty"` 45 46 // the count of scanned artifacts 47 ScannedCnt int64 `json:"scanned_cnt"` 48 49 // the total count of artifacts 50 TotalArtifact int64 `json:"total_artifact"` 51 52 // the count of total vulnerabilities 53 TotalVuls int64 `json:"total_vuls"` 54 55 // the count of unknown vulnerabilities 56 UnknownCnt int64 `json:"unknown_cnt,omitempty"` 57 } 58 59 // Validate validates this security summary 60 func (m *SecuritySummary) Validate(formats strfmt.Registry) error { 61 var res []error 62 63 if err := m.validateDangerousArtifacts(formats); err != nil { 64 res = append(res, err) 65 } 66 67 if err := m.validateDangerousCves(formats); err != nil { 68 res = append(res, err) 69 } 70 71 if len(res) > 0 { 72 return errors.CompositeValidationError(res...) 73 } 74 return nil 75 } 76 77 func (m *SecuritySummary) validateDangerousArtifacts(formats strfmt.Registry) error { 78 if swag.IsZero(m.DangerousArtifacts) { // not required 79 return nil 80 } 81 82 for i := 0; i < len(m.DangerousArtifacts); i++ { 83 if swag.IsZero(m.DangerousArtifacts[i]) { // not required 84 continue 85 } 86 87 if m.DangerousArtifacts[i] != nil { 88 if err := m.DangerousArtifacts[i].Validate(formats); err != nil { 89 if ve, ok := err.(*errors.Validation); ok { 90 return ve.ValidateName("dangerous_artifacts" + "." + strconv.Itoa(i)) 91 } else if ce, ok := err.(*errors.CompositeError); ok { 92 return ce.ValidateName("dangerous_artifacts" + "." + strconv.Itoa(i)) 93 } 94 return err 95 } 96 } 97 98 } 99 100 return nil 101 } 102 103 func (m *SecuritySummary) validateDangerousCves(formats strfmt.Registry) error { 104 if swag.IsZero(m.DangerousCves) { // not required 105 return nil 106 } 107 108 for i := 0; i < len(m.DangerousCves); i++ { 109 if swag.IsZero(m.DangerousCves[i]) { // not required 110 continue 111 } 112 113 if m.DangerousCves[i] != nil { 114 if err := m.DangerousCves[i].Validate(formats); err != nil { 115 if ve, ok := err.(*errors.Validation); ok { 116 return ve.ValidateName("dangerous_cves" + "." + strconv.Itoa(i)) 117 } else if ce, ok := err.(*errors.CompositeError); ok { 118 return ce.ValidateName("dangerous_cves" + "." + strconv.Itoa(i)) 119 } 120 return err 121 } 122 } 123 124 } 125 126 return nil 127 } 128 129 // ContextValidate validate this security summary based on the context it is used 130 func (m *SecuritySummary) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 131 var res []error 132 133 if err := m.contextValidateDangerousArtifacts(ctx, formats); err != nil { 134 res = append(res, err) 135 } 136 137 if err := m.contextValidateDangerousCves(ctx, formats); err != nil { 138 res = append(res, err) 139 } 140 141 if len(res) > 0 { 142 return errors.CompositeValidationError(res...) 143 } 144 return nil 145 } 146 147 func (m *SecuritySummary) contextValidateDangerousArtifacts(ctx context.Context, formats strfmt.Registry) error { 148 149 for i := 0; i < len(m.DangerousArtifacts); i++ { 150 151 if m.DangerousArtifacts[i] != nil { 152 if err := m.DangerousArtifacts[i].ContextValidate(ctx, formats); err != nil { 153 if ve, ok := err.(*errors.Validation); ok { 154 return ve.ValidateName("dangerous_artifacts" + "." + strconv.Itoa(i)) 155 } else if ce, ok := err.(*errors.CompositeError); ok { 156 return ce.ValidateName("dangerous_artifacts" + "." + strconv.Itoa(i)) 157 } 158 return err 159 } 160 } 161 162 } 163 164 return nil 165 } 166 167 func (m *SecuritySummary) contextValidateDangerousCves(ctx context.Context, formats strfmt.Registry) error { 168 169 for i := 0; i < len(m.DangerousCves); i++ { 170 171 if m.DangerousCves[i] != nil { 172 if err := m.DangerousCves[i].ContextValidate(ctx, formats); err != nil { 173 if ve, ok := err.(*errors.Validation); ok { 174 return ve.ValidateName("dangerous_cves" + "." + strconv.Itoa(i)) 175 } else if ce, ok := err.(*errors.CompositeError); ok { 176 return ce.ValidateName("dangerous_cves" + "." + strconv.Itoa(i)) 177 } 178 return err 179 } 180 } 181 182 } 183 184 return nil 185 } 186 187 // MarshalBinary interface implementation 188 func (m *SecuritySummary) MarshalBinary() ([]byte, error) { 189 if m == nil { 190 return nil, nil 191 } 192 return swag.WriteJSON(m) 193 } 194 195 // UnmarshalBinary interface implementation 196 func (m *SecuritySummary) UnmarshalBinary(b []byte) error { 197 var res SecuritySummary 198 if err := swag.ReadJSON(b, &res); err != nil { 199 return err 200 } 201 *m = res 202 return nil 203 }