Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 45 additions & 5 deletions src/ucp_sdk/models/schemas/common/types/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,72 @@

from pydantic import AnyUrl, BaseModel, ConfigDict, Field

from . import media_source


class Preview(BaseModel):
"""
Poster/thumbnail still the Platform renders before or instead of the primary resource. A Business SHOULD provide it for `video`, `external_video`, and `model_3d` unless no suitable still exists, and MAY provide it for `image` as a low-resolution placeholder.
"""

model_config = ConfigDict(
extra="allow",
)
url: AnyUrl
"""
URL of the preview image.
"""
width: int | None = Field(None, ge=1)
"""
Pixel width of the preview image.
"""
height: int | None = Field(None, ge=1)
"""
Pixel height of the preview image.
"""


class Media(BaseModel):
"""
Media item (image, video, etc.).
One logical media item — such as an image, a video, or a 3D model. `url` identifies the resource the Platform renders; `sources` lists alternate renditions; `preview` is a still.
"""

model_config = ConfigDict(
extra="allow",
)
type: str
"""
Media type. Well-known values: `image`, `video`, `model_3d`.
Media type. Well-known values: `image`, `video`, `external_video`, `model_3d`. A Platform MUST NOT reject the containing object for an unrecognized value; it MAY present the item from `preview` and `name`, or omit it.
"""
url: AnyUrl
"""
URL to the media resource.
URL of the media resource the Platform renders; interpretation is specialized per `type`.
"""
name: str | None = None
"""
Human-readable title or label for the media, distinct from `alt_text` (accessibility text). Often present for `video` and `model_3d`.
"""
alt_text: str | None = None
"""
Accessibility text describing the media.
"""
width: int | None = Field(None, ge=1)
"""
Width in pixels (for images/video).
Intrinsic pixel width of the media item, for image and video types; a rendition's own dimensions are on its `sources` entry.
"""
height: int | None = Field(None, ge=1)
"""
Height in pixels (for images/video).
Intrinsic pixel height of the media item, for image and video types; a rendition's own dimensions are on its `sources` entry.
"""
duration: int | None = Field(None, ge=1)
"""
Duration in seconds, for time-based media such as `video` and `external_video`.
"""
preview: Preview | None = None
"""
Poster/thumbnail still the Platform renders before or instead of the primary resource. A Business SHOULD provide it for `video`, `external_video`, and `model_3d` unless no suitable still exists, and MAY provide it for `image` as a low-resolution placeholder.
"""
sources: list[media_source.MediaSource] | None = None
"""
Alternate renditions of the resource at `url`. The Business SHOULD include the rendition at `url`.
"""
41 changes: 41 additions & 0 deletions src/ucp_sdk/models/schemas/common/types/media_external_video.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2026 UCP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# generated by datamodel-codegen
# pylint: disable=all
# pyformat: disable

from __future__ import annotations

from typing import Any

from pydantic import BaseModel, ConfigDict


class MediaExternalVideo(BaseModel):
"""
Type-specific properties for a video presented through a third-party player.
"""

model_config = ConfigDict(
extra="allow",
)
url: Any | None = None
"""
The third-party player the Platform embeds. A video the Business serves as files from any origin, including a CDN, is `video`, not `external_video`.
"""
sources: Any | None = None
"""
Not used: a video presented through a player has no renditions.
"""
41 changes: 41 additions & 0 deletions src/ucp_sdk/models/schemas/common/types/media_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2026 UCP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# generated by datamodel-codegen
# pylint: disable=all
# pyformat: disable

from __future__ import annotations

from typing import Any

from pydantic import BaseModel, ConfigDict


class MediaImage(BaseModel):
"""
Type-specific properties for image media.
"""

