MCPcopy
hub / github.com/crowdsecurity/crowdsec / GetAlertByID

Method GetAlertByID

pkg/database/alerts.go:984–999  ·  view source on GitHub ↗
(ctx context.Context, alertID int)

Source from the content-addressed store, hash-verified

982}
983
984func (c *Client) GetAlertByID(ctx context.Context, alertID int) (*ent.Alert, error) {
985 alert, err := c.Ent.Alert.Query().Where(alert.IDEQ(alertID)).WithDecisions().WithEvents().WithMetas().WithOwner().First(ctx)
986 if err != nil {
987 // record not found, 404
988 if ent.IsNotFound(err) {
989 log.Warningf("GetAlertByID (not found): %s", err)
990 return nil, ItemNotFound
991 }
992
993 c.Log.Warningf("GetAlertByID : %s", err)
994
995 return nil, QueryFail
996 }
997
998 return alert, nil
999}

Callers 1

FindAlertByIDMethod · 0.80

Calls 9

IDEQFunction · 0.92
IsNotFoundFunction · 0.92
WithMetasMethod · 0.80
WithEventsMethod · 0.80
WithDecisionsMethod · 0.80
FirstMethod · 0.45
WithOwnerMethod · 0.45
WhereMethod · 0.45
QueryMethod · 0.45

Tested by

no test coverage detected