Skip to content

feat(maasservicelayer): add bulk-remove and bulk-create operations for users and entitlements in groups#163

Open
nehjoshi wants to merge 4 commits intocanonical:masterfrom
nehjoshi:bulk-permissions
Open

feat(maasservicelayer): add bulk-remove and bulk-create operations for users and entitlements in groups#163
nehjoshi wants to merge 4 commits intocanonical:masterfrom
nehjoshi:bulk-permissions

Conversation

@nehjoshi
Copy link
Copy Markdown
Contributor

@nehjoshi nehjoshi commented Apr 17, 2026

Added 3 new endpoints:

  1. POST /groups/{group_id}/members:batch_create: For adding multiple users to a group in one operation. The batch_create suffix is appended to separate this endpoint from the POST /groups/{group_id}/members for adding a single member.
  2. DELETE /groups/{group_id}/members: For removing multiple users from a group in one operation
  3. POST /groups/{group_id}/entitlements:batch_delete: Removes multiple entitlements from a group in a single operation. Entitlements within a group do not have a unique id. Instead, each entitlement is identified by a combination of fields: resource_type, resource_id, and entitlement (e.g. can_edit_machines). Deleting multiple entitlements therefore requires sending a structured payload (e.g. an array of these field combinations).
    While this could map to a DELETE endpoint, doing so would require a request body. In practice, request bodies on DELETE are discouraged by MDN (see docs). For this reason, POST is chosen. Also, the suffix batch_delete is appended because POST /groups/{group_id}/entitlements already exists for entitlement creation.

The following endpoints are modified and now include pagination:

  1. GET /groups/{group_id}/members
  2. GET /groups/{group_id}/entitlements

Resolves MAASENG-6347

@nehjoshi nehjoshi marked this pull request as ready for review April 17, 2026 13:42
@nehjoshi nehjoshi requested a review from a team April 17, 2026 13:42
@nehjoshi nehjoshi marked this pull request as draft April 19, 2026 19:28
@nehjoshi nehjoshi marked this pull request as ready for review April 19, 2026 19:59
Comment thread src/maasapiserver/v3/api/public/handlers/usergroups.py Outdated
async def bulk_delete_entitlements(
self,
group_id: int,
items: list[tuple[str, str, int]],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I discourage to pass list[tuple[str,str,int]]. Use a typed model instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants