# generated by datamodel-codegen:
#   filename:  media_buy/package_update.json
#   timestamp: 2026-02-22T00:26:42+00:00

from __future__ import annotations

from typing import Annotated

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

from ..core import catalog as catalog_1
from ..core import creative_asset, creative_assignment
from ..core import ext as ext_1
from ..core import optimization_goal as optimization_goal_1
from ..core import targeting
from ..enums import pacing as pacing_1


class PackageUpdate1(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    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
    catalog: Annotated[
        catalog_1.Catalog | None,
        Field(
            description='Update the catalog this package promotes. Replaces the current catalog reference.'
        ),
    ] = None
    creative_assignments: Annotated[
        list[creative_assignment.CreativeAssignment] | None,
        Field(
            description='Replace creative assignments for this package with optional weights and placement targeting. Uses replacement semantics - omit to leave assignments unchanged.'
        ),
    ] = None
    creatives: Annotated[
        list[creative_asset.CreativeAsset] | None,
        Field(
            description='Upload new creative assets and assign to this package (creatives will be added to library). Use creative_assignments instead for existing library creatives.',
            max_length=100,
            min_length=1,
        ),
    ] = None
    ext: ext_1.ExtensionObject | None = None
    impressions: Annotated[
        float | None, Field(description='Updated impression goal for this package', ge=0.0)
    ] = None
    optimization_goal: optimization_goal_1.OptimizationGoal | None = 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 PackageUpdate2(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    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")]
    catalog: Annotated[
        catalog_1.Catalog | None,
        Field(
            description='Update the catalog this package promotes. Replaces the current catalog reference.'
        ),
    ] = None
    creative_assignments: Annotated[
        list[creative_assignment.CreativeAssignment] | None,
        Field(
            description='Replace creative assignments for this package with optional weights and placement targeting. Uses replacement semantics - omit to leave assignments unchanged.'
        ),
    ] = None
    creatives: Annotated[
        list[creative_asset.CreativeAsset] | None,
        Field(
            description='Upload new creative assets and assign to this package (creatives will be added to library). Use creative_assignments instead for existing library creatives.',
            max_length=100,
            min_length=1,
        ),
    ] = None
    ext: ext_1.ExtensionObject | None = None
    impressions: Annotated[
        float | None, Field(description='Updated impression goal for this package', ge=0.0)
    ] = None
    optimization_goal: optimization_goal_1.OptimizationGoal | None = 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 PackageUpdate(RootModel[PackageUpdate1 | PackageUpdate2]):
    root: Annotated[
        PackageUpdate1 | PackageUpdate2,
        Field(
            description='Package update configuration for update_media_buy. Identifies package by package_id or buyer_ref and specifies fields to modify. Fields not present are left unchanged. Note: product_id, format_ids, and pricing_option_id cannot be changed after creation.',
            title='Package Update',
        ),
    ]
