75 lines
3 KiB
Python
75 lines
3 KiB
Python
"""Attribute models"""
|
|
|
|
from typing import Any, Dict, List, Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class SimpleAttributeResponse(BaseModel):
|
|
"""Simplified attribute definition"""
|
|
|
|
id: int = Field(..., description="The ID of the attribute")
|
|
name: str = Field(..., description="The independent name of the attribute")
|
|
description: Optional[str] = Field(None, description="The description of the attribute")
|
|
attributeType: Optional[str] = Field(
|
|
None, description="The type of attribute (normal, meta, internal)"
|
|
)
|
|
type: Optional[str] = Field(None, description="The type of the attribute")
|
|
autoSync: Optional[str] = Field(None, description="The auto sync mode of the attribute")
|
|
translations: Optional[Dict[str, str]] = Field(
|
|
None, description="Translations of the attribute name"
|
|
)
|
|
|
|
|
|
class AttributeGetByNameResponse(SimpleAttributeResponse):
|
|
"""Attribute response when fetching by name"""
|
|
|
|
languageDependents: Optional[Dict[str, Any]] = Field(
|
|
None, description="Language-dependent properties"
|
|
)
|
|
|
|
|
|
class SingleNewAttributeRequestBody(BaseModel):
|
|
"""Request body for creating a new attribute"""
|
|
|
|
name: str = Field(..., description="The independent name of the attribute")
|
|
type: str = Field(..., description="The type of the attribute")
|
|
description: Optional[str] = Field(None, description="The description of the attribute")
|
|
translations: Optional[Dict[str, str]] = Field(
|
|
None, description="Translations of the attribute name"
|
|
)
|
|
|
|
|
|
class SingleUpdateAttributeRequestBody(BaseModel):
|
|
"""Request body for updating an attribute"""
|
|
|
|
id: int = Field(..., description="The ID of the attribute")
|
|
name: Optional[str] = Field(None, description="The independent name of the attribute")
|
|
description: Optional[str] = Field(None, description="The description of the attribute")
|
|
translations: Optional[Dict[str, str]] = Field(
|
|
None, description="Translations of the attribute name"
|
|
)
|
|
|
|
|
|
class AttributeListResponse(BaseModel):
|
|
"""Paginated response containing multiple attributes"""
|
|
|
|
items: List[SimpleAttributeResponse] = Field(..., description="List of attributes")
|
|
total: int = Field(..., description="The total number of attributes")
|
|
page: int = Field(..., description="The current page number")
|
|
limit: int = Field(..., description="The number of attributes per page")
|
|
links: Optional[Dict[str, Optional[str]]] = Field(None, description="Pagination links")
|
|
|
|
|
|
class AttributeBulkCreateResponse(BaseModel):
|
|
"""Response from bulk attribute creation"""
|
|
|
|
items: List[SimpleAttributeResponse] = Field(..., description="The created attributes")
|
|
totalItemsCreated: int = Field(..., description="The total number of attributes created")
|
|
|
|
|
|
class AttributeBulkUpdateResponse(BaseModel):
|
|
"""Response from bulk attribute update"""
|
|
|
|
items: List[SimpleAttributeResponse] = Field(..., description="The updated attributes")
|
|
totalItemsUpdated: int = Field(..., description="The total number of attributes updated")
|