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_version_set_item_request_builder import WithVersionSetItemRequestBuilder
    from .version_sets_get_response import VersionSetsGetResponse
    from .version_sets_post_request_body import VersionSetsPostRequestBody
    from .version_sets_post_response import VersionSetsPostResponse

class VersionSetsRequestBuilder(BaseRequestBuilder):
    """
    Builds and executes requests for operations under /construction/sheets/v1/projects/{projectId}/version-sets
    """
    def __init__(self,request_adapter: RequestAdapter, path_parameters: Union[str, dict[str, Any]]) -> None:
        """
        Instantiates a new VersionSetsRequestBuilder 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/sheets/v1/projects/{projectId}/version-sets{?collectionId*,limit*,offset*,sort*}", path_parameters)
    
    def by_version_set_id(self,version_set_id: str) -> WithVersionSetItemRequestBuilder:
        """
        Gets an item from the Autodesk.ACC.construction.sheets.v1.projects.item.versionSets.item collection
        param version_set_id: The ID of the version set. To find the version set ID, call `GET version-sets </en/docs/acc/v1/reference/http/sheets-version-sets-GET/>`_.
        Returns: WithVersionSetItemRequestBuilder
        """
        if version_set_id is None:
            raise TypeError("version_set_id cannot be null.")
        from .item.with_version_set_item_request_builder import WithVersionSetItemRequestBuilder

        url_tpl_params = get_path_parameters(self.path_parameters)
        url_tpl_params["versionSetId"] = version_set_id
        return WithVersionSetItemRequestBuilder(self.request_adapter, url_tpl_params)
    
    async def get(self,request_configuration: Optional[RequestConfiguration[VersionSetsRequestBuilderGetQueryParameters]] = None) -> Optional[VersionSetsGetResponse]:
        """
        Retrieves a list of version sets.
        param request_configuration: Configuration for the request such as headers, query parameters, and middleware options.
        Returns: Optional[VersionSetsGetResponse]
        """
        request_info = self.to_get_request_information(
            request_configuration
        )
        if not self.request_adapter:
            raise Exception("Http core is null") 
        from .version_sets_get_response import VersionSetsGetResponse

        return await self.request_adapter.send_async(request_info, VersionSetsGetResponse, None)
    
    async def post(self,body: VersionSetsPostRequestBody, request_configuration: Optional[RequestConfiguration[QueryParameters]] = None) -> Optional[VersionSetsPostResponse]:
        """
        Creates a version set.
        param body: The request body
        param request_configuration: Configuration for the request such as headers, query parameters, and middleware options.
        Returns: Optional[VersionSetsPostResponse]
        """
        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 .version_sets_post_response import VersionSetsPostResponse

        return await self.request_adapter.send_async(request_info, VersionSetsPostResponse, None)
    
    def to_get_request_information(self,request_configuration: Optional[RequestConfiguration[VersionSetsRequestBuilderGetQueryParameters]] = None) -> RequestInformation:
        """
        Retrieves a list of version sets.
        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: VersionSetsPostRequestBody, request_configuration: Optional[RequestConfiguration[QueryParameters]] = None) -> RequestInformation:
        """
        Creates a version set.
        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) -> VersionSetsRequestBuilder:
        """
        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: VersionSetsRequestBuilder
        """
        if raw_url is None:
            raise TypeError("raw_url cannot be null.")
        return VersionSetsRequestBuilder(self.request_adapter, raw_url)
    
    @dataclass
    class VersionSetsRequestBuilderGetQueryParameters():
        """
        Retrieves a list of version sets.
        """
        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 == "collection_id":
                return "collectionId"
            if original_name == "limit":
                return "limit"
            if original_name == "offset":
                return "offset"
            if original_name == "sort":
                return "sort"
            return original_name
        
        # Filter by sheet collection. If not provided, only results in the ungrouped collection are returned.Possible values:- The UUID of an existing collection: Returns only the results within that collection.- ``*`` Returns results from all collections.
        collection_id: Optional[str] = None

        # The maximum number of results to return per page. The default is ``200``.
        limit: Optional[int] = None

        # The starting point for the results, specified by item number. The default value is ``0``. For example, use ``offset=3`` to start the results from the third item.
        offset: Optional[int] = None

        # Sort the version sets by ``issuanceDate`` or ``name``. You need to add whether to sort in ascending (``asc``) or descending (``desc``) order. For example, ``sort=issuanceDate desc``.
        sort: Optional[str] = None

    
    @dataclass
    class VersionSetsRequestBuilderGetRequestConfiguration(RequestConfiguration[VersionSetsRequestBuilderGetQueryParameters]):
        """
        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 VersionSetsRequestBuilderPostRequestConfiguration(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)
    

