policyweaver.core.common¶
policyweaver.core.common¶
- class policyweaver.core.common.PolicyWeaverCore(type: PolicyWeaverConnectorType, config: SourceMap)¶
Bases:
objectCore class for Policy Weaver, responsible for mapping policies from various sources to a unified format. This class initializes with a connector type and configuration, and provides a method to map policies. Example usage:
core = PolicyWeaverCore(PolicyWeaverConnectorType.AZURE, config) policy_export = core.map_policy()
- map_policy() PolicyExport¶
Map policies from the configured source to a unified format. This method retrieves policies from the source, processes them, and returns a PolicyExport object containing the mapped policies. Returns:
PolicyExport: An object containing the mapped policies.
- class policyweaver.core.common.SnapshotExport(directory: str = None)¶
Bases:
objectA class to handle the export of snapshots to a specified directory. This class provides methods to export snapshots for different types of sources (e.g., dbx, fabric) and unmapped snapshots. It creates directories for each type and saves the snapshots in JSON format. Example usage:
snapshot_export = SnapshotExport(directory=”/path/to/export”) snapshot_export.dbx_export_snapshot(snapshot_data)
- dbx_export_snapshot(snapshot: dict)¶
Export a snapshot for Databricks (dbx) to the specified directory. Args:
snapshot (dict): The snapshot data to be exported. This method creates a directory for dbx snapshots if it doesn’t exist and saves the snapshot in JSON format with a timestamped filename.
- fabric_export_snapshot(snapshot: dict)¶
Export a snapshot for Fabric to the specified directory. Args:
snapshot (dict): The snapshot data to be exported. This method creates a directory for fabric snapshots if it doesn’t exist and saves the snapshot in JSON format with a timestamped filename.
- unmapped_snapshot(snapshot: dict)¶
Export an unmapped snapshot to the specified directory. Args:
snapshot (dict): The snapshot data to be exported. This method creates a directory for unmapped snapshots if it doesn’t exist and saves the snapshot in JSON format with a timestamped filename.
- class policyweaver.core.common.classproperty(fget=None, fset=None, fdel=None, doc=None)¶
Bases:
propertyA class property decorator that allows you to define properties that can be accessed on the class itself. Usage:
- class MyClass:
@classproperty def my_property(cls):
return “This is a class property