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 uuid import UUID
from warnings import warn

if TYPE_CHECKING:
    from .get_filter_version_type_query_parameter_type import GetFilterVersionTypeQueryParameterType
    from .get_sort_query_parameter_type import GetSortQueryParameterType
    from .item.with_package_item_request_builder import WithPackageItemRequestBuilder
    from .packages_get_response import PackagesGetResponse

class PackagesRequestBuilder(BaseRequestBuilder):
    """
    Builds and executes requests for operations under /construction/packages/v1/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/packages/v1/projects/{projectId}/packages{?filter%5BcreatedAt%5D*,filter%5BcreatedBy%5D*,filter%5BupdatedAt%5D*,filter%5BupdatedBy%5D*,filter%5BversionType%5D*,limit*,offset*,sort*}", path_parameters)
    
    def by_package_id(self,package_id: UUID) -> WithPackageItemRequestBuilder:
        """
        Gets an item from the Autodesk.ACC.construction.packages.v1.projects.item.packages.item collection
        param package_id: The ID of the package.To find the package ID, call `GET packages </en/docs/acc/v1/reference/http/packages-list-packages-GET/>`_.
        Returns: WithPackageItemRequestBuilder
        """
        if package_id is None:
            raise TypeError("package_id cannot be null.")
        from .item.with_package_item_request_builder import WithPackageItemRequestBuilder

        url_tpl_params = get_path_parameters(self.path_parameters)
        url_tpl_params["packageId"] = package_id
        return WithPackageItemRequestBuilder(self.request_adapter, url_tpl_params)
    
    async def get(self,request_configuration: Optional[RequestConfiguration[PackagesRequestBuilderGetQueryParameters]] = None) -> Optional[PackagesGetResponse]:
        """
        Retrieves a list of all packages within a specified ACC project.
        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:
        """
        Retrieves a list of all packages within a specified ACC 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_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():
        """
        Retrieves a list of all packages within a specified ACC project.
        """
        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 == "filtercreated_at":
                return "filter%5BcreatedAt%5D"
            if original_name == "filtercreated_by":
                return "filter%5BcreatedBy%5D"
            if original_name == "filterupdated_at":
                return "filter%5BupdatedAt%5D"
            if original_name == "filterupdated_by":
                return "filter%5BupdatedBy%5D"
            if original_name == "filterversion_type":
                return "filter%5BversionType%5D"
            if original_name == "limit":
                return "limit"
            if original_name == "offset":
                return "offset"
            if original_name == "sort":
                return "sort"
            return original_name
        
        # Filter packages by their creation time. Use an ISO 8601 date-time range in the format ``startDate..endDate``.Either date may be omitted to specify an open-ended range.Examples:- After a specific time: ``2025-03-26T16:00:00.000Z..``- Before a specific time: ``..2025-03-28T15:59:59.999Z``- Between two times: ``2025-03-26T16:00:00.000Z..2025-03-28T15:59:59.999Z``
        filtercreated_at: Optional[str] = None

        # Filters results by the Autodesk ID of the users who created the packages.You can provide a single Autodesk ID or a comma-separated list of IDs.
        filtercreated_by: Optional[str] = None

        # Filter packages by their last update time. Use an ISO 8601 date-time range in the format ``startDate..endDate``.Either date may be omitted to specify an open-ended range.Examples:- After a specific time: ``2025-03-26T16:00:00.000Z..``- Before a specific time: ``..2025-03-28T15:59:59.999Z``- Between two times: ``2025-03-26T16:00:00.000Z..2025-03-28T15:59:59.999Z``
        filterupdated_at: Optional[str] = None

        # Filters results by the Autodesk ID of the users who last updated the packages.You can provide a single Autodesk ID or a comma-separated list of IDs.To find the IDs call `GET users </en/docs/acc/v1/reference/http/admin-projectsprojectId-users-GET/>`_
        filterupdated_by: Optional[str] = None

        # Filters results by the version type of the packages.Possible values:- ``FIXED`` – Files in the package remain fixed at selected versions.- ``CURRENT`` – Files in the package automatically update to the latest current versions.For more details, see the `Flexible Package Types <https://help.autodesk.com/view/BUILD/ENU/?guid=File_Packages_Docs>`_ documentation.
        filterversion_type: Optional[GetFilterVersionTypeQueryParameterType] = None

        # The number of packages to return in the response payload.Possible values: ``1-200``. Default: ``200``. For example: ``limit=2``.
        limit: Optional[int] = None

        # The number of packages that you want to begin retrieving results from.Default: ``0``. For example: ``offset=10``
        offset: Optional[int] = None

        # Sorts the results by a supported field.By default, results are sorted in ascending (``asc``) order. To sort in descending order, add ``desc`` after the field name.Format: ``sort=fieldName [desc]``Possible values: ``name``, ``createdAt``, ``updatedAt``, ``displayId``,Examples:- Sort by name (ascending): ``sort=name``- Sort by creation time (descending): ``sort=createdAt desc``
        sort: Optional[GetSortQueryParameterType] = 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)
    

