from pydantic import BaseModel
from typing import List, Optional
from datetime import datetime
from .models import UserRole, JobStatus

class UserBase(BaseModel):
    username: str

class UserCreate(UserBase):
    password: str
    role: UserRole = UserRole.user

class User(UserBase):
    id: int
    role: UserRole
    created_at: datetime
    class Config:
        orm_mode = True

class JobBase(BaseModel):
    branch_name: str
    scenarios: List[str]
    environment: str
    test_mode: str

class JobCreate(JobBase):
    pass

class Job(JobBase):
    id: int
    user_id: int
    status: JobStatus
    result_path: Optional[str]
    duration: Optional[str]
    created_at: datetime
    updated_at: datetime
    class Config:
        orm_mode = True

class Token(BaseModel):
    access_token: str
    token_type: str

class TokenData(BaseModel):
    username: Optional[str] = None
