Module adcp.types.domains.media_buy.change_term

Classes

class AllowedStatus (*args, **kwds)
Expand source code
class AllowedStatus(StrEnum):
    pending_creatives = 'pending_creatives'
    pending_start = 'pending_start'
    active = 'active'
    paused = 'paused'

Enum where members are also (and must be) strings

Ancestors

  • enum.StrEnum
  • builtins.str
  • enum.ReprEnum
  • enum.Enum

Class variables

var active
var paused
var pending_creatives
var pending_start
class Condition (value: Any = <object object>, *, root: Any = <object object>)
Expand source code
class Condition(ScalarStr):
    __slots__ = ()
    _constraints = {'pattern': '^[A-Za-z0-9][A-Za-z0-9_.:-]{0,199}$'}

A str generated from a JSON Schema string root.

Ancestors

  • adcp.types._scalar.ScalarStr
  • adcp.types._scalar._ScalarRoot
  • builtins.str
class MediaBuyChangeTerm (**data: Any)
Expand source code
class MediaBuyChangeTerm(AdCPBaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    term_id: Annotated[str, Field(pattern='^[A-Za-z0-9_.:-]+$')]
    action: canonical_media_buy_action.CanonicalMediaBuyActionName
    service_mode: canonical_media_buy_action_mode.CanonicalMediaBuyActionMode
    allowed_statuses: Annotated[
        list[AllowedStatus] | None,
        Field(
            description='Non-terminal MediaBuy statuses in which this negotiated right may be exercised. When absent, the right applies in every non-terminal status where the canonical action itself is meaningful. This field describes contractual lifecycle scope; available_actions[] remains authoritative for the current instant.',
            min_length=1,
        ),
    ] = None
    processing_sla: Annotated[
        sla_window.SlaWindow | None,
        Field(
            description='Binding elapsed-time acknowledgement and completion commitment. Sellers account for weekends and non-working periods when declaring the maximum.'
        ),
    ] = None
    conditions: Annotated[
        list[Condition] | None,
        Field(
            description='Opaque stable condition identifiers defined by terms_ref or bilateral commercial documentation. Implementations compare identifiers; they MUST NOT execute or interpret them as instructions.',
            min_length=1,
        ),
    ] = None
    constraints: Annotated[
        change_term_constraints.MediaBuyChangeTermConstraints | None,
        Field(
            description='Portable bounds that buyer and seller SDKs can preflight. Omission means no machine-readable bound was promised; opaque conditions remain unevaluated.'
        ),
    ] = None
    terms_ref: Annotated[
        str | None,
        Field(
            description="Stable contract reference. Resolving it cannot expand the typed right and MUST use the caller's normal authenticated contract-document path, never ambient seller credentials.",
            max_length=1000,
            min_length=1,
        ),
    ] = None
    description: Annotated[
        str | None,
        Field(
            description='Display-only summary; it cannot grant authority, add an action, or override typed fields.',
            max_length=1000,
            min_length=1,
        ),
    ] = None
    ext: ext_1.ExtensionObject | None = None

    @model_validator(mode='after')
    def _validate_constraint_action(self) -> MediaBuyChangeTerm:
        if self.constraints is None:
            return self
        kind = self.constraints.kind
        allowed = {
            'budget': {
                'increase_budget', 'decrease_budget', 'reallocate_budget',
                'update_budget_allocation', 'update_spend_target',
            },
            'flight': {'extend_flight', 'shorten_flight', 'update_flight_dates'},
            'package_count': {'add_packages', 'remove_packages'},
            'effective_timing': {'pause', 'resume', 'cancel'},
        }
        action = self.action.value
        if action not in allowed.get(kind, set()):
            raise ValueError('constraint kind is incompatible with action')
        return self

Base model for AdCP types with spec-compliant serialization.

Defaults to extra='ignore' so unknown fields from newer spec versions are silently dropped rather than causing validation errors. Generated types whose schemas set additionalProperties: true override this with extra='allow' in their own model_config.

Set ADCP_STRICT_VALIDATION=1 in the environment ("1", "true", "yes", "on" are accepted) to flip the default to extra='forbid'. Use this during spec upgrades to catch silently-dropped renamed fields in tests. See :func:_resolve_extra_policy.

Important

The env var is resolved once at module import time. Set it in your shell or CI environment before import adcp runs — mutating os.environ["ADCP_STRICT_VALIDATION"] after the first adcp import has no effect on already-imported model classes (they captured the policy at class-body evaluation).

Consumers who want per-model strict validation can override model_config on their subclass.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Ancestors

Class variables

var action : CanonicalMediaBuyActionName
var allowed_statuses : list[AllowedStatus] | None
var conditions : list[Condition] | None
var constraints : MediaBuyChangeTermConstraints1 | MediaBuyChangeTermConstraints2 | MediaBuyChangeTermConstraints3 | MediaBuyChangeTermConstraints4 | None
var description : str | None
var ext : ExtensionObject | None
var model_config
var processing_sla : SlaWindow | None
var service_mode : CanonicalMediaBuyActionMode
var term_id : str
var terms_ref : str | None

Inherited members