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.specs_item_request_builder import SpecsItemRequestBuilder
    from .specs_get_response import SpecsGetResponse
    from .specs_post_request_body import SpecsPostRequestBody
    from .specs_post_response import SpecsPostResponse

class SpecsRequestBuilder(BaseRequestBuilder):
    """
    Builds and executes requests for operations under /construction/submittals/v2/projects/{projectId}/specs
    """
    def __init__(self,request_adapter: RequestAdapter, path_parameters: Union[str, dict[str, Any]]) -> None:
        """
        Instantiates a new SpecsRequestBuilder 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}/specs{?filter%5Bidentifier%5D*,limit*,offset*,search*,sort*}", path_parameters)
    
    def by_id(self,id: str) -> SpecsItemRequestBuilder:
        """
        Gets an item from the Autodesk.ACC.construction.submittals.v2.projects.item.specs.item collection
        param id: The ID of the submittal item to retrieve revisions for. To obtain this ID, call `GET items </en/docs/acc/v1/reference/http/submittals-items-GET/>`_.
        Returns: SpecsItemRequestBuilder
        """
        if id is None:
            raise TypeError("id cannot be null.")
        from .item.specs_item_request_builder import SpecsItemRequestBuilder

        url_tpl_params = get_path_parameters(self.path_parameters)
        url_tpl_params["id"] = id
        return SpecsItemRequestBuilder(self.request_adapter, url_tpl_params)
    
    async def get(self,request_configuration: Optional[RequestConfiguration[SpecsRequestBuilderGetQueryParameters]] = None) -> Optional[SpecsGetResponse]:
        """
        Retrieve all the spec sections for the specified project. For information about spec sections, see the `Help documentation <https://help.autodesk.com/view/BUILD/ENU/?guid=Submittal_Spec_Sections>`_.
        param request_configuration: Configuration for the request such as headers, query parameters, and middleware options.
        Returns: Optional[SpecsGetResponse]
        """
        request_info = self.to_get_request_information(
            request_configuration
        )
        if not self.request_adapter:
            raise Exception("Http core is null") 
        from .specs_get_response import SpecsGetResponse

        return await self.request_adapter.send_async(request_info, SpecsGetResponse, None)
    
    async def post(self,body: SpecsPostRequestBody, request_configuration: Optional[RequestConfiguration[QueryParameters]] = None) -> Optional[SpecsPostResponse]:
        """
        Creates a spec section to organize and categorize submittals.
        param body: The request body
        param request_configuration: Configuration for the request such as headers, query parameters, and middleware options.
        Returns: Optional[SpecsPostResponse]
        """
        if body is None:
            raise TypeError("body cannot be null.")
        request_info = self.to_post_request_information(
            body, request_configuration
        )
        if not self.request_adapter:
            raise Exception("Http core is null") 
        from .specs_post_response import SpecsPostResponse

        return await self.request_adapter.send_async(request_info, SpecsPostResponse, None)
    
    def to_get_request_information(self,request_configuration: Optional[RequestConfiguration[SpecsRequestBuilderGetQueryParameters]] = None) -> RequestInformation:
        """
        Retrieve all the spec sections for the specified project. For information about spec sections, see the `Help documentation <https://help.autodesk.com/view/BUILD/ENU/?guid=Submittal_Spec_Sections>`_.
        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 to_post_request_information(self,body: SpecsPostRequestBody, request_configuration: Optional[RequestConfiguration[QueryParameters]] = None) -> RequestInformation:
        """
        Creates a spec section to organize and categorize submittals.
        param body: The request body
        param request_configuration: Configuration for the request such as headers, query parameters, and middleware options.
        Returns: RequestInformation
        """
        if body is None:
            raise TypeError("body cannot be null.")
        request_info = RequestInformation(Method.POST, self.url_template, self.path_parameters)
        request_info.configure(request_configuration)
        request_info.headers.try_add("Accept", "application/json")
        request_info.set_content_from_parsable(self.request_adapter, "application/json", body)
        return request_info
    
    def with_url(self,raw_url: str) -> SpecsRequestBuilder:
        """
        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: SpecsRequestBuilder
        """
        if raw_url is None:
            raise TypeError("raw_url cannot be null.")
        return SpecsRequestBuilder(self.request_adapter, raw_url)
    
    @dataclass
    class SpecsRequestBuilderGetQueryParameters():
        """
        Retrieve all the spec sections for the specified project. For information about spec sections, see the `Help documentation <https://help.autodesk.com/view/BUILD/ENU/?guid=Submittal_Spec_Sections>`_.
        """
        def get_query_parameter(self,original_name: str) -> str:
            """
            Maps the query parameters names to their encoded names for the URI template parsing.
            param original_name: The original query parameter name in the class.
            Returns: str
            """
            if original_name is None:
                raise TypeError("original_name cannot be null.")
            if original_name == "filteridentifier":
                return "filter%5Bidentifier%5D"
            if original_name == "limit":
                return "limit"
            if original_name == "offset":
                return "offset"
            if original_name == "search":
                return "search"
            if original_name == "sort":
                return "sort"
            return original_name
        
        # Filter spec sections with the specified spec section ID (the spec section ID in the UI). You can specify multiple values. Separate multiple values with commas. For example, ``filter[identifier]=2.``
        filteridentifier: Optional[str] = None

        # 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

        # Search for spec sections by querying a specified string within specific fields (``identifier``, ``title``), and retrieve the associated items that match the search criteria. This includes spec sections where the string matches part of a field. For example, search=1.
        search: Optional[str] = None

        # Sort spec sections by specified fields. Separate multiple values with commas. To sort in descending or ascending order, add ``desc`` or ``asc`` after the sort criteria. For example, ``identifier asc``.Possible values: ``identifier``, ``title``.
        sort: Optional[str] = None

    
    @dataclass
    class SpecsRequestBuilderGetRequestConfiguration(RequestConfiguration[SpecsRequestBuilderGetQueryParameters]):
        """
        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)
    
    @dataclass
    class SpecsRequestBuilderPostRequestConfiguration(RequestConfiguration[QueryParameters]):
        """
        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)
    

