# generated by fastapi-codegen:
#   filename:  ./api-wrapper/openapi.yaml
#   timestamp: 2025-01-08T11:10:30+00:00

from __future__ import annotations

from datetime import datetime
from enum import Enum
from typing import Any, Dict, List, Optional, Union
from uuid import UUID

from pydantic import BaseModel, Extra, Field, PositiveFloat, PositiveInt, conint, constr

class CompilerStatus(Enum):
    running = 'running'
    offline = 'offline'
    maintenance = 'maintenance'


class CompilerTable(BaseModel):
    name: str = Field(..., title='Name')
    manufacturer: Optional[str] = Field(..., title='Manufacturer')
    status: CompilerStatus
    description: Optional[constr(min_length=0, max_length=512)] = Field(
        ..., title='Description'
    )
    time_limit: PositiveFloat = Field(..., title='Time Limit')
    passes_available: Optional[Dict[str, bool]] = Field(None, title='Passes Available')
    compiler_id: int = Field(..., title='Compiler Id')
#    compiler_alias: str = Field(..., title='Compiler Alias')

class CompilerTaskBase(BaseModel):
    compiler_id: Optional[int] = Field(..., title='Compiler Id')
    compilation_pass: str
    options: Optional[Dict[str, Any]] = Field(None, title='Options')


class CompilerTaskResult(BaseModel):
    meta_data: Any = Field(..., title='Meta Data')
    status: str = Field(..., title='Status')
    status_message: Optional[str] = Field(..., title='Status Message')
    start_date_time: Optional[str] = Field(..., title='Start Date Time')
    end_date_time: Optional[str] = Field(..., title='End Date Time')
    total_runtime: Optional[float] = Field(..., title='Total Runtime')
    compiled_circuit: Optional[Union[str,List[str]]] = Field(..., title='Compiled Circuit')


class Primitive(Enum):
    sampling = 'sampling'
    quantum_state = 'quantum_state'


class QPUOptions(BaseModel):
    class Config:
        extra = Extra.forbid

    coupling_map: Optional[List[List[conint(ge=0)]]] = Field(None, title='Coupling Map')
    basis_gates: Optional[List[str]] = Field(None, title='Basis Gates')


class QPUStatus(Enum):
    idle = 'idle'
    running = 'running'
    offline = 'offline'
    maintenance = 'maintenance'


class QPUTaskBase(BaseModel):
    total_shots: Optional[conint(ge=1, le=1000000)] = Field(1, title='Total Shots')
    qpu_id: int = Field(..., title='Qpu Id')
    primitive: Optional[Primitive] = 'sampling'
    qpu_options: Optional[QPUOptions]
    class Config:  
        use_enum_values = True


class QPUTaskResult(BaseModel):
    meta_data: Any = Field(..., title='Meta Data')
    status: str = Field(..., title='Status')
    status_message: Optional[str] = Field(..., title='Status Message')
    start_date_time: Optional[str] = Field(..., title='Start Date Time')
    end_date_time: Optional[str] = Field(..., title='End Date Time')
    total_runtime: Optional[float] = Field(..., title='Total Runtime')
    data: Optional[str] = Field(..., title='Data')


class Technology(Enum):
    statevector_simulator = 'statevector_simulator'
    trapped_ions = 'trapped_ions'
    neutral_atoms = 'neutral_atoms'
    vacancy_centers = 'vacancy_centers'


class ValidationError(BaseModel):
    loc: List[Union[str, int]] = Field(..., title='Location')
    msg: str = Field(..., title='Message')
    type: str = Field(..., title='Error Type')


class HTTPValidationError(BaseModel):
    detail: Optional[List[ValidationError]] = Field(None, title='Detail')


class JobInfo(BaseModel):
    circuit: str = Field(..., title='Circuit')
    primitive: Optional[Primitive] = 'sampling'
    name: constr(min_length=1, max_length=64) = Field(..., title='Name')
    comment: Optional[constr(min_length=0, max_length=512)] = Field(
        ..., title='Comment'
    )
    job_id: UUID = Field(..., title='Job Id')
    submission_date_time: datetime = Field(..., title='Submission Date Time')
    status: str = Field(..., title='Status')
    status_message: Optional[str] = Field(..., title='Status Message')
    qpu_name: str = Field(..., title='Qpu Name')
    last_compiler_task: Optional[CompilerTaskBase]
    last_qpu_task: Optional[QPUTaskBase]


class JobResult(BaseModel):
    status: str = Field(..., title='Status')
    status_message: Optional[str] = Field(..., title='Status Message')
    start_date_time: Optional[str] = Field(..., title='Start Date Time')
    end_date_time: Optional[str] = Field(..., title='End Date Time')
    total_runtime: Optional[float] = Field(..., title='Total Runtime')
    last_compiler_result: Optional[CompilerTaskResult]
    last_qpu_result: Optional[QPUTaskResult]


class JobSubmission(BaseModel):
    circuit: str = Field(..., title='Circuit')
    primitive: Optional[Primitive] = 'sampling'
    name: constr(min_length=1, max_length=64) = Field(..., title='Name')
    comment: Optional[constr(min_length=0, max_length=512)] = Field(
        ..., title='Comment'
    )
    tasks: List[Union[CompilerTaskBase, QPUTaskBase]] = Field(..., title='Tasks')
    class Config:  
        use_enum_values = True


class QPUTable(BaseModel):
    manufacturer: str = Field(..., title='Manufacturer')
    name: str = Field(..., title='Name')
    technology: Technology
    status: QPUStatus
    number_of_qubits_available: PositiveInt = Field(
        ..., title='Number Of Qubits Available'
    )
    circuit_depth_limit: conint(ge=0) = Field(..., title='Circuit Depth Limit')
    shot_limit: PositiveInt = Field(..., title='Shot Limit')
    description: Optional[constr(min_length=0, max_length=512)] = Field(
        ..., title='Description'
    )
    time_limit: PositiveFloat = Field(..., title='Time Limit')
    measurement_required: Optional[bool] = Field(..., title='Measurement Required')
    qpu_id: int = Field(..., title='Qpu Id')
    qpu_alias: str = Field(..., title='Qpu Alias')
