"""
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 Any, Optional, Union  # noqa: F401 # pylint: disable=W0611

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

DEFINITION = """
query AssignmentGroupIndex($course_id: ID!) {
    legacyNode(_id: $course_id, type: Course) {
        ... on Course {
            assignmentGroups {
                id
                legacy_id: _id
                name
                groupWeight
            }
        }
    }
}
"""


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


class Node(ConfiguredBaseModel): ...


class AssignmentGroup(ConfiguredBaseModel):
    q_id: str = Field(..., alias="id")
    legacy_id: str = Field(..., alias="legacy_id")
    name: Optional[str] = Field(..., alias="name")
    group_weight: Optional[float] = Field(..., alias="groupWeight")


class Course(Node):
    assignment_groups: Optional[list[AssignmentGroup]] = Field(
        ..., alias="assignmentGroups"
    )


class AssignmentGroupIndexQueryData(ConfiguredBaseModel):
    legacy_node: Optional[Union[Course, Node]] = Field(..., alias="legacyNode")


def query(query_func: Callable, **kwargs: Any) -> AssignmentGroupIndexQueryData:
    """
    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:
        AssignmentGroupIndexQueryData: queried data parsed into generated classes
    """
    raw_data: dict[Any, Any] = query_func(DEFINITION, **kwargs)
    return AssignmentGroupIndexQueryData(**raw_data)
