29d9b95885
Profiles monitor running processes and foreground windows to automatically start/stop targets when conditions are met. Includes profile engine, platform detector (WMI), REST API, process browser endpoint, and calibration persistence fix. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
59 lines
2.8 KiB
Python
59 lines
2.8 KiB
Python
"""Profile-related schemas."""
|
|
|
|
from datetime import datetime
|
|
from typing import List, Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class ConditionSchema(BaseModel):
|
|
"""A single condition within a profile."""
|
|
|
|
condition_type: str = Field(description="Condition type discriminator (e.g. 'application')")
|
|
apps: Optional[List[str]] = Field(None, description="Process names (for application condition)")
|
|
match_type: Optional[str] = Field(None, description="'running' or 'topmost' (for application condition)")
|
|
|
|
|
|
class ProfileCreate(BaseModel):
|
|
"""Request to create a profile."""
|
|
|
|
name: str = Field(description="Profile name", min_length=1, max_length=100)
|
|
enabled: bool = Field(default=True, description="Whether the profile is enabled")
|
|
condition_logic: str = Field(default="or", description="How conditions combine: 'or' or 'and'")
|
|
conditions: List[ConditionSchema] = Field(default_factory=list, description="List of conditions")
|
|
target_ids: List[str] = Field(default_factory=list, description="Target IDs to activate")
|
|
|
|
|
|
class ProfileUpdate(BaseModel):
|
|
"""Request to update a profile."""
|
|
|
|
name: Optional[str] = Field(None, description="Profile name", min_length=1, max_length=100)
|
|
enabled: Optional[bool] = Field(None, description="Whether the profile is enabled")
|
|
condition_logic: Optional[str] = Field(None, description="How conditions combine: 'or' or 'and'")
|
|
conditions: Optional[List[ConditionSchema]] = Field(None, description="List of conditions")
|
|
target_ids: Optional[List[str]] = Field(None, description="Target IDs to activate")
|
|
|
|
|
|
class ProfileResponse(BaseModel):
|
|
"""Profile information response."""
|
|
|
|
id: str = Field(description="Profile ID")
|
|
name: str = Field(description="Profile name")
|
|
enabled: bool = Field(description="Whether the profile is enabled")
|
|
condition_logic: str = Field(description="Condition combination logic")
|
|
conditions: List[ConditionSchema] = Field(description="List of conditions")
|
|
target_ids: List[str] = Field(description="Target IDs to activate")
|
|
is_active: bool = Field(default=False, description="Whether the profile is currently active")
|
|
active_target_ids: List[str] = Field(default_factory=list, description="Targets currently owned by this profile")
|
|
last_activated_at: Optional[datetime] = Field(None, description="Last time this profile was activated")
|
|
last_deactivated_at: Optional[datetime] = Field(None, description="Last time this profile was deactivated")
|
|
created_at: datetime = Field(description="Creation timestamp")
|
|
updated_at: datetime = Field(description="Last update timestamp")
|
|
|
|
|
|
class ProfileListResponse(BaseModel):
|
|
"""List of profiles response."""
|
|
|
|
profiles: List[ProfileResponse] = Field(description="List of profiles")
|
|
count: int = Field(description="Number of profiles")
|