product_image
konigle.models.commerce.product_image
¶
Product image models for the Konigle SDK.
This module provides Pydantic models for product image resources including creation, update, and response models with file upload validation.
ProductImage
¶
Bases: ProductImageBase, TimestampedResource, IDMixin, BaseResource
Complete product image resource model.
Represents a product image from the API with all fields including computed values, file metadata, and Active Record capabilities.
height = Field(None, ge=1, title='Height', description='Image height in pixels.')
class-attribute
instance-attribute
¶
Image height in pixels.
position = Field(..., ge=1, title='Position', description='Display position of the image.')
class-attribute
instance-attribute
¶
Display position of the image.
url = Field(default=None, title='URL', description='The URL of the image.')
class-attribute
instance-attribute
¶
URL of the image after upload.
width = Field(None, ge=1, title='Width', description='Image width in pixels.')
class-attribute
instance-attribute
¶
Image width in pixels.
ProductImageBase
¶
Bases: BaseModel
Base product image model with truly shared fields.
Contains only fields that have the same optionality and validation requirements in both creation and response contexts.
alt = Field(default='', title='Alt Text', description='Alternative text for accessibility.')
class-attribute
instance-attribute
¶
Alternative text for accessibility.
product = Field(..., title='Product ID', description='ID of the parent product.')
class-attribute
instance-attribute
¶
ID of the parent product.
variant_ids = Field(default_factory=list, title='Variant IDs', description='List of variant IDs this image is associated with.')
class-attribute
instance-attribute
¶
List of variant IDs this image is associated with.
ProductImageCreate
¶
Bases: ProductImageBase, CreateModel
Model for creating a new product image.
Requires either a file upload or a source URL. Must specify the parent product ID.
file = Field(..., title='Image File', description='Image file to upload.')
class-attribute
instance-attribute
¶
Image file to upload.
position = Field(default=1, ge=1, title='Position', description='Display position of the image.')
class-attribute
instance-attribute
¶
Display position of the image.
src = Field(default=None, title='Source URL', description='If the image is copied from URL, specify it here.')
class-attribute
instance-attribute
¶
If the image is copied from URL, specify it here.
normalize_file()
¶
Convert file paths or bytes to FileInput.
validate_image_file(v)
classmethod
¶
Ensure we're uploading an image file.
ProductImageReference
¶
ProductImageUpdate
¶
Bases: UpdateModel
Model for updating an existing product image.
All fields are optional for partial updates. Supports updating position, alt text, variant associations, and the image file.
alt = Field(default=None, title='Alt Text', description='Alternative text for accessibility.')
class-attribute
instance-attribute
¶
Alternative text for accessibility.
position = Field(default=None, ge=1, title='Position', description='Display position of the image.')
class-attribute
instance-attribute
¶
Display position of the image.
variant_ids = Field(default=None, title='Variant IDs', description='List of variant IDs this image is associated with.')
class-attribute
instance-attribute
¶
List of variant IDs this image is associated with.