Source code for deephaven_enterprise.acl_generator

#
# Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
#
"""This module defines a set of functions for creating filter generators that are used to build ACLs for Persistent
Queries. A filter generator takes the user's credentials and produces one or more filters that are applied to the table
before providing the result to the user.  For more information on ACLs and filter generators, see the Deephaven
documentation https://deephaven.io/enterprise/docs/sys-admin/permissions/acls/#persistent-query-acls.
"""

from typing import Any

import jpy
from deephaven.jcompat import j_array_list
from deephaven.table import Table

JAclFilterGenerator: Any = jpy.get_type(
    "io.deephaven.enterprise.acl.AclFilterGenerator"
)


[docs] def full_access() -> JAclFilterGenerator: """Creates a filter generator that gives full access to the table. Returns: a filter generator """ return JAclFilterGenerator.fullAccess()
[docs] def no_access() -> JAclFilterGenerator: """Creates a filter generator that gives no access to the table. Returns: a filter generator """ return JAclFilterGenerator.noAccess()
[docs] def group(group_column: str, matches_set: bool = False) -> JAclFilterGenerator: """Creates a filter generator that filters rows based on group data contained within the table. Args: group_column (str): the column containing the group data matches_set (bool): if the filter should match groups within a column that is a list or array or groups. Defaults to False. Returns: a filter generator """ return JAclFilterGenerator.group(group_column, matches_set)
[docs] def where(*filters: str) -> JAclFilterGenerator: """Creates a filter generator from a set of simple where clauses. Args: *filters (str): the filters to apply Returns: a filter generator """ return JAclFilterGenerator.where(*filters)
[docs] def where_in( set_namespace: str, set_table_name: str, set_group_column: str, set_filters: list, use_historical: bool, *match_expressions: str, ) -> JAclFilterGenerator: """Creates a filter generator that applies a where_in() filter from a "Set" table containing the grouping information Args: set_namespace (str): the namespace of the "Set" table set_table_name (str): the table name of the "Set" table set_group_column (str): the column in the "Set" table containing the group information set_filters (list): a set of expressions to filter the "Set" table use_historical (bool): if the "Set" table should come from the historical data store *match_expressions (str): the set of columns to match between the two tables Returns: a filter generator """ return JAclFilterGenerator.whereIn( set_namespace, set_table_name, set_group_column, j_array_list(set_filters), use_historical, *match_expressions, )
[docs] def where_in_table( set_table: Table, set_group_column: str, set_filters: list, *match_expressions: str ) -> JAclFilterGenerator: """Creates a filter generator that applies a where_in() filter from a "Set" table containing the grouping information Args: set_table (Table): the set table set_group_column (str): the column in the "Set" table containing the group information set_filters (list): a set of expressions to filter the "Set" table *match_expressions (str): the set of columns to match between the two tables Returns: a filter generator """ return JAclFilterGenerator.whereIn( set_table.j_table, set_group_column, j_array_list(set_filters), *match_expressions, )
[docs] def conjunctive(*generators: JAclFilterGenerator) -> JAclFilterGenerator: """Creates a filter generator that conjunctively combines the input generators Args: *generators (JAclFilterGenerator): the generators to combine Returns: a filter generator """ return JAclFilterGenerator.conjunctive(*generators)
[docs] def disjunctive(*generators: JAclFilterGenerator) -> JAclFilterGenerator: """Creates a filter generator that disjunctively combines the input generators Args: *generators (JAclFilterGenerator): the generators to combine Returns: a filter generator """ return JAclFilterGenerator.disjunctive(*generators)