Module adcp.compat.legacy.v2_5.update_media_buy

v2.5 → v3 adapter for update_media_buy.

Same wire-shape deltas as create_media_buy for the package shape (creative_idscreative_assignments), but no brand_manifest translation — updates don't carry brand info.

Response shape matches create_media_buy: package creative_assignments collapse back to creative_ids for the v2.5 buyer.

Direct port (inverted) of src/lib/adapters/legacy/v2-5/update_media_buy.ts + src/lib/utils/creative-adapter.ts.

Functions

def adapt_request(payload: dict[str, Any]) ‑> dict[str, typing.Any]
Expand source code
def adapt_request(payload: dict[str, Any]) -> dict[str, Any]:
    """Translate a v2.5 ``update_media_buy`` request to v3 shape."""
    out = dict(payload)

    packages = out.get("packages")
    if isinstance(packages, list):
        out["packages"] = [adapt_package_request(p) if isinstance(p, dict) else p for p in packages]

    return out

Translate a v2.5 update_media_buy request to v3 shape.

def is_legacy_shape(payload: dict[str, Any]) ‑> bool
Expand source code
def is_legacy_shape(payload: dict[str, Any]) -> bool:
    """v2.5 ``update_media_buy``: any package with ``creative_ids:
    list[str]`` is the marker (no ``brand_manifest`` on updates)."""
    packages = payload.get("packages")
    if not isinstance(packages, list):
        return False
    for pkg in packages:
        if isinstance(pkg, dict) and isinstance(pkg.get("creative_ids"), list):
            return True
    return False

v2.5 update_media_buy: any package with creative_ids: list[str]<code> is the marker (no </code>brand_manifest on updates).