github.com/crowdsecurity/crowdsec@v1.6.1/pkg/modelscapi/add_signals_request_item.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package modelscapi 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 // AddSignalsRequestItem Signal 19 // 20 // swagger:model AddSignalsRequestItem 21 type AddSignalsRequestItem struct { 22 23 // alert id 24 AlertID int64 `json:"alert_id,omitempty"` 25 26 // context 27 Context []*AddSignalsRequestItemContextItems0 `json:"context"` 28 29 // created at 30 CreatedAt string `json:"created_at,omitempty"` 31 32 // decisions 33 Decisions AddSignalsRequestItemDecisions `json:"decisions,omitempty"` 34 35 // machine id 36 MachineID string `json:"machine_id,omitempty"` 37 38 // a human readable message 39 // Required: true 40 Message *string `json:"message"` 41 42 // scenario 43 // Required: true 44 Scenario *string `json:"scenario"` 45 46 // scenario hash 47 // Required: true 48 ScenarioHash *string `json:"scenario_hash"` 49 50 // scenario trust 51 ScenarioTrust string `json:"scenario_trust,omitempty"` 52 53 // scenario version 54 // Required: true 55 ScenarioVersion *string `json:"scenario_version"` 56 57 // source 58 // Required: true 59 Source *AddSignalsRequestItemSource `json:"source"` 60 61 // start at 62 // Required: true 63 StartAt *string `json:"start_at"` 64 65 // stop at 66 // Required: true 67 StopAt *string `json:"stop_at"` 68 } 69 70 // Validate validates this add signals request item 71 func (m *AddSignalsRequestItem) Validate(formats strfmt.Registry) error { 72 var res []error 73 74 if err := m.validateContext(formats); err != nil { 75 res = append(res, err) 76 } 77 78 if err := m.validateDecisions(formats); err != nil { 79 res = append(res, err) 80 } 81 82 if err := m.validateMessage(formats); err != nil { 83 res = append(res, err) 84 } 85 86 if err := m.validateScenario(formats); err != nil { 87 res = append(res, err) 88 } 89 90 if err := m.validateScenarioHash(formats); err != nil { 91 res = append(res, err) 92 } 93 94 if err := m.validateScenarioVersion(formats); err != nil { 95 res = append(res, err) 96 } 97 98 if err := m.validateSource(formats); err != nil { 99 res = append(res, err) 100 } 101 102 if err := m.validateStartAt(formats); err != nil { 103 res = append(res, err) 104 } 105 106 if err := m.validateStopAt(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 *AddSignalsRequestItem) validateContext(formats strfmt.Registry) error { 117 if swag.IsZero(m.Context) { // not required 118 return nil 119 } 120 121 for i := 0; i < len(m.Context); i++ { 122 if swag.IsZero(m.Context[i]) { // not required 123 continue 124 } 125 126 if m.Context[i] != nil { 127 if err := m.Context[i].Validate(formats); err != nil { 128 if ve, ok := err.(*errors.Validation); ok { 129 return ve.ValidateName("context" + "." + strconv.Itoa(i)) 130 } else if ce, ok := err.(*errors.CompositeError); ok { 131 return ce.ValidateName("context" + "." + strconv.Itoa(i)) 132 } 133 return err 134 } 135 } 136 137 } 138 139 return nil 140 } 141 142 func (m *AddSignalsRequestItem) validateDecisions(formats strfmt.Registry) error { 143 if swag.IsZero(m.Decisions) { // not required 144 return nil 145 } 146 147 if err := m.Decisions.Validate(formats); err != nil { 148 if ve, ok := err.(*errors.Validation); ok { 149 return ve.ValidateName("decisions") 150 } else if ce, ok := err.(*errors.CompositeError); ok { 151 return ce.ValidateName("decisions") 152 } 153 return err 154 } 155 156 return nil 157 } 158 159 func (m *AddSignalsRequestItem) validateMessage(formats strfmt.Registry) error { 160 161 if err := validate.Required("message", "body", m.Message); err != nil { 162 return err 163 } 164 165 return nil 166 } 167 168 func (m *AddSignalsRequestItem) validateScenario(formats strfmt.Registry) error { 169 170 if err := validate.Required("scenario", "body", m.Scenario); err != nil { 171 return err 172 } 173 174 return nil 175 } 176 177 func (m *AddSignalsRequestItem) validateScenarioHash(formats strfmt.Registry) error { 178 179 if err := validate.Required("scenario_hash", "body", m.ScenarioHash); err != nil { 180 return err 181 } 182 183 return nil 184 } 185 186 func (m *AddSignalsRequestItem) validateScenarioVersion(formats strfmt.Registry) error { 187 188 if err := validate.Required("scenario_version", "body", m.ScenarioVersion); err != nil { 189 return err 190 } 191 192 return nil 193 } 194 195 func (m *AddSignalsRequestItem) validateSource(formats strfmt.Registry) error { 196 197 if err := validate.Required("source", "body", m.Source); err != nil { 198 return err 199 } 200 201 if m.Source != nil { 202 if err := m.Source.Validate(formats); err != nil { 203 if ve, ok := err.(*errors.Validation); ok { 204 return ve.ValidateName("source") 205 } else if ce, ok := err.(*errors.CompositeError); ok { 206 return ce.ValidateName("source") 207 } 208 return err 209 } 210 } 211 212 return nil 213 } 214 215 func (m *AddSignalsRequestItem) validateStartAt(formats strfmt.Registry) error { 216 217 if err := validate.Required("start_at", "body", m.StartAt); err != nil { 218 return err 219 } 220 221 return nil 222 } 223 224 func (m *AddSignalsRequestItem) validateStopAt(formats strfmt.Registry) error { 225 226 if err := validate.Required("stop_at", "body", m.StopAt); err != nil { 227 return err 228 } 229 230 return nil 231 } 232 233 // ContextValidate validate this add signals request item based on the context it is used 234 func (m *AddSignalsRequestItem) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 235 var res []error 236 237 if err := m.contextValidateContext(ctx, formats); err != nil { 238 res = append(res, err) 239 } 240 241 if err := m.contextValidateDecisions(ctx, formats); err != nil { 242 res = append(res, err) 243 } 244 245 if err := m.contextValidateSource(ctx, formats); err != nil { 246 res = append(res, err) 247 } 248 249 if len(res) > 0 { 250 return errors.CompositeValidationError(res...) 251 } 252 return nil 253 } 254 255 func (m *AddSignalsRequestItem) contextValidateContext(ctx context.Context, formats strfmt.Registry) error { 256 257 for i := 0; i < len(m.Context); i++ { 258 259 if m.Context[i] != nil { 260 if err := m.Context[i].ContextValidate(ctx, formats); err != nil { 261 if ve, ok := err.(*errors.Validation); ok { 262 return ve.ValidateName("context" + "." + strconv.Itoa(i)) 263 } else if ce, ok := err.(*errors.CompositeError); ok { 264 return ce.ValidateName("context" + "." + strconv.Itoa(i)) 265 } 266 return err 267 } 268 } 269 270 } 271 272 return nil 273 } 274 275 func (m *AddSignalsRequestItem) contextValidateDecisions(ctx context.Context, formats strfmt.Registry) error { 276 277 if err := m.Decisions.ContextValidate(ctx, formats); err != nil { 278 if ve, ok := err.(*errors.Validation); ok { 279 return ve.ValidateName("decisions") 280 } else if ce, ok := err.(*errors.CompositeError); ok { 281 return ce.ValidateName("decisions") 282 } 283 return err 284 } 285 286 return nil 287 } 288 289 func (m *AddSignalsRequestItem) contextValidateSource(ctx context.Context, formats strfmt.Registry) error { 290 291 if m.Source != nil { 292 if err := m.Source.ContextValidate(ctx, formats); err != nil { 293 if ve, ok := err.(*errors.Validation); ok { 294 return ve.ValidateName("source") 295 } else if ce, ok := err.(*errors.CompositeError); ok { 296 return ce.ValidateName("source") 297 } 298 return err 299 } 300 } 301 302 return nil 303 } 304 305 // MarshalBinary interface implementation 306 func (m *AddSignalsRequestItem) MarshalBinary() ([]byte, error) { 307 if m == nil { 308 return nil, nil 309 } 310 return swag.WriteJSON(m) 311 } 312 313 // UnmarshalBinary interface implementation 314 func (m *AddSignalsRequestItem) UnmarshalBinary(b []byte) error { 315 var res AddSignalsRequestItem 316 if err := swag.ReadJSON(b, &res); err != nil { 317 return err 318 } 319 *m = res 320 return nil 321 } 322 323 // AddSignalsRequestItemContextItems0 add signals request item context items0 324 // 325 // swagger:model AddSignalsRequestItemContextItems0 326 type AddSignalsRequestItemContextItems0 struct { 327 328 // key 329 Key string `json:"key,omitempty"` 330 331 // value 332 Value string `json:"value,omitempty"` 333 } 334 335 // Validate validates this add signals request item context items0 336 func (m *AddSignalsRequestItemContextItems0) Validate(formats strfmt.Registry) error { 337 return nil 338 } 339 340 // ContextValidate validates this add signals request item context items0 based on context it is used 341 func (m *AddSignalsRequestItemContextItems0) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 342 return nil 343 } 344 345 // MarshalBinary interface implementation 346 func (m *AddSignalsRequestItemContextItems0) MarshalBinary() ([]byte, error) { 347 if m == nil { 348 return nil, nil 349 } 350 return swag.WriteJSON(m) 351 } 352 353 // UnmarshalBinary interface implementation 354 func (m *AddSignalsRequestItemContextItems0) UnmarshalBinary(b []byte) error { 355 var res AddSignalsRequestItemContextItems0 356 if err := swag.ReadJSON(b, &res); err != nil { 357 return err 358 } 359 *m = res 360 return nil 361 }