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

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

DEFINITION = """
fragment CanvasCourseData on Course {
    _id
    name
    courseNickname
    term {
        endAt
        startAt
        name
        id
    }
    assignmentsConnection @include(if: $detailed) {
        nodes {
            description
            courseId
            dueAt
            createdAt
            id
            name
            position
            updatedAt
        }
    }
    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:
        smart_union = True
        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 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")


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


class ModuleItemInterface(ConfiguredBaseModel):
    ...


class File(ModuleItemInterface):
    m_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):
    m_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):
    m_id: str = Field(..., alias="_id")
    name: str = Field(..., alias="name")
    course_nickname: Optional[str] = Field(..., alias="courseNickname")
    term: Optional[Term] = Field(..., alias="term")
    assignments_connection: Optional[AssignmentConnection] = Field(None, alias="assignmentsConnection")
    modules_connection: Optional[ModuleConnection] = Field(None, alias="modulesConnection")
