from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass, field
from kiota_abstractions.base_request_builder import BaseRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
from kiota_abstractions.default_query_parameters import QueryParameters
from kiota_abstractions.get_path_parameters import get_path_parameters
from kiota_abstractions.method import Method
from kiota_abstractions.request_adapter import RequestAdapter
from kiota_abstractions.request_information import RequestInformation
from kiota_abstractions.request_option import RequestOption
from kiota_abstractions.serialization import Parsable, ParsableFactory
from typing import Any, Optional, TYPE_CHECKING, Union
from warnings import warn

if TYPE_CHECKING:
    from .item.with_task_item_request_builder import WithTaskItemRequestBuilder
    from .tasks_get_response import TasksGetResponse
    from .with_task_id_close.with_task_id_close_request_builder import WithTaskIdCloseRequestBuilder

class TasksRequestBuilder(BaseRequestBuilder):
    """
    Builds and executes requests for operations under /construction/submittals/v2/projects/{projectId}/items/{itemId}/steps/{stepId}/tasks
    """
    def __init__(self,request_adapter: RequestAdapter, path_parameters: Union[str, dict[str, Any]]) -> None:
        """
        Instantiates a new TasksRequestBuilder and sets the default values.
        param path_parameters: The raw url or the url-template parameters for the request.
        param request_adapter: The request adapter to use to execute the requests.
        Returns: None
        """
        super().__init__(request_adapter, "{+baseurl}/construction/submittals/v2/projects/{projectId}/items/{itemId}/steps/{stepId}/tasks{?limit*,offset*}", path_parameters)
    
    def by_task_id(self,task_id: str) -> WithTaskItemRequestBuilder:
        """
        Gets an item from the Autodesk.ACC.construction.submittals.v2.projects.item.items.item.steps.item.tasks.item collection
        param task_id: The ID of the task. To get the task ID, call `GET tasks </en/docs/acc/v1/reference/http/submittals-tasks-GET/>`_.
        Returns: WithTaskItemRequestBuilder
        """
        if task_id is None:
            raise TypeError("task_id cannot be null.")
        from .item.with_task_item_request_builder import WithTaskItemRequestBuilder

        url_tpl_params = get_path_parameters(self.path_parameters)
        url_tpl_params["taskId"] = task_id
        return WithTaskItemRequestBuilder(self.request_adapter, url_tpl_params)
    
    async def get(self,request_configuration: Optional[RequestConfiguration[TasksRequestBuilderGetQueryParameters]] = None) -> Optional[TasksGetResponse]:
        """
        Retrieves a list of tasks associated with a specific review step of a submittal item in a project.
        param request_configuration: Configuration for the request such as headers, query parameters, and middleware options.
        Returns: Optional[TasksGetResponse]
        """
        request_info = self.to_get_request_information(
            request_configuration
        )
        if not self.request_adapter:
            raise Exception("Http core is null") 
        from .tasks_get_response import TasksGetResponse

        return await self.request_adapter.send_async(request_info, TasksGetResponse, None)
    
    def to_get_request_information(self,request_configuration: Optional[RequestConfiguration[TasksRequestBuilderGetQueryParameters]] = None) -> RequestInformation:
        """
        Retrieves a list of tasks associated with a specific review step of a submittal item in a project.
        param request_configuration: Configuration for the request such as headers, query parameters, and middleware options.
        Returns: RequestInformation
        """
        request_info = RequestInformation(Method.GET, self.url_template, self.path_parameters)
        request_info.configure(request_configuration)
        request_info.headers.try_add("Accept", "application/json")
        return request_info
    
    def with_task_id_close(self,task_id: str) -> WithTaskIdCloseRequestBuilder:
        """
        Builds and executes requests for operations under /construction/submittals/v2/projects/{projectId}/items/{itemId}/steps/{stepId}/tasks/{taskId}:close
        param task_id: The ID of the task. To get the task ID, call `GET tasks </en/docs/acc/v1/reference/http/submittals-tasks-GET/>`_.
        Returns: WithTaskIdCloseRequestBuilder
        """
        if task_id is None:
            raise TypeError("task_id cannot be null.")
        from .with_task_id_close.with_task_id_close_request_builder import WithTaskIdCloseRequestBuilder

        return WithTaskIdCloseRequestBuilder(self.request_adapter, self.path_parameters, task_id)
    
    def with_url(self,raw_url: str) -> TasksRequestBuilder:
        """
        Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored.
        param raw_url: The raw URL to use for the request builder.
        Returns: TasksRequestBuilder
        """
        if raw_url is None:
            raise TypeError("raw_url cannot be null.")
        return TasksRequestBuilder(self.request_adapter, raw_url)
    
    @dataclass
    class TasksRequestBuilderGetQueryParameters():
        """
        Retrieves a list of tasks associated with a specific review step of a submittal item in a project.
        """
        # The maximum number of results per page. Possible values: ``1``- ``50``. Default value: ``20``. For example, to limit the response to two results per page, use ``limit=2``.
        limit: Optional[int] = None

        # The number of results to skip before starting to return data. For example, to skip the first 20 results, include ``offset=20`` in the query string. For more details, see the `JSON API Paging Help documentation <https://jsonapi.org/format/#fetching-pagination>`_.
        offset: Optional[int] = None

    
    @dataclass
    class TasksRequestBuilderGetRequestConfiguration(RequestConfiguration[TasksRequestBuilderGetQueryParameters]):
        """
        Configuration for the request such as headers, query parameters, and middleware options.
        """
        warn("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.", DeprecationWarning)
    

