cloak-api / copilot /adapters /__init__.py
n1th1sh's picture
Upload 35 files
375880c verified
Raw History Blame Contribute Delete
1.31 kB
"""One adapter per policy type. Adding a type means adding one entry here."""
from __future__ import annotations
from functools import partial
from importlib import import_module
from ..platform import catalog
# Policy types this build creates. The others are still recognised in a sentence (so "on Slack" is never
# turned into a laptop policy) and answered with "not available yet". The endpoint-only package sets this
# to ('endpoint',) and ships without the other adapter modules.
ENABLED_TYPES = catalog.POLICY_TYPES
_BUILDERS = {
'endpoint': ('endpoint', 'build', {}),
'email': ('email', 'build', {}),
'slack': ('messaging', 'build_slack', {}),
'teams': ('messaging', 'build_teams', {}),
'chat': ('messaging', 'build_chat', {}),
'drive': ('files', 'build_drive', {}),
'm365files': ('files', 'build_m365files', {}),
's3': ('storage', 'build', {'kind': 's3'}),
'gcs': ('storage', 'build', {'kind': 'gcs'}),
'azure': ('storage', 'build', {'kind': 'azure'}),
'github': ('storage', 'build', {'kind': 'github'}),
}
def _load(policy_type: str):
module, name, kwargs = _BUILDERS[policy_type]
fn = getattr(import_module(f'.{module}', __name__), name)
return partial(fn, **kwargs) if kwargs else fn
ADAPTERS = {t: _load(t) for t in ENABLED_TYPES}