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_text_match_query_parameter_type import GetFilterTextMatchQueryParameterType
    from .projects_get_response import ProjectsGetResponse
    from .projects_post_request_body import ProjectsPostRequestBody
    from .projects_post_response import ProjectsPostResponse

class ProjectsRequestBuilder(BaseRequestBuilder):
    """
    Builds and executes requests for operations under /construction/admin/v1/accounts/{accountId}/projects
    """
    def __init__(self,request_adapter: RequestAdapter, path_parameters: Union[str, dict[str, Any]]) -> None:
        """
        Instantiates a new ProjectsRequestBuilder 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/admin/v1/accounts/{accountId}/projects{?fields*,filterTextMatch*,filter%5BbusinessUnitId%5D*,filter%5Bclassification%5D*,filter%5BjobNumber%5D*,filter%5Bname%5D*,filter%5Bplatform%5D*,filter%5Bproducts%5D*,filter%5Bstatus%5D*,filter%5Btype%5D*,filter%5BupdatedAt%5D*,limit*,offset*,sort*}", path_parameters)
    
    async def get(self,request_configuration: Optional[RequestConfiguration[ProjectsRequestBuilderGetQueryParameters]] = None) -> Optional[ProjectsGetResponse]:
        """
        You can also use this endpoint to retrieve a list of project templates by setting the ``filter[classification]`` parameter to ``template`` or the ``filter[type]`` parameter to ``Template Project``.
        param request_configuration: Configuration for the request such as headers, query parameters, and middleware options.
        Returns: Optional[ProjectsGetResponse]
        """
        request_info = self.to_get_request_information(
            request_configuration
        )
        if not self.request_adapter:
            raise Exception("Http core is null") 
        from .projects_get_response import ProjectsGetResponse

        return await self.request_adapter.send_async(request_info, ProjectsGetResponse, None)
    
    async def post(self,body: ProjectsPostRequestBody, request_configuration: Optional[RequestConfiguration[QueryParameters]] = None) -> Optional[ProjectsPostResponse]:
        """
        Creates a new project in the specified account. You can create the project directly, or clone it from a project template.
        param body: The request body
        param request_configuration: Configuration for the request such as headers, query parameters, and middleware options.
        Returns: Optional[ProjectsPostResponse]
        """
        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 .projects_post_response import ProjectsPostResponse

        return await self.request_adapter.send_async(request_info, ProjectsPostResponse, None)
    
    def to_get_request_information(self,request_configuration: Optional[RequestConfiguration[ProjectsRequestBuilderGetQueryParameters]] = None) -> RequestInformation:
        """
        You can also use this endpoint to retrieve a list of project templates by setting the ``filter[classification]`` parameter to ``template`` or the ``filter[type]`` parameter to ``Template 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 to_post_request_information(self,body: ProjectsPostRequestBody, request_configuration: Optional[RequestConfiguration[QueryParameters]] = None) -> RequestInformation:
        """
        Creates a new project in the specified account. You can create the project directly, or clone it from a project template.
        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) -> ProjectsRequestBuilder:
        """
        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: ProjectsRequestBuilder
        """
        if raw_url is None:
            raise TypeError("raw_url cannot be null.")
        return ProjectsRequestBuilder(self.request_adapter, raw_url)
    
    @dataclass
    class ProjectsRequestBuilderGetQueryParameters():
        """
        You can also use this endpoint to retrieve a list of project templates by setting the ``filter[classification]`` parameter to ``template`` or the ``filter[type]`` parameter to ``Template 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 == "filterbusiness_unit_id":
                return "filter%5BbusinessUnitId%5D"
            if original_name == "filterclassification":
                return "filter%5Bclassification%5D"
            if original_name == "filterjob_number":
                return "filter%5BjobNumber%5D"
            if original_name == "filtername":
                return "filter%5Bname%5D"
            if original_name == "filterplatform":
                return "filter%5Bplatform%5D"
            if original_name == "filterproducts":
                return "filter%5Bproducts%5D"
            if original_name == "filterstatus":
                return "filter%5Bstatus%5D"
            if original_name == "filtertype":
                return "filter%5Btype%5D"
            if original_name == "filterupdated_at":
                return "filter%5BupdatedAt%5D"
            if original_name == "filter_text_match":
                return "filterTextMatch"
            if original_name == "fields":
                return "fields"
            if original_name == "limit":
                return "limit"
            if original_name == "offset":
                return "offset"
            if original_name == "sort":
                return "sort"
            return original_name
        
        # A comma-separated list of the project fields to include in the response. Default value: all fields.Possible values: ``accountId``, ``addressLine1``, ``addressLine2``, ``businessUnitId``, ``city``, ``companyCount``, ``constructionType``, ``country``, ``createdAt``, ``deliveryMethod``, ``endDate``, ``imageUrl``, ``jobNumber``, ``lastSignIn``, ``latitude``, ``longitude``, ``memberCount``, ``name``, ``platform``, ``postalCode``, ``products``, ``projectValue``, ``sheetCount``, ``startDate``, ``stateOrProvince``, ``status``, ``thumbnailImageUrl``, ``timezone``, ``type`` and ``updatedAt``.
        fields: Optional[list[str]] = None

        # Specifies how text-based filters should match values in supported fields.This parameter can be used in any endpoint that supports text-based filtering (e.g., ``filter[name]``, ``filter[jobNumber]``, ``filter[companyName]``, etc.).Possible values:``contains`` (default) – Matches if the field contains the specified text anywhere``startsWith`` – Matches if the field starts with the specified text``endsWith`` – Matches if the field ends with the specified text``equals`` – Matches only if the field exactly matches the specified textMatching is case-insensitive.Wildcards and regular expressions are not supported.
        filter_text_match: Optional[GetFilterTextMatchQueryParameterType] = None

        # The ID of the business unit that returned projects must be associated with.Note that you can obtain this ID value by calling the `GET business_units_structure </en/docs/acc/v1/reference/http/business_units_structure-GET/>`_ endpoint to retrieve a list of business units. Use the ``id`` field of the returned business unit that you want to filter by.Max length: 255
        filterbusiness_unit_id: Optional[UUID] = None

        # Filters projects by classification. Possible values:``production`` – Standard production projects.``template`` – Project templates that can be cloned to create production projects.``component`` – Placeholder projects that contain standardized components (e.g., forms) for use across projects. Only one component project is permitted per account. Known as a library in the ACC unified products UI.``sample`` – The single sample project automatically created upon ACC trial setup. Only one sample project is permitted per account.Max length: 255
        filterclassification: Optional[list[str]] = None

        # Filters by a user-defined project identifier. Supports partial matches when used with ``filterTextMatch``. For example, ``filter[jobNumber]=HP-0002&filterTextMatch=equals`` returns projects where the job number is exactly ``HP-0002``.Max length: 255
        filterjob_number: Optional[str] = None

        # Filters projects by name. Supports partial matches when used with ``filterTextMatch``. For example ``filter[name]=ABCco&filterTextMatch=startsWith`` returns projects whose names start with ``ABCco``.Max length: 255
        filtername: Optional[str] = None

        # Filters by platform. Possible values: ``acc`` (Autodesk Construction Cloud) and ``bim360`` (BIM 360).Max length: 255
        filterplatform: Optional[list[str]] = None

        # A comma-separated list of the products that the returned projects must use. Only projects that use one or more of the listed products are returned.Note that every product that can be used in a project on the same platform (ACC or BIM 360) is activated for the project. All products associated with the project are returned in the response.Some products are exclusive to ACC or to BIM 360, others are available on both platforms. Specify only the products on the appropriate platform for the projects you want to retrieve.Possible ACC values: ``accountAdministration``, ``autoSpecs``, ``build``, ``buildingConnected``, ``capitalPlanning``, ``cloudWorksharing``, ``cost``, ``designCollaboration``, ``docs``, ``financials``, ``insight``, ``modelCoordination``, ``projectAdministration``, ``takeoff``, and ``workshopxr``.Possible BIM 360 values: ``accountAdministration``, ``assets``, ``cloudWorksharing``, ``costManagement``, ``designCollaboration``, ``documentManagement``, ``field``, ``fieldManagement``, ``glue``, ``insight``, ``modelCoordination``, ``plan``, ``projectAdministration``, ``projectHome``, ``projectManagement``, and ``quantification``.
        filterproducts: Optional[list[str]] = None

        # Filters projects by status. Possible values: ``active``, ``pending``, ``archived``, ``suspended``.
        filterstatus: Optional[list[str]] = None

        # Filters by project type. To exclude a type, prefix it with ``-`` (e.g., ``-Bridge`` excludes bridge projects).Possible values: ``Airport``, ``Assisted Living / Nursing Home``, ``Bridge``, ``Canal / Waterway``, ``Convention Center``, ``Court House``, ``Data Center``, ``Dams / Flood Control / Reservoirs``, ``Demonstration Project``, ``Dormitory``, ``Education Facility``, ``Government Building``, ``Harbor / River Development``, ``Hospital``, ``Hotel / Motel``, ``Library``, ``Manufacturing / Factory``, ``Medical Laboratory``, ``Medical Office``, ``Military Facility``, ``Mining Facility``, ``Multi-Family Housing``, ``Museum``, ``Oil & Gas``,``Plant``, ``Office``, ``OutPatient Surgery Center``, ``Parking Structure / Garage``, ``Performing Arts``, ``Power Plant``, ``Prison / Correctional Facility``, ``Rail``, ``Recreation Building``, ``Religious Building``, ``Research Facility / Laboratory``, ``Restaurant``, ``Retail``, ``Seaport``, ``Single-Family Housing``, ``Solar Farm``, ``Stadium/Arena``, ``Streets / Roads / Highways``, ``Template Project``, ``Theme Park``, ``Training Project``, ``Transportation Building``, ``Tunnel``, ``Utilities``, ``Warehouse (non-manufacturing)``, ``Waste Water / Sewers``, ``Water Supply``, ``Wind Farm``.
        filtertype: Optional[list[str]] = None

        # Filters projects updated within a specific date range in ISO 8601 format. For example:Date range: ``2023-03-02T00:00:00.000Z..2023-03-03T23:59:59 .999Z``Specific start date: ``2023-03-02T00:00:00.000Z..``Specific end date: ``..2023-03-02T23:59:59.999Z``For more details, see `JSON API Filtering <https://jsonapi.org/format/#fetching-filtering>`_.Max length: 100
        filterupdated_at: Optional[str] = None

        # The maximum number of records to return in the response.Default: ``20``Minimum: ``1``Maximum: ``200`` (If a larger value is provided, only 200 records are returned)
        limit: Optional[int] = None

        # The index of the first record to return.Used for pagination in combination with the ``limit`` parameter.Example: ``limit=20`` and ``offset=40`` returns records 41–60.
        offset: Optional[int] = None

        # Sorts results by specified fields. Multiple fields can be used in order of priority. Each field can be followed by ``asc`` (ascending) or ``desc`` (descending). Default: ``asc``.For example, ``sort=name,createdAt desc`` sorts projects by name, then by creation date (newest first).Possible values: ``name`` (the default), ``startDate``, ``endDate``, ``type``, ``status``, ``jobNumber``, ``constructionType``, ``deliveryMethod``, ``contractType``, ``currentPhase``, ``companyCount``, ``memberCount``, ``createdAt`` and ``updatedAt``.
        sort: Optional[list[str]] = None

    
    @dataclass
    class ProjectsRequestBuilderGetRequestConfiguration(RequestConfiguration[ProjectsRequestBuilderGetQueryParameters]):
        """
        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 ProjectsRequestBuilderPostRequestConfiguration(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)
    

