Skip to content

ACL

A class to represent an Access Control List (ACL) for managing permissions.

Parameters:

  • permissions

    (dict[Permission, list[User | Group]] | None, default: None ) –

    A mapping of permission types to lists of users and/or groups.

Example
from datatailr import ACL, Permission, User, Group
acl = ACL({
    Permission.READ: [User.get("alice"), Group.get("analysts")],
    Permission.WRITE: [User.get("alice")],
})

from_dict classmethod

Create an ACL instance from a dictionary.

to_cli_command

Convert the ACL to a command string of the form: group1:rw,group2:rw,....

to_dict

Convert the ACL to a dictionary mapping permission names to entity IDs.

Group IDs are stored as negative numbers to distinguish them from user IDs.

Returns:

  • dict[str, list[int]]

    A dictionary where keys are permission names (e.g. "read") and

  • dict[str, list[int]]

    values are lists of integer entity IDs.

to_json

Serialize the ACL to a JSON string.

Returns:

  • str

    A JSON string representation of the ACL.