Skip to content

media_asset

konigle.models.core.media_asset

Media asset models for the Konigle SDK.

This module defines models for Image, Video, and Document assets. All three types map to the same backend StorefrontAsset table but are differentiated by mime_type for user-friendly separate interfaces.

AssetType

Bases: str, Enum

Asset type enumeration.

BaseAsset

Bases: TimestampedResource

Base class for all media assets with common fields.

alt_text = Field(default='', title='Alt Text', description='Alt text for accessibility') class-attribute instance-attribute

Alt text for accessibility

asset_url = Field(None, title='Asset URL', description='URL to access the asset') class-attribute instance-attribute

URL to access the asset

description = Field(default=None, title='Description', description='Optional description of the asset') class-attribute instance-attribute

Optional description of the asset

meta = Field(default=None, title='Meta', description='Optional metadata dictionary') class-attribute instance-attribute

Optional metadata dictionary

mime_type = Field(..., max_length=100, title='MIME Type', description='MIME type of the file') class-attribute instance-attribute

MIME type of the file

name = Field(..., max_length=255, title='Name', description='User-friendly name for searching') class-attribute instance-attribute

User-friendly name for searching

size = Field(default=0, ge=0, title='Size', description='Total size in bytes') class-attribute instance-attribute

Total size in bytes

tags = Field(default_factory=list, title='Tags', description='Tags for categorization') class-attribute instance-attribute

Tags for categorization

BaseAssetCreate

Bases: CreateModel

Base create model for assets.

alt_text = Field(default='', title='Alt Text', description='Alt text for accessibility') class-attribute instance-attribute

Alt text for accessibility

description = Field(default=None, title='Description', description='Optional description of the asset') class-attribute instance-attribute

Optional description of the asset

meta = Field(default=None, title='Meta', description='Optional metadata dictionary') class-attribute instance-attribute

Optional metadata dictionary

name = Field(..., max_length=255, title='Name', description='User-friendly name') class-attribute instance-attribute

User-friendly name

source_url = Field(default=None, title='Source URL', description='URL from which this asset is sourced') class-attribute instance-attribute

URL from which this asset is sourced. Helps to avoid duplicates.

tags = Field(default='', title='Tags', description='Tags for categorization. Comma-separated string.') class-attribute instance-attribute

Tags for categorization. Comma-separated string.

BaseAssetUpdate

Bases: UpdateModel

Base update model for assets - only mutable fields.

alt_text = Field(None, title='Alt Text', description='Alt text for accessibility') class-attribute instance-attribute

Alt text for accessibility

description = Field(default=None, title='Description', description='Optional description of the asset') class-attribute instance-attribute

Optional description of the asset

meta = Field(default=None, title='Meta', description='Optional metadata dictionary') class-attribute instance-attribute

Optional metadata dictionary

name = Field(None, max_length=255, title='Name', description='User-friendly name') class-attribute instance-attribute

User-friendly name

tags = Field(None, title='Tags', description='Tags for categorization') class-attribute instance-attribute

Tags for categorization

Document

Bases: BaseAsset

Document asset model.

DocumentCreate

Bases: BaseAssetCreate

Create model for document assets.

file = Field(..., title='File', description='Document file to upload. Can be file path, bytes, BytesIO, BinaryIO, or tuple of (file_data, filename)') class-attribute instance-attribute

Document file to upload. Can be file path, bytes, BytesIO, BinaryIO, or tuple of (file_data, filename)

normalize_file()

Convert file paths or bytes to FileInput.

validate_document_file(v) classmethod

Ensure we're uploading a supported document file.

DocumentUpdate

Bases: BaseAssetUpdate

Update model for document assets - file cannot be updated.

Image

Bases: BaseAsset

Image asset model.

image_height = Field(None, ge=0, title='Image Height', description='Image height in pixels') class-attribute instance-attribute

Image height in pixels

image_width = Field(None, ge=0, title='Image Width', description='Image width in pixels') class-attribute instance-attribute

Image width in pixels

ImageCreate

Bases: BaseAssetCreate

Create model for image assets.

image = Field(..., title='Image', description='Image file to upload. Can be file path, bytes, BytesIO, BinaryIO, or tuple of (file_data, filename)') class-attribute instance-attribute

Image file to upload. Can be file path, bytes, BytesIO, BinaryIO, or tuple of (file_data, filename)

normalize_file()

Convert file paths or bytes to FileInput.

validate_image_file(v) classmethod

Ensure we're uploading an image file.

ImageGenerate

Bases: CreateModel

Model for generating images from text prompts.

aspect_ratio = Field(default='1:1', title='Aspect Ratio', description='Aspect ratio of the generated image') class-attribute instance-attribute

Aspect ratio of the generated image

output_format = Field(default='webp', title='Output Format', description='Output format of the generated image') class-attribute instance-attribute

Output format of the generated image

prompt = Field(..., title='Prompt', description='Text prompt to generate the image') class-attribute instance-attribute

Text prompt to generate the image

ImageUpdate

Bases: BaseAssetUpdate

Update model for image assets - file cannot be updated.

Video

Bases: BaseAsset

Video asset model.

VideoCreate

Bases: BaseAssetCreate

Create model for video assets.

file = Field(..., title='File', description='Video file to upload. Can be file path, bytes, BytesIO, BinaryIO, or tuple of (file_data, filename)') class-attribute instance-attribute

Video file to upload. Can be file path, bytes, BytesIO, BinaryIO, or tuple of (file_data, filename)

normalize_file()

Convert file paths or bytes to FileInput.

validate_video_file(v) classmethod

Ensure we're uploading a video file.

VideoUpdate

Bases: BaseAssetUpdate

Update model for video assets - file cannot be updated.