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 .item.with_job_item_request_builder import WithJobItemRequestBuilder
    from .jobs_get_response import JobsGetResponse

class JobsRequestBuilder(BaseRequestBuilder):
    """
    Builds and executes requests for operations under /data-connector/v1/accounts/{accountId}/jobs
    """
    def __init__(self,request_adapter: RequestAdapter, path_parameters: Union[str, dict[str, Any]]) -> None:
        """
        Instantiates a new JobsRequestBuilder 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}/data-connector/v1/accounts/{accountId}/jobs{?filter%5Bfield_to_filter%5D*,limit*,offset*,projectId*,sort*,sortFields*}", path_parameters)
    
    def by_job_id(self,job_id: UUID) -> WithJobItemRequestBuilder:
        """
        Gets an item from the Autodesk.ACC.dataConnector.v1.accounts.item.jobs.item collection
        param job_id: The job ID
        Returns: WithJobItemRequestBuilder
        """
        if job_id is None:
            raise TypeError("job_id cannot be null.")
        from .item.with_job_item_request_builder import WithJobItemRequestBuilder

        url_tpl_params = get_path_parameters(self.path_parameters)
        url_tpl_params["jobId"] = job_id
        return WithJobItemRequestBuilder(self.request_adapter, url_tpl_params)
    
    async def get(self,request_configuration: Optional[RequestConfiguration[JobsRequestBuilderGetQueryParameters]] = None) -> Optional[JobsGetResponse]:
        """
        To get request IDs for your requests, use `GET requests </en/docs/bim360/v1/reference/http/data-connector-requests-GET/>`_.
        param request_configuration: Configuration for the request such as headers, query parameters, and middleware options.
        Returns: Optional[JobsGetResponse]
        """
        request_info = self.to_get_request_information(
            request_configuration
        )
        if not self.request_adapter:
            raise Exception("Http core is null") 
        from .jobs_get_response import JobsGetResponse

        return await self.request_adapter.send_async(request_info, JobsGetResponse, None)
    
    def to_get_request_information(self,request_configuration: Optional[RequestConfiguration[JobsRequestBuilderGetQueryParameters]] = None) -> RequestInformation:
        """
        To get request IDs for your requests, use `GET requests </en/docs/bim360/v1/reference/http/data-connector-requests-GET/>`_.
        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) -> JobsRequestBuilder:
        """
        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: JobsRequestBuilder
        """
        if raw_url is None:
            raise TypeError("raw_url cannot be null.")
        return JobsRequestBuilder(self.request_adapter, raw_url)
    
    @dataclass
    class JobsRequestBuilderGetQueryParameters():
        """
        To get request IDs for your requests, use `GET requests </en/docs/bim360/v1/reference/http/data-connector-requests-GET/>`_.
        """
        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 == "filterfield_to_filter":
                return "filter%5Bfield_to_filter%5D"
            if original_name == "project_id":
                return "projectId"
            if original_name == "sort_fields":
                return "sortFields"
            if original_name == "limit":
                return "limit"
            if original_name == "offset":
                return "offset"
            if original_name == "sort":
                return "sort"
            return original_name
        
        # Return only the Data Connector jobs in which the specified field has the specified value. Use the following format in the endpoint URL: ``filter[field_to_filter]=_filter_value_``.Note that you can provide multiple job filters in the URL, but you may not filter on multiple values of the same field.Possible ``field_to_filter`` values: ``projectId``, ``createdAt``, ``status``, ``completionStatus``, ``startedAt``, ``completedAt``, ``startDate``, ``endDate``. You can also retrieve all Data Connector jobs in the current account by specifying ``filter[projectId]=null``.For the ``createdAt``, ``startedAt``, and ``completedAt`` fields (which accept a date range), specify the range in the form *firstdate..lastdate*, in ISO 8601 format with the time required. You can alternatively omit the first date (for example, to get everything on or before June 1, 2019 the range would be ``..2019-06-01T23:59:59.999Z``). You can also omit the last date (for example, to get everything after June 1, 2019 the range would be ``2019-06-01T00:00:00.000Z..``)Additional notes on using ``startDate`` and ``endDate``:- If you provide only ``startDate`` or ``endDate`` (but not both), Data Connector uses that single date for both ``startDate`` and ``endDate``.- If you request more than the Maximum Date Range Allowed for an extraction, the default date range as documented in the schema documentation is returned.- For the ``activities`` service group, data replication can be delayed up to 20 minutes, so your requests should account for that delay.
        filterfield_to_filter: Optional[str] = None

        # The number of data connector objects to return. Default value: 20
        limit: Optional[int] = None

        # The number of data objects to skip before starting to starting to collect the result set. Default value: 0
        offset: Optional[int] = None

        # Project ID of the returned Data Connector objects.
        project_id: Optional[str] = None

        # The sort order of returned data connector objects. Possible values: ``asc`` ascending by date (earliest to latest date), ``desc`` descending by date (latest to earliest date).
        sort: Optional[str] = None

        # A string of comma-separated names of the fields by which to sort the returned jobs. The results are sorted by the first field, then by the second field, and so on. Jobs are sorted by each field in ascending order by default; you can prepend any field name with a hyphen ( ``-`` ) to sort in descending order. Invalid fields and whitespaces are ignored.Possible values: ``projectId``, ``createdBy``, ``createdByEmail``, ``createdAt``, ``status``, ``completionStatus``, ``startedAt``, ``completedAt``, ``startDate``, ``endDate``.
        sort_fields: Optional[str] = None

    
    @dataclass
    class JobsRequestBuilderGetRequestConfiguration(RequestConfiguration[JobsRequestBuilderGetQueryParameters]):
        """
        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)
    

