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

from qcanvas_backend.gql_queries.canvas_course_data import CanvasCourseData

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
                    }
                }
            }
        }
    }
}

query SingleCourse($course_id: ID!, $detailed: Boolean!)
{
    course(id:$course_id) { ... CanvasCourseData }
}
"""


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


class SingleCourseQueryData(ConfiguredBaseModel):
    course: Optional[CanvasCourseData] = Field(..., alias="course")


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