"""
Generated by qenerate plugin=pydantic_v2. DO NOT MODIFY MANUALLY!
"""

from collections.abc import Callable  # noqa: F401 # pylint: disable=W0611
from datetime import datetime  # noqa: F401 # pylint: disable=W0611
from enum import Enum  # noqa: F401 # pylint: disable=W0611
from typing import (  # noqa: F401 # pylint: disable=W0611
    Any,
    Optional,
    Union,
)

from pydantic import (  # noqa: F401 # pylint: disable=W0611
    BaseModel,
    Extra,
    Field,
    Json,
)

DEFINITION = """
query CourseIndex {
    allCourses {
        _id
        name
        courseNickname
        settings {
            # This value isn't actually used, but something needs to be included to determine if the settings object is null
            restrictStudentPastView
        }
        term {
            id
            startAt
            endAt
            name
        }
    }
}
"""


class ConfiguredBaseModel(BaseModel):
    class Config:
        extra = "forbid"


class CourseSettings(ConfiguredBaseModel):
    restrict_student_past_view: Optional[bool] = Field(
        ..., alias="restrictStudentPastView"
    )


class Term(ConfiguredBaseModel):
    q_id: str = Field(..., alias="id")
    start_at: Optional[datetime] = Field(..., alias="startAt")
    end_at: Optional[datetime] = Field(..., alias="endAt")
    name: Optional[str] = Field(..., alias="name")


class Course(ConfiguredBaseModel):
    q_id: str = Field(..., alias="_id")
    name: str = Field(..., alias="name")
    course_nickname: Optional[str] = Field(..., alias="courseNickname")
    settings: Optional[CourseSettings] = Field(..., alias="settings")
    term: Optional[Term] = Field(..., alias="term")


class CourseIndexQueryData(ConfiguredBaseModel):
    all_courses: Optional[list[Course]] = Field(..., alias="allCourses")


def query(query_func: Callable, **kwargs: Any) -> CourseIndexQueryData:
    """
    This is a convenience function which queries and parses the data into
    concrete types. It should be compatible with most GQL clients.
    You do not have to use it to consume the generated data classes.
    Alternatively, you can also mime and alternate the behavior
    of this function in the caller.

    Parameters:
        query_func (Callable): Function which queries your GQL Server
        kwargs: optional arguments that will be passed to the query function

    Returns:
        CourseIndexQueryData: queried data parsed into generated classes
    """
    raw_data: dict[Any, Any] = query_func(DEFINITION, **kwargs)
    return CourseIndexQueryData(**raw_data)
