# generated by datamodel-codegen:
#   filename:  media_buy/update_media_buy_request.json
#   timestamp: 2025-12-11T15:09:37+00:00

from __future__ import annotations

from typing import Annotated

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

from ..core import context as context_1
from ..core import creative_asset, creative_assignment
from ..core import ext as ext_1
from ..core import push_notification_config as push_notification_config_1
from ..core import start_timing, targeting
from ..enums import pacing as pacing_1


class Packages(AdCPBaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    bid_price: Annotated[
        float | None,
        Field(
            description='Updated bid price for auction-based pricing options (only applies when pricing_option is auction-based)',
            ge=0.0,
        ),
    ] = None
    budget: Annotated[
        float | None,
        Field(
            description='Updated budget allocation for this package in the currency specified by the pricing option',
            ge=0.0,
        ),
    ] = None
    buyer_ref: Annotated[
        str | None, Field(description="Buyer's reference for the package to update")
    ] = None
    creative_assignments: Annotated[
        list[creative_assignment.CreativeAssignment] | None,
        Field(
            description='Full creative assignment objects with weights and placement targeting (alternative to creative_ids - provides granular control over weights and placement targeting). Uses replacement semantics like creative_ids.'
        ),
    ] = None
    creative_ids: Annotated[
        list[str] | None,
        Field(description='Update creative assignments (references existing library creatives)'),
    ] = None
    creatives: Annotated[
        list[creative_asset.CreativeAsset] | None,
        Field(
            description='Full creative objects to upload and assign to this package (alternative to creative_ids - creatives will be added to library). Supports both static and generative creatives.',
            max_length=100,
        ),
    ] = None
    pacing: pacing_1.Pacing | None = None
    package_id: Annotated[str, Field(description="Publisher's ID of package to update")]
    paused: Annotated[
        bool | None,
        Field(description='Pause/resume specific package (true = paused, false = active)'),
    ] = None
    targeting_overlay: targeting.TargetingOverlay | None = None


class Packages1(AdCPBaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    bid_price: Annotated[
        float | None,
        Field(
            description='Updated bid price for auction-based pricing options (only applies when pricing_option is auction-based)',
            ge=0.0,
        ),
    ] = None
    budget: Annotated[
        float | None,
        Field(
            description='Updated budget allocation for this package in the currency specified by the pricing option',
            ge=0.0,
        ),
    ] = None
    buyer_ref: Annotated[str, Field(description="Buyer's reference for the package to update")]
    creative_assignments: Annotated[
        list[creative_assignment.CreativeAssignment] | None,
        Field(
            description='Full creative assignment objects with weights and placement targeting (alternative to creative_ids - provides granular control over weights and placement targeting). Uses replacement semantics like creative_ids.'
        ),
    ] = None
    creative_ids: Annotated[
        list[str] | None,
        Field(description='Update creative assignments (references existing library creatives)'),
    ] = None
    creatives: Annotated[
        list[creative_asset.CreativeAsset] | None,
        Field(
            description='Full creative objects to upload and assign to this package (alternative to creative_ids - creatives will be added to library). Supports both static and generative creatives.',
            max_length=100,
        ),
    ] = None
    pacing: pacing_1.Pacing | None = None
    package_id: Annotated[str | None, Field(description="Publisher's ID of package to update")] = (
        None
    )
    paused: Annotated[
        bool | None,
        Field(description='Pause/resume specific package (true = paused, false = active)'),
    ] = None
    targeting_overlay: targeting.TargetingOverlay | None = None


class UpdateMediaBuyRequest1(AdCPBaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    buyer_ref: Annotated[
        str | None, Field(description="Buyer's reference for the media buy to update")
    ] = None
    context: context_1.ContextObject | None = None
    end_time: Annotated[
        AwareDatetime | None, Field(description='New end date/time in ISO 8601 format')
    ] = None
    ext: ext_1.ExtensionObject | None = None
    media_buy_id: Annotated[str, Field(description="Publisher's ID of the media buy to update")]
    packages: Annotated[
        list[Packages | Packages1] | None, Field(description='Package-specific updates')
    ] = None
    paused: Annotated[
        bool | None,
        Field(description='Pause/resume the entire media buy (true = paused, false = active)'),
    ] = None
    push_notification_config: Annotated[
        push_notification_config_1.PushNotificationConfig | None,
        Field(
            description='Optional webhook configuration for async update notifications. Publisher will send webhook when update completes if operation takes longer than immediate response time.'
        ),
    ] = None
    start_time: start_timing.StartTiming | None = None


Packages2 = Packages


Packages3 = Packages1


class UpdateMediaBuyRequest2(AdCPBaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    buyer_ref: Annotated[str, Field(description="Buyer's reference for the media buy to update")]
    context: context_1.ContextObject | None = None
    end_time: Annotated[
        AwareDatetime | None, Field(description='New end date/time in ISO 8601 format')
    ] = None
    ext: ext_1.ExtensionObject | None = None
    media_buy_id: Annotated[
        str | None, Field(description="Publisher's ID of the media buy to update")
    ] = None
    packages: Annotated[
        list[Packages2 | Packages3] | None, Field(description='Package-specific updates')
    ] = None
    paused: Annotated[
        bool | None,
        Field(description='Pause/resume the entire media buy (true = paused, false = active)'),
    ] = None
    push_notification_config: Annotated[
        push_notification_config_1.PushNotificationConfig | None,
        Field(
            description='Optional webhook configuration for async update notifications. Publisher will send webhook when update completes if operation takes longer than immediate response time.'
        ),
    ] = None
    start_time: start_timing.StartTiming | None = None


class UpdateMediaBuyRequest(RootModel[UpdateMediaBuyRequest1 | UpdateMediaBuyRequest2]):
    root: Annotated[
        UpdateMediaBuyRequest1 | UpdateMediaBuyRequest2,
        Field(
            description='Request parameters for updating campaign and package settings',
            title='Update Media Buy Request',
        ),
    ]
