Module adcp.types.domains.formats.canonical.image_carousel

Classes

class AllowedCardMediaAssetType (*args, **kwds)
Expand source code
class AllowedCardMediaAssetType(StrEnum):
    image = 'image'
    video = 'video'

Enum where members are also (and must be) strings

Ancestors

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

Class variables

var image
var video
class CanonicalFormatImageCarousel (**data: Any)
Expand source code
class CanonicalFormatImageCarousel(CanonicalFormatBase):
    model_config = ConfigDict(
        extra='allow',
    )
    v1_translatable: Annotated[
        Any | None,
        Field(
            description="Inherently new in v2 — multi-card carousels (Meta carousel, Pinterest pin collections, Snap collection ads) weren't expressible as v1 named formats. SDKs MUST NOT emit `FORMAT_PROJECTION_FAILED` for products using this canonical; the v1-unreachability is structural."
        ),
    ] = False
    slots: Annotated[
        Any | None,
        Field(
            description="Default slots for image_carousel. The `cards` slot's value in the manifest is an array of [card-asset](/schemas/core/assets/card-asset.json) objects; `min` / `max` constrain card count."
        ),
    ] = [
        {'asset_group_id': 'cards', 'asset_type': 'card', 'required': True, 'min': 2, 'max': 10},
        {'asset_group_id': 'primary_text', 'asset_type': 'text', 'required': False},
        {'asset_group_id': 'landing_page_url', 'asset_type': 'url', 'required': False},
    ]
    card_aspect_ratio: Annotated[
        str | None,
        Field(
            description="Aspect ratio shared across all cards (e.g., '1:1', '1.91:1', '4:5').",
            pattern='^[0-9]+(\\.[0-9]+)?:[0-9]+(\\.[0-9]+)?$',
        ),
    ] = None
    min_cards: Annotated[
        SchemaInt | None, Field(description='Minimum card count (typical: 2 or 3).', ge=2)
    ] = None
    max_cards: Annotated[
        SchemaInt | None,
        Field(description='Maximum card count (typical: 6, 10, or 35 depending on platform).'),
    ] = None
    allowed_card_media_asset_types: Annotated[
        list[AllowedCardMediaAssetType] | None,
        Field(
            description='Asset types each card\'s `media` field may carry. Default: [\'image\']. Polymorphic carousels (Meta) allow [\'image\', \'video\']. Renamed from `allowed_card_asset_types` to disambiguate that this constrains the card\'s media payload, not the card-asset itself (which is always asset_type: "card").'
        ),
    ] = None
    allowed_card_asset_types: Annotated[
        list[AllowedCardMediaAssetType] | None,
        Field(
            deprecated=True,
            description='DEPRECATED — alias for `allowed_card_media_asset_types`. Kept for back-compat; prefer the new field name. Removed in 5.0.',
        ),
    ] = None
    card_image_max_file_size_kb: Annotated[SchemaInt | None, Field(ge=1)] = None
    card_video_max_file_size_kb: Annotated[SchemaInt | None, Field(ge=1)] = None
    card_video_max_duration_ms: Annotated[SchemaInt | None, Field(ge=1)] = None
    primary_text_max_chars: Annotated[
        SchemaInt | None,
        Field(description='Maximum length of the carousel-level primary text.', ge=1),
    ] = None
    card_headline_max_chars: Annotated[
        SchemaInt | None,
        Field(
            description='Per-card headline character limit. Governs the `headline` field on each card-asset in the `cards` slot.',
            ge=1,
        ),
    ] = None
    card_description_max_chars: Annotated[
        SchemaInt | None,
        Field(
            description='Per-card description character limit. Governs the `description` field on each card-asset in the `cards` slot. Distinct from `card_headline_max_chars`: description is longer body copy (typically 100-500 chars); headline is the short label (typically 25-40 chars).',
            ge=1,
        ),
    ] = None
    ssl_required: StrictBool | None = None

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

  • adcp.types.domains.formats.canonical._base.CanonicalFormatBase
  • AdCPBaseModel
  • pydantic.main.BaseModel

Class variables

var allowed_card_asset_types : list[AllowedCardMediaAssetType] | None
var allowed_card_media_asset_types : list[AllowedCardMediaAssetType] | None
var card_aspect_ratio : str | None
var card_description_max_chars : int | None
var card_headline_max_chars : int | None
var card_image_max_file_size_kb : int | None
var card_video_max_duration_ms : int | None
var card_video_max_file_size_kb : int | None
var max_cards : int | None
var min_cards : int | None
var model_config
var primary_text_max_chars : int | None
var slots : typing.Any | None
var ssl_required : bool | None
var v1_translatable : typing.Any | None

Inherited members