Skip to content

ACL

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

__init__(permissions=None)

Initialize an ACL instance.

Parameters:

Name Type Description Default
permissions dict[Permission, list[User | Group]] | None

A mapping of permission types to lists of users and/or groups. If not provided, a default ACL is created granting the currently signed-in user and the primary group standard permissions.

None

Raises:

Type Description
ValueError

If the signed-in user or the primary group cannot be found when building the default ACL.

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

default_for_user(user) classmethod

Create a default ACL for a given user.

from_dict(acl_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:

Type Description
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:

Type Description
str

A JSON string representation of the ACL.