py_abac.storage package¶
Subpackages¶
Submodules¶
py_abac.storage.base module¶
Policy Storage abstract class
-
class
py_abac.storage.base.
Storage
[source]¶ Bases:
object
Base class for policy storage
-
abstract
get_all
(limit: int, offset: int) → Generator[py_abac.policy.policy.Policy, None, None][source]¶ Retrieve all the policies within a window
-
abstract
py_abac.storage.migration module¶
Migration utilities for Storage Migrations
-
class
py_abac.storage.migration.
Migration
[source]¶ Bases:
object
Manager for maintaining various migration actions of the storage: schema, indices, etc
-
abstract property
order
¶ Number of this migration in the row of migrations
-
abstract property
-
class
py_abac.storage.migration.
MigrationSet
[source]¶ Bases:
object
Collection of migrations.
-
down
(number: int = None)[source]¶ Runs migrations down. If number was specified, runs particular migration from the set
-
py_abac.storage.utils module¶
Utility methods used for creating storage
-
py_abac.storage.utils.
get_all_wildcard_queries
(string: str, wildcard: str = '*') → List[str][source]¶ This method computes all possible wildcard queries matching given string.
- Example
"a" -> ['a', '*', '*a*', 'a*', '*a'] "ab" -> ['ab', '*', '*a*', 'a*', '*b', '*b*', '*ab*', 'ab*', '*ab']
See unit tests for more examples.
- Parameters
string – string for which to obtain queries
wildcard – wildcard char in query. Default set to ‘*’
- Returns
list of queries
-
py_abac.storage.utils.
get_sub_wildcard_queries
(query: str, wildcard: str = '*') → List[str][source]¶ This method splits a wildcard query into sub-queries in such a way that if it matches an arbitrary string, then all its sub-queries also match that string. This is achieved by splitting the query by the wildcard and then adding it back as prefix and suffix to the splits.
- Example
"ab*c" -> ["ab*", "*c"] "*a*b" -> ["*a*", "*b"] "ab**" -> ["ab*"]
See unit tests for more examples.
- Parameters
query – wildcard query
wildcard – wildcard char in the query. Default set to ‘*’
- Returns
list of sub-queries