# coding: utf-8

"""
ME TT DataPortal Data Portal API

ME TT DataPortal Data Portal APIs to fetch Gut Microbes Genomes / Genes information.

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

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

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

from pydantic import StrictBool
from mett_dataportal_sdk.models.paginated_response_schema import PaginatedResponseSchema
from mett_dataportal_sdk.models.success_response_schema import SuccessResponseSchema

from mett_dataportal_sdk.api_client import ApiClient, RequestSerialized
from mett_dataportal_sdk.api_response import ApiResponse
from mett_dataportal_sdk.rest import RESTResponseType


class OperonsApi:
    """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 dataportal_api_interactions_operon_endpoints_get_operon_by_id(
        self,
        operon_id: StrictStr,
        _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,
    ) -> SuccessResponseSchema:
        """Get operon by ID

        Get detailed information about a specific operon

        :param operon_id: (required)
        :type operon_id: 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._dataportal_api_interactions_operon_endpoints_get_operon_by_id_serialize(
            operon_id=operon_id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "SuccessResponseSchema",
        }
        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 dataportal_api_interactions_operon_endpoints_get_operon_by_id_with_http_info(
        self,
        operon_id: StrictStr,
        _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[SuccessResponseSchema]:
        """Get operon by ID

        Get detailed information about a specific operon

        :param operon_id: (required)
        :type operon_id: 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._dataportal_api_interactions_operon_endpoints_get_operon_by_id_serialize(
            operon_id=operon_id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "SuccessResponseSchema",
        }
        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 dataportal_api_interactions_operon_endpoints_get_operon_by_id_without_preload_content(
        self,
        operon_id: StrictStr,
        _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 operon by ID

        Get detailed information about a specific operon

        :param operon_id: (required)
        :type operon_id: 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._dataportal_api_interactions_operon_endpoints_get_operon_by_id_serialize(
            operon_id=operon_id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "SuccessResponseSchema",
        }
        response_data = self.api_client.call_api(
            *_param, _request_timeout=_request_timeout
        )
        return response_data.response

    def _dataportal_api_interactions_operon_endpoints_get_operon_by_id_serialize(
        self,
        operon_id,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:
        _host = None

        _collection_formats: Dict[str, str] = {}

        _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
        if operon_id is not None:
            _path_params["operon_id"] = operon_id
        # process the query parameters
        # 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] = ["RoleBasedJWTAuth"]

        return self.api_client.param_serialize(
            method="GET",
            resource_path="/api/operons/{operon_id}",
            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,
        )

    @validate_call
    def dataportal_api_interactions_operon_endpoints_search_operons(
        self,
        locus_tag: Annotated[
            Optional[StrictStr],
            Field(description="Filter by gene (operons containing this gene)"),
        ] = None,
        operon_id: Annotated[
            Optional[StrictStr], Field(description="Filter by operon ID")
        ] = None,
        species_acronym: Annotated[
            Optional[StrictStr], Field(description="Filter by species")
        ] = None,
        isolate_name: Annotated[
            Optional[StrictStr], Field(description="Filter by isolate")
        ] = None,
        has_tss: Annotated[
            Optional[StrictBool], Field(description="Filter by presence of TSS")
        ] = None,
        has_terminator: Annotated[
            Optional[StrictBool], Field(description="Filter by presence of terminator")
        ] = None,
        min_gene_count: Annotated[
            Optional[Annotated[int, Field(strict=True, ge=2)]],
            Field(description="Minimum number of genes"),
        ] = None,
        page: Annotated[
            Optional[Annotated[int, Field(strict=True, ge=1)]],
            Field(description="Page number"),
        ] = None,
        per_page: Annotated[
            Optional[Annotated[int, Field(le=10000, strict=True, ge=1)]],
            Field(description="Results per page"),
        ] = 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,
    ) -> PaginatedResponseSchema:
        """Search operons with filters

        Search for operons with various filters and pagination

        :param locus_tag: Filter by gene (operons containing this gene)
        :type locus_tag: str
        :param operon_id: Filter by operon ID
        :type operon_id: str
        :param species_acronym: Filter by species
        :type species_acronym: str
        :param isolate_name: Filter by isolate
        :type isolate_name: str
        :param has_tss: Filter by presence of TSS
        :type has_tss: bool
        :param has_terminator: Filter by presence of terminator
        :type has_terminator: bool
        :param min_gene_count: Minimum number of genes
        :type min_gene_count: int
        :param page: Page number
        :type page: int
        :param per_page: Results per page
        :type per_page: int
        :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._dataportal_api_interactions_operon_endpoints_search_operons_serialize(
                locus_tag=locus_tag,
                operon_id=operon_id,
                species_acronym=species_acronym,
                isolate_name=isolate_name,
                has_tss=has_tss,
                has_terminator=has_terminator,
                min_gene_count=min_gene_count,
                page=page,
                per_page=per_page,
                _request_auth=_request_auth,
                _content_type=_content_type,
                _headers=_headers,
                _host_index=_host_index,
            )
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "PaginatedResponseSchema",
        }
        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 dataportal_api_interactions_operon_endpoints_search_operons_with_http_info(
        self,
        locus_tag: Annotated[
            Optional[StrictStr],
            Field(description="Filter by gene (operons containing this gene)"),
        ] = None,
        operon_id: Annotated[
            Optional[StrictStr], Field(description="Filter by operon ID")
        ] = None,
        species_acronym: Annotated[
            Optional[StrictStr], Field(description="Filter by species")
        ] = None,
        isolate_name: Annotated[
            Optional[StrictStr], Field(description="Filter by isolate")
        ] = None,
        has_tss: Annotated[
            Optional[StrictBool], Field(description="Filter by presence of TSS")
        ] = None,
        has_terminator: Annotated[
            Optional[StrictBool], Field(description="Filter by presence of terminator")
        ] = None,
        min_gene_count: Annotated[
            Optional[Annotated[int, Field(strict=True, ge=2)]],
            Field(description="Minimum number of genes"),
        ] = None,
        page: Annotated[
            Optional[Annotated[int, Field(strict=True, ge=1)]],
            Field(description="Page number"),
        ] = None,
        per_page: Annotated[
            Optional[Annotated[int, Field(le=10000, strict=True, ge=1)]],
            Field(description="Results per page"),
        ] = 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[PaginatedResponseSchema]:
        """Search operons with filters

        Search for operons with various filters and pagination

        :param locus_tag: Filter by gene (operons containing this gene)
        :type locus_tag: str
        :param operon_id: Filter by operon ID
        :type operon_id: str
        :param species_acronym: Filter by species
        :type species_acronym: str
        :param isolate_name: Filter by isolate
        :type isolate_name: str
        :param has_tss: Filter by presence of TSS
        :type has_tss: bool
        :param has_terminator: Filter by presence of terminator
        :type has_terminator: bool
        :param min_gene_count: Minimum number of genes
        :type min_gene_count: int
        :param page: Page number
        :type page: int
        :param per_page: Results per page
        :type per_page: int
        :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._dataportal_api_interactions_operon_endpoints_search_operons_serialize(
                locus_tag=locus_tag,
                operon_id=operon_id,
                species_acronym=species_acronym,
                isolate_name=isolate_name,
                has_tss=has_tss,
                has_terminator=has_terminator,
                min_gene_count=min_gene_count,
                page=page,
                per_page=per_page,
                _request_auth=_request_auth,
                _content_type=_content_type,
                _headers=_headers,
                _host_index=_host_index,
            )
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "PaginatedResponseSchema",
        }
        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 dataportal_api_interactions_operon_endpoints_search_operons_without_preload_content(
        self,
        locus_tag: Annotated[
            Optional[StrictStr],
            Field(description="Filter by gene (operons containing this gene)"),
        ] = None,
        operon_id: Annotated[
            Optional[StrictStr], Field(description="Filter by operon ID")
        ] = None,
        species_acronym: Annotated[
            Optional[StrictStr], Field(description="Filter by species")
        ] = None,
        isolate_name: Annotated[
            Optional[StrictStr], Field(description="Filter by isolate")
        ] = None,
        has_tss: Annotated[
            Optional[StrictBool], Field(description="Filter by presence of TSS")
        ] = None,
        has_terminator: Annotated[
            Optional[StrictBool], Field(description="Filter by presence of terminator")
        ] = None,
        min_gene_count: Annotated[
            Optional[Annotated[int, Field(strict=True, ge=2)]],
            Field(description="Minimum number of genes"),
        ] = None,
        page: Annotated[
            Optional[Annotated[int, Field(strict=True, ge=1)]],
            Field(description="Page number"),
        ] = None,
        per_page: Annotated[
            Optional[Annotated[int, Field(le=10000, strict=True, ge=1)]],
            Field(description="Results per page"),
        ] = 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:
        """Search operons with filters

        Search for operons with various filters and pagination

        :param locus_tag: Filter by gene (operons containing this gene)
        :type locus_tag: str
        :param operon_id: Filter by operon ID
        :type operon_id: str
        :param species_acronym: Filter by species
        :type species_acronym: str
        :param isolate_name: Filter by isolate
        :type isolate_name: str
        :param has_tss: Filter by presence of TSS
        :type has_tss: bool
        :param has_terminator: Filter by presence of terminator
        :type has_terminator: bool
        :param min_gene_count: Minimum number of genes
        :type min_gene_count: int
        :param page: Page number
        :type page: int
        :param per_page: Results per page
        :type per_page: int
        :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._dataportal_api_interactions_operon_endpoints_search_operons_serialize(
                locus_tag=locus_tag,
                operon_id=operon_id,
                species_acronym=species_acronym,
                isolate_name=isolate_name,
                has_tss=has_tss,
                has_terminator=has_terminator,
                min_gene_count=min_gene_count,
                page=page,
                per_page=per_page,
                _request_auth=_request_auth,
                _content_type=_content_type,
                _headers=_headers,
                _host_index=_host_index,
            )
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "PaginatedResponseSchema",
        }
        response_data = self.api_client.call_api(
            *_param, _request_timeout=_request_timeout
        )
        return response_data.response

    def _dataportal_api_interactions_operon_endpoints_search_operons_serialize(
        self,
        locus_tag,
        operon_id,
        species_acronym,
        isolate_name,
        has_tss,
        has_terminator,
        min_gene_count,
        page,
        per_page,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:
        _host = None

        _collection_formats: Dict[str, str] = {}

        _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 locus_tag is not None:
            _query_params.append(("locus_tag", locus_tag))

        if operon_id is not None:
            _query_params.append(("operon_id", operon_id))

        if species_acronym is not None:
            _query_params.append(("species_acronym", species_acronym))

        if isolate_name is not None:
            _query_params.append(("isolate_name", isolate_name))

        if has_tss is not None:
            _query_params.append(("has_tss", has_tss))

        if has_terminator is not None:
            _query_params.append(("has_terminator", has_terminator))

        if min_gene_count is not None:
            _query_params.append(("min_gene_count", min_gene_count))

        if page is not None:
            _query_params.append(("page", page))

        if per_page is not None:
            _query_params.append(("per_page", per_page))

        # 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] = ["RoleBasedJWTAuth"]

        return self.api_client.param_serialize(
            method="GET",
            resource_path="/api/operons/search",
            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,
        )
