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.packages_item_request_builder import PackagesItemRequestBuilder
    from .packages_get_response import PackagesGetResponse

class PackagesRequestBuilder(BaseRequestBuilder):
    """
    Builds and executes requests for operations under /construction/submittals/v2/projects/{projectId}/packages
    """
    def __init__(self,request_adapter: RequestAdapter, path_parameters: Union[str, dict[str, Any]]) -> None:
        """
        Instantiates a new PackagesRequestBuilder 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}/packages{?filter%5Bidentifier%5D*,filter%5Bspec%26%2346%3Bidentifier%5D*,filter%5BspecId%5D*,filter%5Btitle%5D*,limit*,offset*,search*,sort*}", path_parameters)
    
    def by_id(self,id: str) -> PackagesItemRequestBuilder:
        """
        Gets an item from the Autodesk.ACC.construction.submittals.v2.projects.item.packages.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: PackagesItemRequestBuilder
        """
        if id is None:
            raise TypeError("id cannot be null.")
        from .item.packages_item_request_builder import PackagesItemRequestBuilder

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

        return await self.request_adapter.send_async(request_info, PackagesGetResponse, None)
    
    def to_get_request_information(self,request_configuration: Optional[RequestConfiguration[PackagesRequestBuilderGetQueryParameters]] = None) -> RequestInformation:
        """
        Retrieve all the packages for the specified project. For information about packages, see the `Help documentation <https://help.autodesk.com/view/BUILD/ENU/?guid=Submittal_Packages>`_.
        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_url(self,raw_url: str) -> PackagesRequestBuilder:
        """
        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: PackagesRequestBuilder
        """
        if raw_url is None:
            raise TypeError("raw_url cannot be null.")
        return PackagesRequestBuilder(self.request_adapter, raw_url)
    
    @dataclass
    class PackagesRequestBuilderGetQueryParameters():
        """
        Retrieve all the packages for the specified project. For information about packages, see the `Help documentation <https://help.autodesk.com/view/BUILD/ENU/?guid=Submittal_Packages>`_.
        """
        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 == "filterspec46identifier":
                return "filter%5Bspec%26%2346%3Bidentifier%5D"
            if original_name == "filterspec_id":
                return "filter%5BspecId%5D"
            if original_name == "filtertitle":
                return "filter%5Btitle%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 packages with the specified package ID (the package ID in the UI). You can specify multiple values. Separate multiple values with commas. For example, ``filter[identifier]=2``.
        filteridentifier: Optional[str] = None

        # Filter packages with the associated specified spec section internal, globally unique ID (UUID). You can specify multiple values. Separate multiple values with commas. For example, ``filter[specId]=b4aa3864-5706-4a7b-b06c-a792e8b2df23``.
        filterspec_id: Optional[str] = None

        # Filter packages with the associated specified section ID (the spec section ID in the UI). You can specify multiple values. Separate multiple values with commas. For example, ``filter[identifier]=2``.
        filterspec46identifier: Optional[str] = None

        # Filter packages with the specified title. You can specify multiple values. Separate multiple values with commas. For example, ``filter[title]=Structural Steel``.
        filtertitle: 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 packages by querying a specified string within specific fields (``identifier``, ``title``, ``spec.identifier``), and retrieve the associated packages that match the search criteria. This includes packages where the string matches part of a field. For example, ``search=1``.
        search: Optional[str] = None

        # Sort packages 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, ``spec asc``.Possible values: ``id``, ``identifier``, ``title``, ``description``, ``spec``, ``spec.identifier``.
        sort: Optional[str] = None

    
    @dataclass
    class PackagesRequestBuilderGetRequestConfiguration(RequestConfiguration[PackagesRequestBuilderGetQueryParameters]):
        """
        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)
    

