"""
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,
)

from libqcanvas.gql_queries.attachment import Attachment

DEFINITION = """
fragment Attachment on File {
    id
    url
    displayName
    mimeClass
    contentType
    createdAt
    updatedAt
}

query AssignmentIndex($group_id: ID!) {
    node(id: $group_id) {
        ... on AssignmentGroup {
            assignmentsConnection {
                nodes {
                    id
                    name
                    description
                    dueAt
                    position
                    pointsPossible
                    courseId
                    assignmentGroupId
                    createdAt
                    updatedAt

                    lockInfo {
                        unlockAt
                        lockAt
                        canView
                        isLocked
                    }

                    submissionsConnection {
                        nodes {
                            id
                            score
                            attempt
                            body
                            createdAt
                            updatedAt
                            groupId

                            attachments {
                                ...Attachment
                            }

                            commentsConnection {
                                nodes {
                                    id
                                    htmlComment
                                    attachments {
                                        ...Attachment
                                    }
                                    createdAt
                                    updatedAt

                                    author {
                                        name
                                    }
                                }
                            }
                        }
                    }
                }

            }
        }
    }
}
"""


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


class Node(ConfiguredBaseModel): ...


class LockInfo(ConfiguredBaseModel):
    unlock_at: Optional[datetime] = Field(..., alias="unlockAt")
    lock_at: Optional[datetime] = Field(..., alias="lockAt")
    can_view: Optional[bool] = Field(..., alias="canView")
    is_locked: bool = Field(..., alias="isLocked")


class User(ConfiguredBaseModel):
    name: Optional[str] = Field(..., alias="name")


class SubmissionComment(ConfiguredBaseModel):
    q_id: str = Field(..., alias="id")
    html_comment: Optional[str] = Field(..., alias="htmlComment")
    attachments: list[Attachment] = Field(..., alias="attachments")
    created_at: datetime = Field(..., alias="createdAt")
    updated_at: Optional[datetime] = Field(..., alias="updatedAt")
    author: Optional[User] = Field(..., alias="author")


class SubmissionCommentConnection(ConfiguredBaseModel):
    nodes: Optional[list[Optional[SubmissionComment]]] = Field(..., alias="nodes")


class Submission(ConfiguredBaseModel):
    q_id: str = Field(..., alias="id")
    score: Optional[float] = Field(..., alias="score")
    attempt: int = Field(..., alias="attempt")
    body: Optional[str] = Field(..., alias="body")
    created_at: Optional[datetime] = Field(..., alias="createdAt")
    updated_at: Optional[datetime] = Field(..., alias="updatedAt")
    group_id: Optional[str] = Field(..., alias="groupId")
    attachments: Optional[list[Attachment]] = Field(..., alias="attachments")
    comments_connection: SubmissionCommentConnection = Field(
        ..., alias="commentsConnection"
    )


class SubmissionConnection(ConfiguredBaseModel):
    nodes: Optional[list[Optional[Submission]]] = Field(..., alias="nodes")


class Assignment(ConfiguredBaseModel):
    q_id: str = Field(..., alias="id")
    name: Optional[str] = Field(..., alias="name")
    description: Optional[str] = Field(..., alias="description")
    due_at: Optional[datetime] = Field(..., alias="dueAt")
    position: Optional[int] = Field(..., alias="position")
    points_possible: Optional[float] = Field(..., alias="pointsPossible")
    course_id: Optional[str] = Field(..., alias="courseId")
    assignment_group_id: Optional[str] = Field(..., alias="assignmentGroupId")
    created_at: Optional[datetime] = Field(..., alias="createdAt")
    updated_at: Optional[datetime] = Field(..., alias="updatedAt")
    lock_info: Optional[LockInfo] = Field(..., alias="lockInfo")
    submissions_connection: Optional[SubmissionConnection] = Field(
        ..., alias="submissionsConnection"
    )


class AssignmentConnection(ConfiguredBaseModel):
    nodes: Optional[list[Optional[Assignment]]] = Field(..., alias="nodes")


class AssignmentGroup(Node):
    assignments_connection: AssignmentConnection = Field(
        ..., alias="assignmentsConnection"
    )


class AssignmentIndexQueryData(ConfiguredBaseModel):
    node: Optional[Union[AssignmentGroup, Node]] = Field(..., alias="node")


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