"""
    Airflow API

    Airflow API. All endpoints located under ``/api/v2`` can be used safely, are stable and backward compatible. Endpoints located under ``/ui`` are dedicated to the UI and are subject to breaking change depending on the need of the frontend. Users should not rely on those but use the public ones instead.

    The version of the OpenAPI document: 2
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


import warnings
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
from typing import Any, Dict, List, Optional, Tuple, Union
from typing_extensions import Annotated

from datetime import datetime
from pydantic import Field, StrictBool, StrictStr
from typing import List, Optional
from typing_extensions import Annotated
from airflow_client.client.models.job_collection_response import JobCollectionResponse

from airflow_client.client.api_client import ApiClient, RequestSerialized
from airflow_client.client.api_response import ApiResponse
from airflow_client.client.rest import RESTResponseType


class JobApi:
    """NOTE: This class is auto generated by OpenAPI Generator
    Ref: https://openapi-generator.tech

    Do not edit the class manually.
    """

    def __init__(self, api_client=None) -> None:
        if api_client is None:
            api_client = ApiClient.get_default()
        self.api_client = api_client


    @validate_call
    def get_jobs(
        self,
        is_alive: Optional[StrictBool] = None,
        start_date_gte: Optional[datetime] = None,
        start_date_gt: Optional[datetime] = None,
        start_date_lte: Optional[datetime] = None,
        start_date_lt: Optional[datetime] = None,
        end_date_gte: Optional[datetime] = None,
        end_date_gt: Optional[datetime] = None,
        end_date_lte: Optional[datetime] = None,
        end_date_lt: Optional[datetime] = None,
        limit: Optional[Annotated[int, Field(strict=True, ge=0)]] = None,
        offset: Optional[Annotated[int, Field(strict=True, ge=0)]] = None,
        order_by: Annotated[Optional[List[StrictStr]], Field(description="Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `id, dag_id, state, job_type, start_date, end_date, latest_heartbeat, executor_class, hostname, unixname`")] = None,
        job_state: Optional[StrictStr] = None,
        job_type: Optional[StrictStr] = None,
        hostname: Optional[StrictStr] = None,
        executor_class: Optional[StrictStr] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> JobCollectionResponse:
        """Get Jobs

        Get all jobs.

        :param is_alive:
        :type is_alive: bool
        :param start_date_gte:
        :type start_date_gte: datetime
        :param start_date_gt:
        :type start_date_gt: datetime
        :param start_date_lte:
        :type start_date_lte: datetime
        :param start_date_lt:
        :type start_date_lt: datetime
        :param end_date_gte:
        :type end_date_gte: datetime
        :param end_date_gt:
        :type end_date_gt: datetime
        :param end_date_lte:
        :type end_date_lte: datetime
        :param end_date_lt:
        :type end_date_lt: datetime
        :param limit:
        :type limit: int
        :param offset:
        :type offset: int
        :param order_by: Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `id, dag_id, state, job_type, start_date, end_date, latest_heartbeat, executor_class, hostname, unixname`
        :type order_by: List[str]
        :param job_state:
        :type job_state: str
        :param job_type:
        :type job_type: str
        :param hostname:
        :type hostname: str
        :param executor_class:
        :type executor_class: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._get_jobs_serialize(
            is_alive=is_alive,
            start_date_gte=start_date_gte,
            start_date_gt=start_date_gt,
            start_date_lte=start_date_lte,
            start_date_lt=start_date_lt,
            end_date_gte=end_date_gte,
            end_date_gt=end_date_gt,
            end_date_lte=end_date_lte,
            end_date_lt=end_date_lt,
            limit=limit,
            offset=offset,
            order_by=order_by,
            job_state=job_state,
            job_type=job_type,
            hostname=hostname,
            executor_class=executor_class,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "JobCollectionResponse",
            '400': "HTTPExceptionResponse",
            '401': "HTTPExceptionResponse",
            '403': "HTTPExceptionResponse",
            '422': "HTTPValidationError",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def get_jobs_with_http_info(
        self,
        is_alive: Optional[StrictBool] = None,
        start_date_gte: Optional[datetime] = None,
        start_date_gt: Optional[datetime] = None,
        start_date_lte: Optional[datetime] = None,
        start_date_lt: Optional[datetime] = None,
        end_date_gte: Optional[datetime] = None,
        end_date_gt: Optional[datetime] = None,
        end_date_lte: Optional[datetime] = None,
        end_date_lt: Optional[datetime] = None,
        limit: Optional[Annotated[int, Field(strict=True, ge=0)]] = None,
        offset: Optional[Annotated[int, Field(strict=True, ge=0)]] = None,
        order_by: Annotated[Optional[List[StrictStr]], Field(description="Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `id, dag_id, state, job_type, start_date, end_date, latest_heartbeat, executor_class, hostname, unixname`")] = None,
        job_state: Optional[StrictStr] = None,
        job_type: Optional[StrictStr] = None,
        hostname: Optional[StrictStr] = None,
        executor_class: Optional[StrictStr] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[JobCollectionResponse]:
        """Get Jobs

        Get all jobs.

        :param is_alive:
        :type is_alive: bool
        :param start_date_gte:
        :type start_date_gte: datetime
        :param start_date_gt:
        :type start_date_gt: datetime
        :param start_date_lte:
        :type start_date_lte: datetime
        :param start_date_lt:
        :type start_date_lt: datetime
        :param end_date_gte:
        :type end_date_gte: datetime
        :param end_date_gt:
        :type end_date_gt: datetime
        :param end_date_lte:
        :type end_date_lte: datetime
        :param end_date_lt:
        :type end_date_lt: datetime
        :param limit:
        :type limit: int
        :param offset:
        :type offset: int
        :param order_by: Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `id, dag_id, state, job_type, start_date, end_date, latest_heartbeat, executor_class, hostname, unixname`
        :type order_by: List[str]
        :param job_state:
        :type job_state: str
        :param job_type:
        :type job_type: str
        :param hostname:
        :type hostname: str
        :param executor_class:
        :type executor_class: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._get_jobs_serialize(
            is_alive=is_alive,
            start_date_gte=start_date_gte,
            start_date_gt=start_date_gt,
            start_date_lte=start_date_lte,
            start_date_lt=start_date_lt,
            end_date_gte=end_date_gte,
            end_date_gt=end_date_gt,
            end_date_lte=end_date_lte,
            end_date_lt=end_date_lt,
            limit=limit,
            offset=offset,
            order_by=order_by,
            job_state=job_state,
            job_type=job_type,
            hostname=hostname,
            executor_class=executor_class,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "JobCollectionResponse",
            '400': "HTTPExceptionResponse",
            '401': "HTTPExceptionResponse",
            '403': "HTTPExceptionResponse",
            '422': "HTTPValidationError",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    @validate_call
    def get_jobs_without_preload_content(
        self,
        is_alive: Optional[StrictBool] = None,
        start_date_gte: Optional[datetime] = None,
        start_date_gt: Optional[datetime] = None,
        start_date_lte: Optional[datetime] = None,
        start_date_lt: Optional[datetime] = None,
        end_date_gte: Optional[datetime] = None,
        end_date_gt: Optional[datetime] = None,
        end_date_lte: Optional[datetime] = None,
        end_date_lt: Optional[datetime] = None,
        limit: Optional[Annotated[int, Field(strict=True, ge=0)]] = None,
        offset: Optional[Annotated[int, Field(strict=True, ge=0)]] = None,
        order_by: Annotated[Optional[List[StrictStr]], Field(description="Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `id, dag_id, state, job_type, start_date, end_date, latest_heartbeat, executor_class, hostname, unixname`")] = None,
        job_state: Optional[StrictStr] = None,
        job_type: Optional[StrictStr] = None,
        hostname: Optional[StrictStr] = None,
        executor_class: Optional[StrictStr] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Get Jobs

        Get all jobs.

        :param is_alive:
        :type is_alive: bool
        :param start_date_gte:
        :type start_date_gte: datetime
        :param start_date_gt:
        :type start_date_gt: datetime
        :param start_date_lte:
        :type start_date_lte: datetime
        :param start_date_lt:
        :type start_date_lt: datetime
        :param end_date_gte:
        :type end_date_gte: datetime
        :param end_date_gt:
        :type end_date_gt: datetime
        :param end_date_lte:
        :type end_date_lte: datetime
        :param end_date_lt:
        :type end_date_lt: datetime
        :param limit:
        :type limit: int
        :param offset:
        :type offset: int
        :param order_by: Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `id, dag_id, state, job_type, start_date, end_date, latest_heartbeat, executor_class, hostname, unixname`
        :type order_by: List[str]
        :param job_state:
        :type job_state: str
        :param job_type:
        :type job_type: str
        :param hostname:
        :type hostname: str
        :param executor_class:
        :type executor_class: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._get_jobs_serialize(
            is_alive=is_alive,
            start_date_gte=start_date_gte,
            start_date_gt=start_date_gt,
            start_date_lte=start_date_lte,
            start_date_lt=start_date_lt,
            end_date_gte=end_date_gte,
            end_date_gt=end_date_gt,
            end_date_lte=end_date_lte,
            end_date_lt=end_date_lt,
            limit=limit,
            offset=offset,
            order_by=order_by,
            job_state=job_state,
            job_type=job_type,
            hostname=hostname,
            executor_class=executor_class,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "JobCollectionResponse",
            '400': "HTTPExceptionResponse",
            '401': "HTTPExceptionResponse",
            '403': "HTTPExceptionResponse",
            '422': "HTTPValidationError",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        return response_data.response


    def _get_jobs_serialize(
        self,
        is_alive,
        start_date_gte,
        start_date_gt,
        start_date_lte,
        start_date_lt,
        end_date_gte,
        end_date_gt,
        end_date_lte,
        end_date_lt,
        limit,
        offset,
        order_by,
        job_state,
        job_type,
        hostname,
        executor_class,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {
            'order_by': 'multi',
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        # process the query parameters
        if is_alive is not None:
            
            _query_params.append(('is_alive', is_alive))
            
        if start_date_gte is not None:
            if isinstance(start_date_gte, datetime):
                _query_params.append(
                    (
                        'start_date_gte',
                        start_date_gte.strftime(
                            self.api_client.configuration.datetime_format
                        )
                    )
                )
            else:
                _query_params.append(('start_date_gte', start_date_gte))
            
        if start_date_gt is not None:
            if isinstance(start_date_gt, datetime):
                _query_params.append(
                    (
                        'start_date_gt',
                        start_date_gt.strftime(
                            self.api_client.configuration.datetime_format
                        )
                    )
                )
            else:
                _query_params.append(('start_date_gt', start_date_gt))
            
        if start_date_lte is not None:
            if isinstance(start_date_lte, datetime):
                _query_params.append(
                    (
                        'start_date_lte',
                        start_date_lte.strftime(
                            self.api_client.configuration.datetime_format
                        )
                    )
                )
            else:
                _query_params.append(('start_date_lte', start_date_lte))
            
        if start_date_lt is not None:
            if isinstance(start_date_lt, datetime):
                _query_params.append(
                    (
                        'start_date_lt',
                        start_date_lt.strftime(
                            self.api_client.configuration.datetime_format
                        )
                    )
                )
            else:
                _query_params.append(('start_date_lt', start_date_lt))
            
        if end_date_gte is not None:
            if isinstance(end_date_gte, datetime):
                _query_params.append(
                    (
                        'end_date_gte',
                        end_date_gte.strftime(
                            self.api_client.configuration.datetime_format
                        )
                    )
                )
            else:
                _query_params.append(('end_date_gte', end_date_gte))
            
        if end_date_gt is not None:
            if isinstance(end_date_gt, datetime):
                _query_params.append(
                    (
                        'end_date_gt',
                        end_date_gt.strftime(
                            self.api_client.configuration.datetime_format
                        )
                    )
                )
            else:
                _query_params.append(('end_date_gt', end_date_gt))
            
        if end_date_lte is not None:
            if isinstance(end_date_lte, datetime):
                _query_params.append(
                    (
                        'end_date_lte',
                        end_date_lte.strftime(
                            self.api_client.configuration.datetime_format
                        )
                    )
                )
            else:
                _query_params.append(('end_date_lte', end_date_lte))
            
        if end_date_lt is not None:
            if isinstance(end_date_lt, datetime):
                _query_params.append(
                    (
                        'end_date_lt',
                        end_date_lt.strftime(
                            self.api_client.configuration.datetime_format
                        )
                    )
                )
            else:
                _query_params.append(('end_date_lt', end_date_lt))
            
        if limit is not None:
            
            _query_params.append(('limit', limit))
            
        if offset is not None:
            
            _query_params.append(('offset', offset))
            
        if order_by is not None:
            
            _query_params.append(('order_by', order_by))
            
        if job_state is not None:
            
            _query_params.append(('job_state', job_state))
            
        if job_type is not None:
            
            _query_params.append(('job_type', job_type))
            
        if hostname is not None:
            
            _query_params.append(('hostname', hostname))
            
        if executor_class is not None:
            
            _query_params.append(('executor_class', executor_class))
            
        # process the header parameters
        # process the form parameters
        # process the body parameter


        # set the HTTP header `Accept`
        if 'Accept' not in _header_params:
            _header_params['Accept'] = self.api_client.select_header_accept(
                [
                    'application/json'
                ]
            )


        # authentication setting
        _auth_settings: List[str] = [
            'OAuth2PasswordBearer', 
            'HTTPBearer'
        ]

        return self.api_client.param_serialize(
            method='GET',
            resource_path='/api/v2/jobs',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth
        )


