angelos.common.policy¶
Applying policy checks and actions.
This is a framework for validating objects according to policies. The policies are organized in layers of rings and ring sections, each policy has a serial number and a description of its purpose. When an object is validated, a report is generated containing all validated policys and the result of failed policys.
# Layers:
The layers of policys is divided into 7 rings where 1 is the innermost layer. Each layer can be divided into sections. Each individual policy has a totally unique serial number that is chronological from when the policys where organized, and a description.
Example: 1A-0001; Policy purpose and description.
1: Fields * A: … * B: …
2: Documents * C: … * D: … * E: …
3: Portfolios * F: … * G: … * H: … * J: …
4: Facade * K: … * L: … * M: … * N: …
5: Nodes * P: … * Q: … * R: … * S: …
6: Domain * T: … * U: … * V: … * X: …
7: Network * Y: … * Z: …
-
class
angelos.common.policy.BasePolicyApplier¶ Bases:
abc.ABCApply all mixed in policies.
-
exception
angelos.common.policy.PolicyBreachException(message, report: angelos.common.policy.Report)¶ Bases:
RuntimeError
-
exception
angelos.common.policy.PolicyException¶ Bases:
RuntimeWarning
-
class
angelos.common.policy.PolicyMixin¶ Bases:
abc.ABCBase class that applies one policy.
-
abstract
apply() → bool¶ Implement policy to be applied here, then decorate with @policy(section=b’I’ sn=0).
-
abstract
-
class
angelos.common.policy.PolicyPerformer¶ Bases:
angelos.common.policy.BasePolicyApplierBase class for policies to be performed.
-
abstract
perform(**kwargs)¶ Perform an action.
-
abstract
-
class
angelos.common.policy.PolicyValidator¶ Bases:
angelos.common.policy.BasePolicyApplierBase class for policies that validates data.
-
abstract
validate(**kwargs)¶ Execute validation.
-
abstract
-
class
angelos.common.policy.Report(event=None)¶ Bases:
objectValidation report that keeps a record of applied policies and failures.
-
NULL_IDENTITY= UUID('00000000-0000-0000-0000-000000000000')¶
-
NULL_POLICY= (b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 73, 0)¶
-
POLICY= {b'A': '1A', b'B': '1B', b'C': '2C', b'D': '2D', b'E': '2E', b'F': '3F', b'G': '3G', b'H': '3H', b'J': '3J', b'K': '4K', b'L': '4L', b'M': '4M', b'N': '4N', b'P': '5P', b'Q': '5Q', b'R': '5R', b'S': '5S', b'T': '6T', b'U': '6U', b'V': '6V', b'X': '6X', b'Y': '7Y', b'Z': '7Z'}¶
-
property
applied¶ All applied policies.
-
down(level: bytes)¶ Go back from level depth.
- Parameters
level (bytes) – Level name/info.
-
property
failed¶ - Type
All failed policy runtime ID
-
format(barrier='-')¶ Print report.
-
property
id¶ Report unique UUID
-
record(section: bytes, sn: int, failed: bool = False)¶ Add a policy record.
- Parameters
section (bytes) – Policy section from which layer is calculated.
sn (int) – Policy chronological serial number.
failed (bool) – True or False whether the check failed.
-
property
timestamp¶ Report timestamp.
-
up(level: bytes)¶ Go one level deeper.
- Parameters
level (bytes) – Level name/info.
-
-
class
angelos.common.policy.evaluate(event=None)¶ Bases:
contextlib.ContextDecorator,contextlib.AbstractContextManagerEvaluate decorator and context manager.
Wrap methods or enclose pieces of code that you want to evaluate that they are complying with certain policies.
-
angelos.common.policy.policy()¶ Policy decorator.
- Parameters
section (bytes) – Policy section
sn (int) – Policy serial number
level (str) – Instruct report to add a level
- Returns (callable):
Wrapper writing policy to the report