RuleCreate creates a new protection rule for a space.
(ctx context.Context, session *auth.Session, spaceRef string, in *rules.CreateInput, )
| 26 | |
| 27 | // RuleCreate creates a new protection rule for a space. |
| 28 | func (c *Controller) RuleCreate(ctx context.Context, |
| 29 | session *auth.Session, |
| 30 | spaceRef string, |
| 31 | in *rules.CreateInput, |
| 32 | ) (*types.Rule, error) { |
| 33 | space, err := c.getSpaceCheckAuth(ctx, session, spaceRef, enum.PermissionSpaceEdit) |
| 34 | if err != nil { |
| 35 | return nil, fmt.Errorf("failed to acquire access to space: %w", err) |
| 36 | } |
| 37 | |
| 38 | rule, err := c.rulesSvc.Create( |
| 39 | ctx, |
| 40 | &session.Principal, |
| 41 | enum.RuleParentSpace, |
| 42 | space.ID, |
| 43 | space.Identifier, |
| 44 | space.Path, |
| 45 | in, |
| 46 | ) |
| 47 | if err != nil { |
| 48 | return nil, fmt.Errorf("failed to create space-level protection rule: %w", err) |
| 49 | } |
| 50 | |
| 51 | return rule, nil |
| 52 | } |
nothing calls this directly
no test coverage detected