| 22 | const allowlistExpireDecisionsBatchSize = 300 |
| 23 | |
| 24 | func (c *Client) CreateAllowList(ctx context.Context, name string, description string, allowlistID string, fromConsole bool) (*ent.AllowList, error) { |
| 25 | allowlist, err := c.Ent.AllowList.Create(). |
| 26 | SetName(name). |
| 27 | SetFromConsole(fromConsole). |
| 28 | SetDescription(description). |
| 29 | SetAllowlistID(allowlistID). |
| 30 | Save(ctx) |
| 31 | if err != nil { |
| 32 | if sqlgraph.IsUniqueConstraintError(err) { |
| 33 | return nil, fmt.Errorf("allowlist '%s' already exists", name) |
| 34 | } |
| 35 | |
| 36 | return nil, fmt.Errorf("unable to create allowlist: %w", err) |
| 37 | } |
| 38 | |
| 39 | return allowlist, nil |
| 40 | } |
| 41 | |
| 42 | func (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) |