Files
motia/bitbylaw/steps/advoware_cal_sync/calendar_sync_api_step.md
2026-02-07 09:23:49 +00:00

2.3 KiB

type, category, name, version, status, tags, dependencies, emits
type category name version status tags dependencies emits
step api Calendar Sync API 1.0.0 active
calendar
sync
api
manual-trigger
redis
calendar_sync_all
calendar_sync_employee

Calendar Sync API Step

Zweck

Manueller Trigger für Calendar-Synchronisation via HTTP-Endpoint. Ermöglicht Sync für alle oder einzelne Mitarbeiter.

Config

{
    'type': 'api',
    'name': 'Calendar Sync API',
    'path': '/advoware/calendar/sync',
    'method': 'POST',
    'emits': ['calendar_sync_all', 'calendar_sync_employee'],
    'flows': ['advoware_cal_sync']
}

Input

POST /advoware/calendar/sync
Content-Type: application/json

{
  "kuerzel": "ALL",  # or specific: "SB"
  "full_content": true
}

Parameters:

  • kuerzel (optional): "ALL" oder Mitarbeiter-Kürzel (default: "ALL")
  • full_content (optional): true = volle Details, false = anonymisiert (default: true)

Output

{
  "status": "triggered",
  "kuerzel": "ALL",
  "message": "Calendar sync triggered for ALL"
}

Verhalten

Case 1: ALL (oder kein kuerzel):

  1. Emit calendar_sync_all event
  2. calendar_sync_all_step fetcht alle Employees
  3. Pro Employee: Emit calendar_sync_employee

Case 2: Specific Employee (z.B. "SB"):

  1. Set Redis Lock: calendar_sync:lock:SB
  2. Emit calendar_sync_employee event direkt
  3. Lock verhindert parallele Syncs für denselben Employee

Redis Locking

lock_key = f'calendar_sync:lock:{kuerzel}'
redis_client.set(lock_key, '1', nx=True, ex=300)  # 5min TTL

Testing

# Sync all employees
curl -X POST "http://localhost:3000/advoware/calendar/sync" \
  -H "Content-Type: application/json" \
  -d '{"full_content": true}'

# Sync single employee
curl -X POST "http://localhost:3000/advoware/calendar/sync" \
  -H "Content-Type: application/json" \
  -d '{"kuerzel": "SB", "full_content": true}'

# Sync with anonymization
curl -X POST "http://localhost:3000/advoware/calendar/sync" \
  -H "Content-Type: application/json" \
  -d '{"kuerzel": "SB", "full_content": false}'

Error Handling

  • Lock active: Wartet oder gibt Fehler zurück
  • Invalid kuerzel: Wird an all_step oder event_step weitergegeben