katana_public_api_client.domain.variant¶
katana_public_api_client.domain.variant
¶
Domain model for Variant entities.
This module provides a Pydantic model representing a Variant (product or material SKU) optimized for ETL, data processing, and business logic.
The domain model uses composition with the auto-generated Pydantic model from OpenAPI,
leveraging its from_attrs() conversion while adding business-specific methods.
Classes¶
KatanaVariant
¶
Bases: KatanaBaseModel
Domain model for a Product or Material Variant.
A Variant represents a specific SKU with unique pricing, configuration, and inventory tracking. This is a Pydantic model optimized for: - ETL and data processing - Business logic - Data validation - JSON schema generation
This model uses composition with the auto-generated Pydantic model, exposing a curated subset of fields with business methods.
Example
Functions¶
from_attrs(attrs_variant, product_or_material_name=None)
classmethod
¶
Create a KatanaVariant from an attrs Variant model (API response).
This method leverages the generated Pydantic model's from_attrs() method
to handle UNSET sentinel conversion, then creates the domain model.
Parameters:
-
attrs_variant(Variant) –The attrs Variant model from API response.
-
product_or_material_name(str | None, default:None) –Optional name of parent product/material (must be provided separately as it comes from extend query).
Returns:
-
KatanaVariant–A new KatanaVariant instance with business methods.
Example
Source code in katana_public_api_client/domain/variant.py
from_generated(generated, product_or_material_name=None)
classmethod
¶
Create a KatanaVariant from a generated Pydantic Variant model.
This method extracts the curated subset of fields from the generated model and converts nested objects (config_attributes, custom_fields) to simple dicts.
Parameters:
-
generated(Variant) –The auto-generated Pydantic Variant model.
-
product_or_material_name(str | None, default:None) –Optional name of parent product/material (must be provided separately as it comes from extend query).
Returns:
-
KatanaVariant–A new KatanaVariant instance with business methods.
Example
Source code in katana_public_api_client/domain/variant.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
get_config_value(config_name)
¶
Get value of a configuration attribute by name.
Parameters:
-
config_name(str) –Name of the configuration attribute
Returns:
-
str | None–Config value or None if not found
Example
Source code in katana_public_api_client/domain/variant.py
get_custom_field(field_name)
¶
Get value of a custom field by name.
Parameters:
-
field_name(str) –Name of the custom field
Returns:
-
str | None–Field value or None if not found
Example
Source code in katana_public_api_client/domain/variant.py
get_display_name()
¶
Get formatted display name matching Katana UI format.
Format: "{Product/Material Name} / {Config Value 1} / {Config Value 2} / ..."
Returns:
-
str–Formatted variant name, or SKU if no name available
Example
Source code in katana_public_api_client/domain/variant.py
matches_search(query)
¶
Check if variant matches search query.
Searches across: - SKU - Product/material name - Supplier item codes - Config attribute values
Parameters:
-
query(str) –Search query string (case-insensitive)
Returns:
-
bool–True if variant matches query
Example
Source code in katana_public_api_client/domain/variant.py
to_csv_row()
¶
Export as CSV-friendly row.
Returns: