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_item_item_request_builder import WithItemItemRequestBuilder
    from .items_get_response import ItemsGetResponse
    from .items_post_request_body import ItemsPostRequestBody
    from .items_post_response import ItemsPostResponse
    from .with_item_id_transition.with_item_id_transition_request_builder import WithItemIdTransitionRequestBuilder

class ItemsRequestBuilder(BaseRequestBuilder):
    """
    Builds and executes requests for operations under /construction/submittals/v2/projects/{projectId}/items
    """
    def __init__(self,request_adapter: RequestAdapter, path_parameters: Union[str, dict[str, Any]]) -> None:
        """
        Instantiates a new ItemsRequestBuilder 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}/items{?filter%5BballInCourtCompanies%5D*,filter%5BballInCourtRoles%5D*,filter%5BballInCourtUsers%5D*,filter%5BcreatedAt%5D*,filter%5BcreatedBy%5D*,filter%5BdueDate%5D*,filter%5Bid%5D*,filter%5Bidentifier%5D*,filter%5BleadTime%5D*,filter%5BmanagerDueDate%5D*,filter%5BmanagerType%5D*,filter%5Bmanager%5D*,filter%5BpackageId%5D*,filter%5BpublishedDate%5D*,filter%5BreceivedFromReview%5D*,filter%5BreceivedFromSubmitter%5D*,filter%5BrequiredApprovalDate%5D*,filter%5BrequiredDate%5D*,filter%5BrequiredOnJobDate%5D*,filter%5BresponseId%5D*,filter%5BreviewResponseId%5D*,filter%5Brevision%5D*,filter%5BsentToReview%5D*,filter%5BsentToSubmitter%5D*,filter%5BspecId%5D*,filter%5BstateId%5D*,filter%5BstatusId%5D*,filter%5BsubcontractorType%5D*,filter%5Bsubcontractor%5D*,filter%5BsubmitterDueDate%5D*,filter%5Btitle%5D*,filter%5BtypeId%5D*,filter%5BupdatedAt%5D*,filter%5Bwatchers%5D*,limit*,offset*,search*,sort*}", path_parameters)
    
    def by_item_id(self,item_id: str) -> WithItemItemRequestBuilder:
        """
        Gets an item from the Autodesk.ACC.construction.submittals.v2.projects.item.items.item collection
        param item_id: The ID of the submittal item. To find the item ID, call `GET items </en/docs/acc/v1/reference/http/submittals-items-GET/>`_.
        Returns: WithItemItemRequestBuilder
        """
        if item_id is None:
            raise TypeError("item_id cannot be null.")
        from .item.with_item_item_request_builder import WithItemItemRequestBuilder

        url_tpl_params = get_path_parameters(self.path_parameters)
        url_tpl_params["itemId"] = item_id
        return WithItemItemRequestBuilder(self.request_adapter, url_tpl_params)
    
    async def get(self,request_configuration: Optional[RequestConfiguration[ItemsRequestBuilderGetQueryParameters]] = None) -> Optional[ItemsGetResponse]:
        """
        Retrieves information about all the submittal items in a project that the user has permission to view.
        param request_configuration: Configuration for the request such as headers, query parameters, and middleware options.
        Returns: Optional[ItemsGetResponse]
        """
        request_info = self.to_get_request_information(
            request_configuration
        )
        if not self.request_adapter:
            raise Exception("Http core is null") 
        from .items_get_response import ItemsGetResponse

        return await self.request_adapter.send_async(request_info, ItemsGetResponse, None)
    
    async def post(self,body: ItemsPostRequestBody, request_configuration: Optional[RequestConfiguration[QueryParameters]] = None) -> Optional[ItemsPostResponse]:
        """
        Creates a new submittal item in the specified project.
        param body: The request body
        param request_configuration: Configuration for the request such as headers, query parameters, and middleware options.
        Returns: Optional[ItemsPostResponse]
        """
        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 .items_post_response import ItemsPostResponse

        return await self.request_adapter.send_async(request_info, ItemsPostResponse, None)
    
    def to_get_request_information(self,request_configuration: Optional[RequestConfiguration[ItemsRequestBuilderGetQueryParameters]] = None) -> RequestInformation:
        """
        Retrieves information about all the submittal items in a project that the user has permission to view.
        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: ItemsPostRequestBody, request_configuration: Optional[RequestConfiguration[QueryParameters]] = None) -> RequestInformation:
        """
        Creates a new submittal item in the specified project.
        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_item_id_transition(self,item_id: str) -> WithItemIdTransitionRequestBuilder:
        """
        Builds and executes requests for operations under /construction/submittals/v2/projects/{projectId}/items/{itemId}:transition
        param item_id: The ID of the submittal item. To find the item ID, call `GET items </en/docs/acc/v1/reference/http/submittals-items-GET/>`_.
        Returns: WithItemIdTransitionRequestBuilder
        """
        if item_id is None:
            raise TypeError("item_id cannot be null.")
        from .with_item_id_transition.with_item_id_transition_request_builder import WithItemIdTransitionRequestBuilder

        return WithItemIdTransitionRequestBuilder(self.request_adapter, self.path_parameters, item_id)
    
    def with_url(self,raw_url: str) -> ItemsRequestBuilder:
        """
        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: ItemsRequestBuilder
        """
        if raw_url is None:
            raise TypeError("raw_url cannot be null.")
        return ItemsRequestBuilder(self.request_adapter, raw_url)
    
    @dataclass
    class ItemsRequestBuilderGetQueryParameters():
        """
        Retrieves information about all the submittal items in a project that the user has permission to view.
        """
        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 == "filterball_in_court_companies":
                return "filter%5BballInCourtCompanies%5D"
            if original_name == "filterball_in_court_roles":
                return "filter%5BballInCourtRoles%5D"
            if original_name == "filterball_in_court_users":
                return "filter%5BballInCourtUsers%5D"
            if original_name == "filtercreated_at":
                return "filter%5BcreatedAt%5D"
            if original_name == "filtercreated_by":
                return "filter%5BcreatedBy%5D"
            if original_name == "filterdue_date":
                return "filter%5BdueDate%5D"
            if original_name == "filterid":
                return "filter%5Bid%5D"
            if original_name == "filteridentifier":
                return "filter%5Bidentifier%5D"
            if original_name == "filterlead_time":
                return "filter%5BleadTime%5D"
            if original_name == "filtermanager":
                return "filter%5Bmanager%5D"
            if original_name == "filtermanager_due_date":
                return "filter%5BmanagerDueDate%5D"
            if original_name == "filtermanager_type":
                return "filter%5BmanagerType%5D"
            if original_name == "filterpackage_id":
                return "filter%5BpackageId%5D"
            if original_name == "filterpublished_date":
                return "filter%5BpublishedDate%5D"
            if original_name == "filterreceived_from_review":
                return "filter%5BreceivedFromReview%5D"
            if original_name == "filterreceived_from_submitter":
                return "filter%5BreceivedFromSubmitter%5D"
            if original_name == "filterrequired_approval_date":
                return "filter%5BrequiredApprovalDate%5D"
            if original_name == "filterrequired_date":
                return "filter%5BrequiredDate%5D"
            if original_name == "filterrequired_on_job_date":
                return "filter%5BrequiredOnJobDate%5D"
            if original_name == "filterresponse_id":
                return "filter%5BresponseId%5D"
            if original_name == "filterreview_response_id":
                return "filter%5BreviewResponseId%5D"
            if original_name == "filterrevision":
                return "filter%5Brevision%5D"
            if original_name == "filtersent_to_review":
                return "filter%5BsentToReview%5D"
            if original_name == "filtersent_to_submitter":
                return "filter%5BsentToSubmitter%5D"
            if original_name == "filterspec_id":
                return "filter%5BspecId%5D"
            if original_name == "filterstate_id":
                return "filter%5BstateId%5D"
            if original_name == "filterstatus_id":
                return "filter%5BstatusId%5D"
            if original_name == "filtersubcontractor":
                return "filter%5Bsubcontractor%5D"
            if original_name == "filtersubcontractor_type":
                return "filter%5BsubcontractorType%5D"
            if original_name == "filtersubmitter_due_date":
                return "filter%5BsubmitterDueDate%5D"
            if original_name == "filtertitle":
                return "filter%5Btitle%5D"
            if original_name == "filtertype_id":
                return "filter%5BtypeId%5D"
            if original_name == "filterupdated_at":
                return "filter%5BupdatedAt%5D"
            if original_name == "filterwatchers":
                return "filter%5Bwatchers%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 items associated with the specified ball-in-court company ID. You can specify multiple companies. Separate multiple values with commas. For example, ``filter[ballInCourtCompanies]=WD43ZJGKDFLFH``.
        filterball_in_court_companies: Optional[str] = None

        # Filter items associated with the specified ball-in-court role ID. You can specify multiple roles. Separate multiple values with commas. For example, ``filter[ballInCourtRoles]=WD43ZJGKDFLFH``.
        filterball_in_court_roles: Optional[str] = None

        # Filter items associated with the specified ball-in-court user ID. You can specify multiple users. Separate multiple values with commas. For example, ``filter[ballInCourtUsers]=HNRCQ6JTWAED``.
        filterball_in_court_users: Optional[str] = None

        # Filter items with the specified creation date, using the following URL-encoded format YYYY-MM-DD. We support the following filtering options:- Date range: e.g., ``2022-03-02..2022-03-03``- Specific day: e.g., ``2022-03-02``For more details, see `JSON API Filtering <http://jsonapi.org/format/#fetching-filtering>`_.
        filtercreated_at: Optional[str] = None

        # Filter items that were created by the specified user by specifying the user’s Autodesk ID. For example, ``filter[createdBy]=PER8KQPK2JRT``. To find the ID call `GET users <https://aps.autodesk.com/en/docs/acc/v1/reference/http/admin-projectsprojectId-users-GET/>`_.
        filtercreated_by: Optional[str] = None

        # Filter items with the specified due date, using the following URL-encoded format YYYY-MM-DD. We support the following filtering options:- Date range: e.g., ``2022-03-02..2022-03-03``- Specific day: e.g., ``2022-03-02``For more details, see `JSON API Filtering <http://jsonapi.org/format/#fetching-filtering>`_.
        filterdue_date: Optional[str] = None

        # Filter submittal items by their unique internal submittal item ID (UUID). You can specify multiple values. Separate multiple values with commas. For example ``filter[id]=b8cc9324-6759-4f07-8ce3-725d5afd4f11``.
        filterid: Optional[str] = None

        # Filter items with the specified submittal item ID (the submittal item ID in the UI). You can specify multiple values. Separate multiple values with commas. For example, ``filter[identifier]=2``.
        filteridentifier: Optional[str] = None

        # Filter items with the specified lead time. You can specify multiple values. Separate multiple values with commas. For example, ``filter[leadTime]=100``.
        filterlead_time: Optional[str] = None

        # Filter items with the specified manager Autodesk ID. You can specify multiple values. Separate multiple values with commas. For example, ``filter[manager]=WD43ZJGKDFLFH``.
        filtermanager: Optional[str] = None

        # Filter items with the specified manager's due date, using the following URL-encoded format YYYY-MM-DD. We support the following filtering options:- Date range: e.g., ``2022-03-02..2022-03-03``- Specific day: e.g., ``2022-03-02``For more details, see `JSON API Filtering <http://jsonapi.org/format/#fetching-filtering>`_.
        filtermanager_due_date: Optional[str] = None

        # Filter items with the specified manager type. You can specify multiple values. Separate multiple values with commas. For example, ``filter[managerType]=1``.
        filtermanager_type: Optional[str] = None

        # Filter items with the specified package ID. You can specify multiple values. Separate multiple values with commas.For example, ``filter[packageId]=06fa0c1b-6462-459d-8a38-0aff11bfe868``.In order to filter items with no package, use 'noPackage' value.
        filterpackage_id: Optional[str] = None

        # Filter items based on their published date using the following URL-encoded format: YYYY-MM-DD. We support the following filtering options:- Date range: e.g., ``2022-03-02..2022-03-03``- Specific day: e.g., ``2022-03-02``For more details, see `JSON API Filtering <http://jsonapi.org/format/#fetching-filtering>`_.
        filterpublished_date: Optional[str] = None

        # Filter items based on the date they were moved forward by the reviewer using the URL-encoded format: YYYY-MM-DD. We support the following filtering options:- Date range: e.g., ``2022-03-02..2022-03-03``- Specific day: e.g., ``2022-03-02``For more details, see `JSON API Filtering <http://jsonapi.org/format/#fetching-filtering>`_.
        filterreceived_from_review: Optional[str] = None

        # Filter items based on the date they were received from the submitter. Use the following URL-encoded format: YYYY-MM-DD. We support the following filtering options:- Date range: e.g., ``2022-03-02..2022-03-03``- Specific day: e.g., ``2022-03-02``For more details, see `JSON API Filtering <http://jsonapi.org/format/#fetching-filtering>`_.
        filterreceived_from_submitter: Optional[str] = None

        # Filter items based on their required approval date using the following URL-encoded format: YYYY-MM-DD. We support the following filtering options:- Date range: e.g., ``2022-03-02..2022-03-03``- Specific day: e.g., ``2022-03-02``For more details, see `JSON API Filtering <http://jsonapi.org/format/#fetching-filtering>`_.
        filterrequired_approval_date: Optional[str] = None

        # Filter items based on the date the responsible contractor needs to submit the submittal to the submittal manager, using the following URL-encoded format: YYYY-MM-DD. We support the following filtering options:- Date range: e.g., ``2022-03-02..2022-03-03``- Specific day: e.g., ``2022-03-02``For more details, see `JSON API Filtering <http://jsonapi.org/format/#fetching-filtering>`_.
        filterrequired_date: Optional[str] = None

        # Filter items based on their required on-job (jobsite) date using the following URL-encoded format: YYYY-MM-DD. We support the following filtering options:- Date range: e.g., ``2022-03-02..2022-03-03``- Specific day: e.g., ``2022-03-02``For more details, see `JSON API Filtering <http://jsonapi.org/format/#fetching-filtering>`_.
        filterrequired_on_job_date: Optional[str] = None

        # Filter items with the specified final response ID. You can specify multiple IDs. You can specify multiple values. Separate multiple values with commas. For example, ``filter[responseId]=1w66d30b-7dc1-4a65-991d-d739a1381rf4``.
        filterresponse_id: Optional[str] = None

        # Filter items with the specified review response ID. You can specify multiple IDs. You can specify multiple values. Separate multiple values with commas. For example, ``filter[reviewResponseId]=1w66d30b-7dc1-4a65-991d-d739a1381rf4``.
        filterreview_response_id: Optional[str] = None

        # Filter items with the specified revision number. You can specify multiple values. Separate multiple values with commas. For example, ``filter[revision]=1``.
        filterrevision: Optional[str] = None

        # Filter items based on the date they were sent for review, in the URL-encoded format: YYYY-MM-DD. We support the following filtering options:- Date range: e.g., ``2022-03-02..2022-03-03``- Specific day: e.g., ``2022-03-02``For more details, see `JSON API Filtering <http://jsonapi.org/format/#fetching-filtering>`_.
        filtersent_to_review: Optional[str] = None

        # Filter items based on the date they were sent to the submitter. Use the following URL-encoded format: YYYY-MM-DD. We support the following filtering options:- Date range: e.g., ``2022-03-02..2022-03-03``- Specific day: e.g., ``2022-03-02``For more details, see `JSON API Filtering <http://jsonapi.org/format/#fetching-filtering>`_.
        filtersent_to_submitter: Optional[str] = None

        # Filter items with the specified spec ID. 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 items with the specified state ID. You can specify multiple values. Separate multiple values with commas. For example, ``filter[stateId]=rev``.
        filterstate_id: Optional[str] = None

        # Filter items with the specified status ID. You can specify multiple values. Separate multiple values with commas. For example, ``filter[statusId]=1``
        filterstatus_id: Optional[str] = None

        # Filter items with the specified subcontractor Autodesk ID. You can specify multiple values. Separate multiple values with commas. For example, ``filter[subcontractor]=WD43ZJGKDFLFH``.
        filtersubcontractor: Optional[str] = None

        # Filter items with the specified subcontractor type. You can specify multiple values. Separate multiple values with commas. For example, ``filter[subcontractorType]=1``.
        filtersubcontractor_type: Optional[str] = None

        # Filter items with the specified submitter's due date, using the following URL-encoded format YYYY-MM-DD. We support the following filtering options:- Date range: e.g., ``2022-03-02..2022-03-03``- Specific day: e.g., ``2022-03-02``For more details, see `JSON API Filtering <http://jsonapi.org/format/#fetching-filtering>`_.
        filtersubmitter_due_date: Optional[str] = None

        # Filter items with the specified title. You can specify multiple values. Separate multiple values with commas. For example, ``filter[title]=``Shop Drawings````.
        filtertitle: Optional[str] = None

        # Filter items with the specified type ID. You can specify multiple values. Separate multiple values with commas. For example, ``filter[typeId]=06fa0c1b-6462-459d-8a38-0aff11bfe868``.
        filtertype_id: Optional[str] = None

        # Filter items by their last updated date using the following URL-encoded format: YYYY-MM-DD. We support the following filtering options:- Date range: e.g., ``2022-03-02..2022-03-03``- Specific day: e.g., ``2022-03-02``For more details, see `JSON API Filtering <http://jsonapi.org/format/#fetching-filtering>`_.
        filterupdated_at: Optional[str] = None

        # Filter items that are associated with the specified watcher, by specifying the watcher’s Autodesk ID. For example, ``filter[watchers]=PER8KQPK2JRT``. You can specify more than one watcher. Separate multiple values with commas. To find the ID call `GET users <https://aps.autodesk.com/en/docs/acc/v1/reference/http/admin-projectsprojectId-users-GET/>`_.
        filterwatchers: 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 items by querying a specified string within specific fields (``identifier``, ``title``, ``specIdentifier``, ``ballInCourt``), and retrieve the associated items that match the search criteria. This includes items where the string matches part of a field. For example, ``search=1``.
        search: Optional[str] = None

        # Sort items 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, ``statusId asc``.Possible values: ``ballInCourtUsers``, ``ballInCourtCompanies``, ``ballInCourtRoles``, ``ballInCourtType``, ``customIdentifier``, ``customIdentifierHumanReadable``, ``createdAt``, ``createdBy``, ``description``, ``dueDate``, ``id``, ``identifier``, ``leadTime``, ``manager``, ``managerType``, ``managerDueDate``, ``package.identifier``, ``package.spec.identifier``, ``packageId``, ``packageIdentifier``, ``packageSpecIdentifier``, ``packageTitle``, ``priority``, ``publishedBy``, ``publishedDate``, ``receivedFromReview``, ``receivedFromSubmitter``, ``requiredApprovalDate``, ``requiredDate``, ``requiredOnJobDate``, ``respondedAt``, ``respondedBy``, ``response.value``, ``responseComment``, ``responseId``, ``revision``, ``sentToReview``, ``sentToReviewBy``, ``sentToSubmitter``, ``spec.identifier``, ``specId``, ``specIdentifier``, ``specTitle``, ``stateId``, ``statusId``, ``subcontractor``, ``subcontractorType``, ``submittedBy``, ``submitterDueDate``, ``subsection``, ``title``, ``type.value``, ``typeId``, ``updatedAt``, ``updatedBy``, ``watchers``.
        sort: Optional[str] = None

    
    @dataclass
    class ItemsRequestBuilderGetRequestConfiguration(RequestConfiguration[ItemsRequestBuilderGetQueryParameters]):
        """
        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 ItemsRequestBuilderPostRequestConfiguration(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)
    

