(ctx context.Context, alertItem *ent.Alert)
| 929 | } |
| 930 | |
| 931 | func (c *Client) DeleteAlertGraph(ctx context.Context, alertItem *ent.Alert) error { |
| 932 | // delete the associated events |
| 933 | _, err := c.Ent.Event.Delete(). |
| 934 | Where(event.HasOwnerWith(alert.IDEQ(alertItem.ID))).Exec(ctx) |
| 935 | if err != nil { |
| 936 | c.Log.Warningf("DeleteAlertGraph : %s", err) |
| 937 | return fmt.Errorf("event with alert ID '%d': %w", alertItem.ID, DeleteFail) |
| 938 | } |
| 939 | |
| 940 | // delete the associated meta |
| 941 | _, err = c.Ent.Meta.Delete(). |
| 942 | Where(meta.HasOwnerWith(alert.IDEQ(alertItem.ID))).Exec(ctx) |
| 943 | if err != nil { |
| 944 | c.Log.Warningf("DeleteAlertGraph : %s", err) |
| 945 | return fmt.Errorf("meta with alert ID '%d': %w", alertItem.ID, DeleteFail) |
| 946 | } |
| 947 | |
| 948 | // delete the associated decisions |
| 949 | _, err = c.Ent.Decision.Delete(). |
| 950 | Where(decision.HasOwnerWith(alert.IDEQ(alertItem.ID))).Exec(ctx) |
| 951 | if err != nil { |
| 952 | c.Log.Warningf("DeleteAlertGraph : %s", err) |
| 953 | return fmt.Errorf("decision with alert ID '%d': %w", alertItem.ID, DeleteFail) |
| 954 | } |
| 955 | |
| 956 | // delete the alert |
| 957 | err = c.Ent.Alert.DeleteOne(alertItem).Exec(ctx) |
| 958 | if err != nil { |
| 959 | c.Log.Warningf("DeleteAlertGraph : %s", err) |
| 960 | return fmt.Errorf("alert with ID '%d': %w", alertItem.ID, DeleteFail) |
| 961 | } |
| 962 | |
| 963 | return nil |
| 964 | } |
| 965 | |
| 966 | func (c *Client) DeleteAlertByID(ctx context.Context, id int) error { |
| 967 | alertItem, err := c.Ent.Alert.Query().Where(alert.IDEQ(id)).Only(ctx) |
no test coverage detected