"""
Generated by qenerate plugin=pydantic_v1. 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, Extra, Field, Json  # noqa: F401 # pylint: disable=W0611

DEFINITION = """
fragment CanvasCourseData on Course {
    _id
    name
    courseNickname
    term {
        endAt
        startAt
        name
        id
    }
    assignmentGroupsConnection @include(if: $detailed) {
        nodes {
            name
            id
            groupWeight
            assignmentsConnection {
                nodes {
                    description
                    courseId
                    dueAt
                    createdAt
                    id
                    name
                    position
                    updatedAt
                    pointsPossible
                    submissionsConnection {
                        nodes {
                            updatedAt
                            score
                        }
                    }
                }
            }
        }
    }
    modulesConnection @include(if: $detailed) {
        nodes {
            name
            id
            moduleItems {
                content {
                    ... on File {
                        _id
                        displayName
                        createdAt
                        updatedAt
                        url
                        size
                        mimeClass
                        contentType
                    }
                    ... on Page {
                        _id
                        title
                        updatedAt
                        createdAt
                    }
                }
            }
        }
    }
}
"""


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


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


class Submission(ConfiguredBaseModel):
    updated_at: Optional[datetime] = Field(..., alias="updatedAt")
    score: Optional[float] = Field(..., alias="score")


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


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


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


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


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


class ModuleItemInterface(ConfiguredBaseModel): ...


class File(ModuleItemInterface):
    q_id: str = Field(..., alias="_id")
    display_name: Optional[str] = Field(..., alias="displayName")
    created_at: Optional[datetime] = Field(..., alias="createdAt")
    updated_at: Optional[datetime] = Field(..., alias="updatedAt")
    url: Optional[str] = Field(..., alias="url")
    size: Optional[str] = Field(..., alias="size")
    mime_class: Optional[str] = Field(..., alias="mimeClass")
    content_type: Optional[str] = Field(..., alias="contentType")


class Page(ModuleItemInterface):
    q_id: str = Field(..., alias="_id")
    title: Optional[str] = Field(..., alias="title")
    updated_at: Optional[datetime] = Field(..., alias="updatedAt")
    created_at: Optional[datetime] = Field(..., alias="createdAt")


class ModuleItem(ConfiguredBaseModel):
    content: Optional[Union[File, Page, ModuleItemInterface]] = Field(
        ..., alias="content"
    )


class Module(ConfiguredBaseModel):
    name: Optional[str] = Field(..., alias="name")
    q_id: str = Field(..., alias="id")
    module_items: Optional[list[ModuleItem]] = Field(..., alias="moduleItems")


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


class CanvasCourseData(ConfiguredBaseModel):
    q_id: str = Field(..., alias="_id")
    name: str = Field(..., alias="name")
    course_nickname: Optional[str] = Field(..., alias="courseNickname")
    term: Optional[Term] = Field(..., alias="term")
    assignment_groups_connection: Optional[AssignmentGroupConnection] = Field(
        None, alias="assignmentGroupsConnection"
    )
    modules_connection: Optional[ModuleConnection] = Field(
        None, alias="modulesConnection"
    )
