# generated by datamodel-codegen:
#   filename:  media_buy/sync_creatives_request.json
#   timestamp: 2026-02-28T17:39:50+00:00

from __future__ import annotations

from typing import Annotated

from adcp.types.base import AdCPBaseModel
from pydantic import ConfigDict, Field

from ..core import account_ref
from ..core import context as context_1
from ..core import creative_asset
from ..core import ext as ext_1
from ..core import push_notification_config as push_notification_config_1
from ..enums import validation_mode as validation_mode_1


class Assignment(AdCPBaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    creative_id: Annotated[str, Field(description='ID of the creative to assign')]
    package_id: Annotated[str, Field(description='ID of the package to assign the creative to')]
    placement_ids: Annotated[
        list[str] | None,
        Field(
            description='Restrict this creative to specific placements within the package. When omitted, the creative is eligible for all placements.',
            min_length=1,
        ),
    ] = None
    weight: Annotated[
        float | None,
        Field(
            description='Relative delivery weight (0–100). When multiple creatives are assigned to the same package, weights determine impression distribution proportionally — a creative with weight 2 gets twice the delivery of weight 1. When omitted, the creative receives equal rotation with other unweighted creatives. A weight of 0 means the creative is assigned but paused (receives no delivery).',
            ge=0.0,
            le=100.0,
        ),
    ] = None


class SyncCreativesRequest(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    account: Annotated[
        account_ref.AccountReference, Field(description='Account that owns these creatives.')
    ]
    assignments: Annotated[
        list[Assignment] | None,
        Field(
            description='Optional bulk assignment of creatives to packages. Each entry maps one creative to one package with optional weight and placement targeting.',
            min_length=1,
        ),
    ] = None
    context: context_1.ContextObject | None = None
    creative_ids: Annotated[
        list[str] | None,
        Field(
            description='Optional filter to limit sync scope to specific creative IDs. When provided, only these creatives will be created/updated. Other creatives in the library are unaffected. Useful for partial updates and error recovery.',
            max_length=100,
            min_length=1,
        ),
    ] = None
    creatives: Annotated[
        list[creative_asset.CreativeAsset],
        Field(
            description='Array of creative assets to sync (create or update)',
            max_length=100,
            min_length=1,
        ),
    ]
    delete_missing: Annotated[
        bool | None,
        Field(
            description='When true, creatives not included in this sync will be archived. Use with caution for full library replacement.'
        ),
    ] = False
    dry_run: Annotated[
        bool | None,
        Field(
            description='When true, preview changes without applying them. Returns what would be created/updated/deleted.'
        ),
    ] = False
    ext: ext_1.ExtensionObject | None = None
    idempotency_key: Annotated[
        str | None,
        Field(
            description='Client-generated idempotency key for safe retries. If a sync fails without a response, resending with the same idempotency_key guarantees at-most-once execution.',
            max_length=255,
            min_length=8,
        ),
    ] = None
    push_notification_config: Annotated[
        push_notification_config_1.PushNotificationConfig | None,
        Field(
            description='Optional webhook configuration for async sync notifications. Publisher will send webhook when sync completes if operation takes longer than immediate response time (typically for large bulk operations or manual approval/HITL).'
        ),
    ] = None
    validation_mode: Annotated[
        validation_mode_1.ValidationMode | None,
        Field(
            description="Validation strictness. 'strict' fails entire sync on any validation error. 'lenient' processes valid creatives and reports errors."
        ),
    ] = validation_mode_1.ValidationMode.strict
