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_status_query_parameter_type import GetFilterStatusQueryParameterType
    from .item.with_workflow_item_request_builder import WithWorkflowItemRequestBuilder
    from .workflows_get_response import WorkflowsGetResponse
    from .workflows_post_request_body import WorkflowsPostRequestBody
    from .workflows_post_response import WorkflowsPostResponse

class WorkflowsRequestBuilder(BaseRequestBuilder):
    """
    Builds and executes requests for operations under /construction/reviews/v1/projects/{projectId}/workflows
    """
    def __init__(self,request_adapter: RequestAdapter, path_parameters: Union[str, dict[str, Any]]) -> None:
        """
        Instantiates a new WorkflowsRequestBuilder 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/reviews/v1/projects/{projectId}/workflows{?filter%5Binitiator%5D*,filter%5Bstatus%5D*,limit*,offset*,sort*}", path_parameters)
    
    def by_workflow_id(self,workflow_id: UUID) -> WithWorkflowItemRequestBuilder:
        """
        Gets an item from the Autodesk.ACC.construction.reviews.v1.projects.item.workflows.item collection
        param workflow_id: The ID of the approval workflow.To find available workflow IDs, call `GET Workflows </en/docs/acc/v1/reference/http/reviews-workflows-GET>`_.
        Returns: WithWorkflowItemRequestBuilder
        """
        if workflow_id is None:
            raise TypeError("workflow_id cannot be null.")
        from .item.with_workflow_item_request_builder import WithWorkflowItemRequestBuilder

        url_tpl_params = get_path_parameters(self.path_parameters)
        url_tpl_params["workflowId"] = workflow_id
        return WithWorkflowItemRequestBuilder(self.request_adapter, url_tpl_params)
    
    async def get(self,request_configuration: Optional[RequestConfiguration[WorkflowsRequestBuilderGetQueryParameters]] = None) -> Optional[WorkflowsGetResponse]:
        """
        Retrieves all approval workflows used for file reviews in a given project.
        param request_configuration: Configuration for the request such as headers, query parameters, and middleware options.
        Returns: Optional[WorkflowsGetResponse]
        """
        request_info = self.to_get_request_information(
            request_configuration
        )
        if not self.request_adapter:
            raise Exception("Http core is null") 
        from .workflows_get_response import WorkflowsGetResponse

        return await self.request_adapter.send_async(request_info, WorkflowsGetResponse, None)
    
    async def post(self,body: WorkflowsPostRequestBody, request_configuration: Optional[RequestConfiguration[QueryParameters]] = None) -> Optional[WorkflowsPostResponse]:
        """
        Creates a new approval workflow 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[WorkflowsPostResponse]
        """
        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 .workflows_post_response import WorkflowsPostResponse

        return await self.request_adapter.send_async(request_info, WorkflowsPostResponse, None)
    
    def to_get_request_information(self,request_configuration: Optional[RequestConfiguration[WorkflowsRequestBuilderGetQueryParameters]] = None) -> RequestInformation:
        """
        Retrieves all approval workflows used for file reviews in a given 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: WorkflowsPostRequestBody, request_configuration: Optional[RequestConfiguration[QueryParameters]] = None) -> RequestInformation:
        """
        Creates a new approval workflow 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_url(self,raw_url: str) -> WorkflowsRequestBuilder:
        """
        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: WorkflowsRequestBuilder
        """
        if raw_url is None:
            raise TypeError("raw_url cannot be null.")
        return WorkflowsRequestBuilder(self.request_adapter, raw_url)
    
    @dataclass
    class WorkflowsRequestBuilderGetQueryParameters():
        """
        Retrieves all approval workflows used for file reviews in a given 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 == "filterinitiator":
                return "filter%5Binitiator%5D"
            if original_name == "filterstatus":
                return "filter%5Bstatus%5D"
            if original_name == "limit":
                return "limit"
            if original_name == "offset":
                return "offset"
            if original_name == "sort":
                return "sort"
            return original_name
        
        # Filters the results based on who initiated the workflow. For example: ``filter[initiator]=true``.``true``: return only workflows initiated by the current user.This filter is ignored if the user is a project admin.``false``: (default) return workflows regardless of who initiated them.Note that this filter cannot be used together with ``filter[status]``.
        filterinitiator: Optional[bool] = None

        # Filters the results by workflow status. For example: ``filter[status]=INACTIVE``. Possible values:``ACTIVE``: return only active workflows.``INACTIVE``: return only inactive (disabled) workflows.Default: ``ACTIVE``.Note that this filter cannot be used together with ``filter[initiator]``.
        filterstatus: Optional[GetFilterStatusQueryParameterType] = None

        # The maximum number of approval workflows to return in a single request. Possible values: ``1-50``. Maximum: ``50``. Default: ``50``. For example: ``limit=2``.
        limit: Optional[int] = None

        # The index at which the endpoint starts returning results. Used for pagination. Default: ``0``. For example: ``offset=10``.
        offset: Optional[int] = None

        # Specifies a single field to sort the results by. The default order is ascending (``asc``); to sort in descending order, add ``desc``.Possible sorting fields: ``name``, ``status``, ``updatedAt``.For example: ``sort=name desc``.
        sort: Optional[str] = None

    
    @dataclass
    class WorkflowsRequestBuilderGetRequestConfiguration(RequestConfiguration[WorkflowsRequestBuilderGetQueryParameters]):
        """
        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 WorkflowsRequestBuilderPostRequestConfiguration(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)
    

