Module leapyear.admin.grants

Convenience functions for retrieving grants on resources.

Access Summaries

leapyear.admin.grants.DatabaseAccess(subject, database, access)
leapyear.admin.grants.TableAccess(subject, table, columns)

Functions

leapyear.admin.grants.all_access_on_database(db)

Fetch the database access for all users or groups.

Examples

>>> db = client.databases['db']
>>> for subject, access_db, access in all_grants_on_database(db):
...     assert isinstance(subject, User) or isinstance(subject, Group)
...     assert access_db == db
...     assert isinstance(access, DatabaseAccessType)
...
Parameters

db (Database) –

Returns

Return type

List[DatabaseAccess]

leapyear.admin.grants.all_access_on_table(table)

Fetch the column access for all columns in the given table for all users or groups.

Examples

>>> table = client.databases['db'].tables['table']
>>> for subject, access_table, columns in all_access_on_table(table):
...     assert isinstance(subject, User) or isinstance(subject, Group)
...     assert access_table == table
...     for column_name, column_access in columns.items():
...         assert isinstance(column_name, str)
...         assert isinstance(column_access, ColumnAccessType)
...
Parameters

table (Table) –

Returns

Return type

List[TableAccess]

leapyear.admin.grants.all_database_accesses_for_subject(subject)

Fetch the access of all databases for the given subject.

Examples

>>> user = client.users['user']
>>> for subject, db, access in all_database_accesses_for_subject(user):
...     assert subject == user
...     assert isinstance(db, Database)
...     assert isinstance(access, DatabaseAccessType)
...
Parameters

subject (Union[User, Group]) –

Returns

Return type

List[DatabaseAccess]