update
This commit is contained in:
parent
3e8ce3ce19
commit
03a058dff6
4 changed files with 29 additions and 0 deletions
|
@ -90,6 +90,7 @@ func AlertToSignal(alert *models.Alert, scenarioTrust string, keepDecisions bool
|
|||
CreatedAt: alert.CreatedAt,
|
||||
MachineID: alert.MachineID,
|
||||
ScenarioTrust: &scenarioTrust,
|
||||
AlertID: &alert.ID,
|
||||
}
|
||||
if keepDecisions {
|
||||
log.Debugf("Keeping decisions to send to CAPI")
|
||||
|
|
|
@ -496,6 +496,14 @@ func (c *Client) CreateAlertBulk(machineId string, alertList []*models.Alert) ([
|
|||
ret = append(ret, strconv.Itoa(alert.ID))
|
||||
}
|
||||
|
||||
for i, alertID := range ret {
|
||||
alertIDInt, err := strconv.Atoi(alertID)
|
||||
if err != nil {
|
||||
log.Errorf("unable to convert alert ID '%s' to int: %s", alertID, err)
|
||||
}
|
||||
alertList[i].ID = int64(alertIDInt)
|
||||
}
|
||||
|
||||
return ret, alertList, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,10 @@ import (
|
|||
// swagger:model AddSignalsRequestItem
|
||||
type AddSignalsRequestItem struct {
|
||||
|
||||
// alert id
|
||||
// Required: true
|
||||
AlertID *int64 `json:"alert_id"`
|
||||
|
||||
// created at
|
||||
CreatedAt string `json:"created_at,omitempty"`
|
||||
|
||||
|
@ -65,6 +69,10 @@ type AddSignalsRequestItem struct {
|
|||
func (m *AddSignalsRequestItem) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateAlertID(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateDecisions(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
@ -107,6 +115,15 @@ func (m *AddSignalsRequestItem) Validate(formats strfmt.Registry) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (m *AddSignalsRequestItem) validateAlertID(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("alert_id", "body", m.AlertID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *AddSignalsRequestItem) validateDecisions(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.Decisions) { // not required
|
||||
return nil
|
||||
|
|
|
@ -944,9 +944,12 @@ definitions:
|
|||
- "start_at"
|
||||
- "stop_at"
|
||||
- "scenario_trust"
|
||||
- "alert_id"
|
||||
properties:
|
||||
scenario_hash:
|
||||
type: "string"
|
||||
alert_id:
|
||||
type: "integer"
|
||||
scenario:
|
||||
type: "string"
|
||||
created_at:
|
||||
|
|
Loading…
Add table
Reference in a new issue