Assets
    
              Bases: Media, Generic[_ParamsType, _InfoType]
Represents an assets with various properties.
class-attribute
      instance-attribute
  
    Information associated with the asset type.
classmethod
  
    
classmethod
  
    
classmethod
  
    Validates the parameters for the assets.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
|                    | Any | The parameters to validate. | required | 
Returns:
| Type | Description | 
|---|---|
| _ParamsType | The validated parameters. | 
Source code in src/mosaico/assets/base.py
              
    Returns a new assets with the specified parameters.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
|                    | _ParamsType | dict[str, Any] | The parameters to update. | required | 
Returns:
| Type | Description | 
|---|---|
| Self | A new assets with the specified parameters. | 
Source code in src/mosaico/assets/base.py
              
module-attribute
  
AssetType = Literal[
    "video", "image", "audio", "text", "subtitle"
]
An enumeration of the different types of assets that can be held in an assets.
module-attribute
  
Asset = AudioAsset | ImageAsset | TextAsset | SubtitleAsset
Represents an assets with various properties.
module-attribute
  
AssetParams = (
    AudioAssetParams | ImageAssetParams | TextAssetParams
)
Represents the parameters of an assets.
          create_asset(
    asset_type: Literal["image"],
    id: str | None = ...,
    data: str | bytes | None = ...,
    path: FilePath | None = ...,
    metadata: dict[str, Any] | None = ...,
    params: ImageAssetParams | None = ...,
    **kwargs: Any
) -> ImageAsset
create_asset(
    asset_type: Literal["audio"],
    id: str | None = ...,
    data: str | bytes | None = ...,
    path: FilePath | None = ...,
    metadata: dict[str, Any] | None = ...,
    params: AudioAssetParams | None = ...,
    **kwargs: Any
) -> AudioAsset
create_asset(
    asset_type: Literal["text"],
    id: str | None = ...,
    data: str | bytes | None = ...,
    path: FilePath | None = ...,
    metadata: dict[str, Any] | None = ...,
    params: TextAssetParams | None = ...,
    **kwargs: Any
) -> TextAsset
create_asset(
    asset_type: Literal["subtitle"],
    id: str | None = ...,
    data: str | bytes | None = ...,
    path: FilePath | None = ...,
    metadata: dict[str, Any] | None = ...,
    params: TextAssetParams | None = ...,
    **kwargs: Any
) -> SubtitleAsset
create_asset(
    asset_type: AssetType,
    id: str | None = None,
    data: str | bytes | None = None,
    path: FilePath | None = None,
    metadata: dict[str, Any] | None = None,
    params: AssetParams | dict[str, Any] | None = None,
    **kwargs: Any
) -> Asset
Create an asset from the given asset type.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
|                    | AssetType | The asset type. | required | 
|                    | str | None | The asset ID. | None | 
|                    | str | bytes | None | The asset data. | None | 
|                    | FilePath | None | The asset path. | None | 
|                    | dict[str, Any] | None | The asset metadata. ;param params: The asset parameters. | None | 
|                    | Any | Additional keyword arguments. | {} | 
Returns:
| Type | Description | 
|---|---|
| Asset | The asset. | 
Source code in src/mosaico/assets/factory.py
              
          get_asset_params_class(
    asset_type: Literal["image"],
) -> type[ImageAssetParams]
get_asset_params_class(
    asset_type: Literal["audio"],
) -> type[AudioAssetParams]
get_asset_params_class(
    asset_type: Literal["text"],
) -> type[TextAssetParams]
get_asset_params_class(
    asset_type: Literal["subtitle"],
) -> type[TextAssetParams]
get_asset_params_class(
    asset_type: AssetType,
) -> type[AssetParams]
get_asset_params_class(
    asset_type: AssetType,
) -> type[AssetParams]
Get the asset parameters class for the given asset type.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
|                    | AssetType | The asset type. | required | 
Returns:
| Type | Description | 
|---|---|
| type[AssetParams] | The asset parameters class. | 
Source code in src/mosaico/assets/factory.py
              
    Convert a media object to an asset.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
|                    | Media | The media object to convert. | required | 
Returns:
| Type | Description | 
|---|---|
| Asset | The asset object. | 
Raises:
| Type | Description | 
|---|---|
| ValueError | If the media object does not have a MIME type or the MIME type is unsupported. | 
Source code in src/mosaico/assets/utils.py
              
    Guess the asset type from a MIME type.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
|                    | str | The MIME type to guess the asset type from. | required | 
Returns:
| Type | Description | 
|---|---|
| AssetType | The asset type. | 
Source code in src/mosaico/assets/utils.py
              
    Check if the user provided all required keys.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
|                    | dict | The data to check. | required | 
|                    | Sequence[str] | The required keys. | required | 
Returns:
| Type | Description | 
|---|---|
| bool | Whether the user provided all required keys. |