18 lines
599 B
Python
18 lines
599 B
Python
from dataclasses import dataclass
|
|
|
|
@dataclass(frozen=True)
|
|
class Trigger:
|
|
connector: str
|
|
tenant_id: str
|
|
mode: str = 'incremental'
|
|
idempotency_key: str = ''
|
|
source: str = 'on_demand'
|
|
|
|
class TriggerValidator:
|
|
@staticmethod
|
|
def validate(trigger):
|
|
if trigger.mode not in ('full', 'incremental'): raise ValueError('invalid mode')
|
|
if trigger.source not in ('on_demand', 'schedule', 'webhook'): raise ValueError('invalid source')
|
|
if not trigger.tenant_id or not trigger.connector: raise ValueError('tenant and connector required')
|
|
return trigger
|