model_config = ConfigDict(
extra="allow",
)
url: Any | None = None
"""
A directly displayable image.
"""
sources: Any | None = None
"""
Alternate encodings and sizes of the image (e.g. `image/avif`, `image/webp`, `image/jpeg`; width variants for responsive layout). `url` SHOULD be the most broadly decodable rendition.
"""
49 changes: 49 additions & 0 deletions src/ucp_sdk/models/schemas/common/types/media_model_3d.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2026 UCP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# generated by datamodel-codegen
# pylint: disable=all
# pyformat: disable

from __future__ import annotations

from typing import Any

from pydantic import BaseModel, ConfigDict


class MediaModel3D(BaseModel):
"""
Type-specific properties for 3D model media.
"""

model_config = ConfigDict(
extra="allow",
)
url: Any | None = None
"""
The primary model file (e.g. GLB).
"""
width: Any | None = None
"""
Not applicable: a 3D model has no pixel dimensions.
"""
height: Any | None = None
"""
Not applicable: a 3D model has no pixel dimensions.
"""
sources: Any | None = None
"""
Alternate file formats of the model (glTF/GLB/USDZ).
"""
55 changes: 55 additions & 0 deletions src/ucp_sdk/models/schemas/common/types/media_source.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright 2026 UCP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# generated by datamodel-codegen
# pylint: disable=all
# pyformat: disable

from __future__ import annotations

from pydantic import AnyUrl, BaseModel, ConfigDict, Field


class MediaSource(BaseModel):
"""
One encoded rendition of the parent media item: a format or resolution of an image or video, a streaming manifest, or a file format of a 3D model. The Platform selects a source by `mime_type` and dimensions.
"""

model_config = ConfigDict(
extra="allow",
)
url: AnyUrl
"""
URL to this rendition's file or streaming manifest.
"""
mime_type: str | None = None
"""
IANA media type of this source. A Platform MUST NOT reject the parent media item solely because this value is unknown, but MAY skip a source it cannot decode. Examples: `image/avif`, `image/webp`, `image/jpeg`, `video/mp4`, `video/webm`, `application/vnd.apple.mpegurl` (HLS), `application/dash+xml` (DASH), `model/gltf-binary` (GLB), `model/gltf+json` (glTF), `model/vnd.usdz+zip` (USDZ).
"""
format: str | None = None
"""
Short format token for display/selection. A Platform MUST NOT reject the parent media item solely because this value is unknown, but MAY skip a source it cannot decode. Examples: `avif`, `webp`, `jpg`, `mp4`, `webm`, `m3u8`, `mpd`, `glb`, `gltf`, `usdz`.
"""
width: int | None = Field(None, ge=1)
"""
Pixel width of this rendition. Omitted for adaptive manifests and 3D models.
"""
height: int | None = Field(None, ge=1)
"""
Pixel height of this rendition. Omitted for adaptive manifests and 3D models.
"""
filesize: int | None = Field(None, ge=1)
"""
File size in bytes. Lets the Platform decide whether to prefetch a large asset (e.g. a multi-megabyte 3D model). Omitted for adaptive-streaming manifests, whose total size is not fixed.
"""
49 changes: 49 additions & 0 deletions src/ucp_sdk/models/schemas/common/types/media_video.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2026 UCP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# generated by datamodel-codegen
# pylint: disable=all
# pyformat: disable

from __future__ import annotations

from typing import Any

from pydantic import BaseModel, ConfigDict


class MediaVideo(BaseModel):
"""
Type-specific properties for video media.
"""

model_config = ConfigDict(
extra="allow",
)
url: Any | None = None
"""
A playable rendition of the video: a progressive file or an adaptive-streaming manifest.
"""
width: Any | None = None
"""
Intrinsic pixel width of the video; a rendition's own dimensions are on its `sources` entry.
"""
height: Any | None = None
"""
Intrinsic pixel height of the video; a rendition's own dimensions are on its `sources` entry.
"""
sources: Any | None = None
"""
Alternate renditions (MP4/WebM) and adaptive manifests (HLS/DASH).
"""
Loading