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

Method DeleteAllowList

pkg/database/allowlists.go:42–63  ·  view source on GitHub ↗
(ctx context.Context, name string, fromConsole bool)

Source from the content-addressed store, hash-verified

40}
41
42func (c *Client) DeleteAllowList(ctx context.Context, name string, fromConsole bool) error {
43 nbDeleted, err := c.Ent.AllowListItem.Delete().Where(allowlistitem.HasAllowlistWith(allowlist.NameEQ(name), allowlist.FromConsoleEQ(fromConsole))).Exec(ctx)
44 if err != nil {
45 return fmt.Errorf("unable to delete allowlist items: %w", err)
46 }
47
48 c.Log.Debugf("deleted %d items from allowlist %s", nbDeleted, name)
49
50 nbDeleted, err = c.Ent.AllowList.
51 Delete().
52 Where(allowlist.NameEQ(name), allowlist.FromConsoleEQ(fromConsole)).
53 Exec(ctx)
54 if err != nil {
55 return fmt.Errorf("unable to delete allowlist: %w", err)
56 }
57
58 if nbDeleted == 0 {
59 return fmt.Errorf("allowlist %s not found", name)
60 }
61
62 return nil
63}
64
65func (c *Client) DeleteAllowListByID(ctx context.Context, name string, allowlistID string, fromConsole bool) error {
66 nbDeleted, err := c.Ent.AllowListItem.Delete().Where(allowlistitem.HasAllowlistWith(allowlist.AllowlistIDEQ(allowlistID), allowlist.FromConsoleEQ(fromConsole))).Exec(ctx)

Callers 1

deleteMethod · 0.80

Calls 6

HasAllowlistWithFunction · 0.92
NameEQFunction · 0.92
FromConsoleEQFunction · 0.92
ExecMethod · 0.45
WhereMethod · 0.45
DeleteMethod · 0.45

Tested by

no test coverage detected