b42e1cd091
Build + Deploy / build-admin-compliance (push) Successful in 2m10s
Build + Deploy / build-backend-compliance (push) Successful in 5m20s
Build + Deploy / build-ai-sdk (push) Successful in 57s
Build + Deploy / build-developer-portal (push) Successful in 1m15s
Build + Deploy / build-tts (push) Successful in 2m3s
Build + Deploy / build-document-crawler (push) Successful in 53s
Build + Deploy / build-dsms-gateway (push) Successful in 38s
Build + Deploy / build-dsms-node (push) Successful in 20s
CI / branch-name (push) Has been skipped
CI / guardrail-integrity (push) Has been skipped
CI / loc-budget (push) Failing after 18s
CI / secret-scan (push) Has been skipped
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / nodejs-build (push) Successful in 2m40s
CI / dep-audit (push) Has been skipped
CI / sbom-scan (push) Has been skipped
CI / test-go (push) Successful in 48s
CI / test-python-backend (push) Successful in 44s
CI / test-python-document-crawler (push) Successful in 26s
CI / test-python-dsms-gateway (push) Successful in 25s
CI / validate-canonical-controls (push) Successful in 15s
Build + Deploy / trigger-orca (push) Successful in 3m32s
Add _resolve_geo_from_timezone() with 35-country IANA timezone map. Accept timezone field in ConsentCreate schema and pass through to service. Populate geo_country automatically from browser timezone. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
118 lines
3.4 KiB
Python
118 lines
3.4 KiB
Python
"""
|
|
Banner consent schemas — cookie consent SDK + admin configuration.
|
|
|
|
Phase 1 Step 4: extracted from ``compliance.api.banner_routes`` so the
|
|
route layer becomes thin delegation to ``compliance.services.banner_*``.
|
|
"""
|
|
|
|
from typing import Any, List, Optional
|
|
|
|
from pydantic import BaseModel, ConfigDict
|
|
|
|
|
|
class ConsentCreate(BaseModel):
|
|
"""Request body for recording a device consent."""
|
|
site_id: str
|
|
device_fingerprint: str
|
|
categories: List[str] = []
|
|
vendors: List[str] = []
|
|
vendor_consents: dict[str, bool] = {}
|
|
ip_address: Optional[str] = None
|
|
user_agent: Optional[str] = None
|
|
consent_string: Optional[str] = None
|
|
# Vendor-agnostische Felder (Migration 107)
|
|
consent_method: Optional[str] = None
|
|
page_url: Optional[str] = None
|
|
referrer: Optional[str] = None
|
|
device_type: Optional[str] = None
|
|
browser: Optional[str] = None
|
|
os: Optional[str] = None
|
|
screen_resolution: Optional[str] = None
|
|
session_id: Optional[str] = None
|
|
consent_scope: Optional[str] = None
|
|
timezone: Optional[str] = None
|
|
# Script/Cookie-Tracking (Migration 108)
|
|
scripts_blocked: List[dict[str, Any]] = []
|
|
scripts_released: List[dict[str, Any]] = []
|
|
cookies_set: List[dict[str, Any]] = []
|
|
|
|
|
|
class SiteConfigCreate(BaseModel):
|
|
"""Request body for creating a banner site configuration."""
|
|
site_id: str
|
|
site_name: Optional[str] = None
|
|
site_url: Optional[str] = None
|
|
banner_title: Optional[str] = None
|
|
banner_description: Optional[str] = None
|
|
privacy_url: Optional[str] = None
|
|
imprint_url: Optional[str] = None
|
|
dsb_name: Optional[str] = None
|
|
dsb_email: Optional[str] = None
|
|
theme: Optional[dict[str, Any]] = None
|
|
tcf_enabled: bool = False
|
|
|
|
|
|
class SiteConfigUpdate(BaseModel):
|
|
"""Partial update for a banner site configuration."""
|
|
|
|
model_config = ConfigDict(extra="ignore")
|
|
|
|
site_name: Optional[str] = None
|
|
site_url: Optional[str] = None
|
|
banner_title: Optional[str] = None
|
|
banner_description: Optional[str] = None
|
|
privacy_url: Optional[str] = None
|
|
imprint_url: Optional[str] = None
|
|
dsb_name: Optional[str] = None
|
|
dsb_email: Optional[str] = None
|
|
theme: Optional[dict[str, Any]] = None
|
|
tcf_enabled: Optional[bool] = None
|
|
is_active: Optional[bool] = None
|
|
|
|
|
|
class CategoryConfigCreate(BaseModel):
|
|
"""Request body for adding a cookie category to a site."""
|
|
category_key: str
|
|
name_de: str
|
|
name_en: Optional[str] = None
|
|
description_de: Optional[str] = None
|
|
description_en: Optional[str] = None
|
|
is_required: bool = False
|
|
sort_order: int = 0
|
|
|
|
|
|
class VendorConfigCreate(BaseModel):
|
|
"""Request body for adding a vendor under a site's category."""
|
|
vendor_name: str
|
|
vendor_url: Optional[str] = None
|
|
category_key: str
|
|
description_de: Optional[str] = None
|
|
description_en: Optional[str] = None
|
|
cookie_names: List[str] = []
|
|
retention_days: int = 365
|
|
|
|
|
|
class LinkEmailRequest(BaseModel):
|
|
"""Request body for linking an email to a device fingerprint."""
|
|
site_id: str
|
|
device_fingerprint: str
|
|
email: str
|
|
|
|
|
|
class ConsentSyncRequest(BaseModel):
|
|
"""Request body for syncing banner consent to Einwilligungen."""
|
|
site_id: str
|
|
device_fingerprint: str
|
|
email: str
|
|
|
|
|
|
__all__ = [
|
|
"ConsentCreate",
|
|
"SiteConfigCreate",
|
|
"SiteConfigUpdate",
|
|
"CategoryConfigCreate",
|
|
"VendorConfigCreate",
|
|
"LinkEmailRequest",
|
|
"ConsentSyncRequest",
|
|
]
|