# coding: utf-8

"""
    AI Stats Gateway API

    Programmatic access to the AI Stats AI Gateway. All endpoints forward requests to the best available provider for the specified model, and return normalised responses with clear structured metadata.

    The version of the OpenAPI document: 0.1.0
    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 pydantic import Field, StrictBool
from typing import Any, Optional
from typing_extensions import Annotated
from ai_stats_generated.models.model_list_response import ModelListResponse

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


class ModelsApi:
    """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 models_get(
        self,
        provider: Annotated[Optional[Any], Field(description="Filter results to models served by one or more provider identifiers.")] = None,
        limit: Annotated[Optional[Annotated[int, Field(le=250, strict=True, ge=1)]], Field(description="Maximum number of models to return (default 50).")] = None,
        offset: Annotated[Optional[Annotated[int, Field(strict=True, ge=0)]], Field(description="Number of models to skip before starting the page.")] = None,
        organisation: Annotated[Optional[Any], Field(description="Restrict results to models associated with one or more organisation identifiers.")] = None,
        include_endpoints: Annotated[Optional[Any], Field(description="Only return models that support at least one of the specified gateway endpoints.")] = None,
        exclude_endpoints: Annotated[Optional[Any], Field(description="Exclude models that support any of the specified gateway endpoints.")] = None,
        input_types: Annotated[Optional[Any], Field(description="Only return models that advertise support for at least one of the requested input content types.")] = None,
        output_types: Annotated[Optional[Any], Field(description="Only return models that advertise support for at least one of the requested output content types.")] = None,
        include_rumoured: Annotated[Optional[StrictBool], Field(description="Whether to include models marked as rumoured in the response (default true).")] = None,
        include_deprecated: Annotated[Optional[StrictBool], Field(description="Whether to include models marked as deprecated in the response (default true).")] = None,
        include_retired: Annotated[Optional[StrictBool], Field(description="Whether to include models marked as retired in the response (default true).")] = 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,
    ) -> ModelListResponse:
        """List all gateway models

        Returns a paginated catalogue of models with provider mappings, aliases, and endpoint support. Results are sorted by release date (falling back to announcement date) in descending order.

        :param provider: Filter results to models served by one or more provider identifiers.
        :type provider: ModelsGetProviderParameter
        :param limit: Maximum number of models to return (default 50).
        :type limit: int
        :param offset: Number of models to skip before starting the page.
        :type offset: int
        :param organisation: Restrict results to models associated with one or more organisation identifiers.
        :type organisation: ModelsGetOrganisationParameter
        :param include_endpoints: Only return models that support at least one of the specified gateway endpoints.
        :type include_endpoints: ModelsGetIncludeEndpointsParameter
        :param exclude_endpoints: Exclude models that support any of the specified gateway endpoints.
        :type exclude_endpoints: ModelsGetIncludeEndpointsParameter
        :param input_types: Only return models that advertise support for at least one of the requested input content types.
        :type input_types: ModelsGetProviderParameter
        :param output_types: Only return models that advertise support for at least one of the requested output content types.
        :type output_types: ModelsGetProviderParameter
        :param include_rumoured: Whether to include models marked as rumoured in the response (default true).
        :type include_rumoured: bool
        :param include_deprecated: Whether to include models marked as deprecated in the response (default true).
        :type include_deprecated: bool
        :param include_retired: Whether to include models marked as retired in the response (default true).
        :type include_retired: bool
        :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._models_get_serialize(
            provider=provider,
            limit=limit,
            offset=offset,
            organisation=organisation,
            include_endpoints=include_endpoints,
            exclude_endpoints=exclude_endpoints,
            input_types=input_types,
            output_types=output_types,
            include_rumoured=include_rumoured,
            include_deprecated=include_deprecated,
            include_retired=include_retired,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "ModelListResponse",
            '401': "GatewayError",
            '429': "GatewayError",
            '500': "GatewayError",
        }
        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 models_get_with_http_info(
        self,
        provider: Annotated[Optional[Any], Field(description="Filter results to models served by one or more provider identifiers.")] = None,
        limit: Annotated[Optional[Annotated[int, Field(le=250, strict=True, ge=1)]], Field(description="Maximum number of models to return (default 50).")] = None,
        offset: Annotated[Optional[Annotated[int, Field(strict=True, ge=0)]], Field(description="Number of models to skip before starting the page.")] = None,
        organisation: Annotated[Optional[Any], Field(description="Restrict results to models associated with one or more organisation identifiers.")] = None,
        include_endpoints: Annotated[Optional[Any], Field(description="Only return models that support at least one of the specified gateway endpoints.")] = None,
        exclude_endpoints: Annotated[Optional[Any], Field(description="Exclude models that support any of the specified gateway endpoints.")] = None,
        input_types: Annotated[Optional[Any], Field(description="Only return models that advertise support for at least one of the requested input content types.")] = None,
        output_types: Annotated[Optional[Any], Field(description="Only return models that advertise support for at least one of the requested output content types.")] = None,
        include_rumoured: Annotated[Optional[StrictBool], Field(description="Whether to include models marked as rumoured in the response (default true).")] = None,
        include_deprecated: Annotated[Optional[StrictBool], Field(description="Whether to include models marked as deprecated in the response (default true).")] = None,
        include_retired: Annotated[Optional[StrictBool], Field(description="Whether to include models marked as retired in the response (default true).")] = 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[ModelListResponse]:
        """List all gateway models

        Returns a paginated catalogue of models with provider mappings, aliases, and endpoint support. Results are sorted by release date (falling back to announcement date) in descending order.

        :param provider: Filter results to models served by one or more provider identifiers.
        :type provider: ModelsGetProviderParameter
        :param limit: Maximum number of models to return (default 50).
        :type limit: int
        :param offset: Number of models to skip before starting the page.
        :type offset: int
        :param organisation: Restrict results to models associated with one or more organisation identifiers.
        :type organisation: ModelsGetOrganisationParameter
        :param include_endpoints: Only return models that support at least one of the specified gateway endpoints.
        :type include_endpoints: ModelsGetIncludeEndpointsParameter
        :param exclude_endpoints: Exclude models that support any of the specified gateway endpoints.
        :type exclude_endpoints: ModelsGetIncludeEndpointsParameter
        :param input_types: Only return models that advertise support for at least one of the requested input content types.
        :type input_types: ModelsGetProviderParameter
        :param output_types: Only return models that advertise support for at least one of the requested output content types.
        :type output_types: ModelsGetProviderParameter
        :param include_rumoured: Whether to include models marked as rumoured in the response (default true).
        :type include_rumoured: bool
        :param include_deprecated: Whether to include models marked as deprecated in the response (default true).
        :type include_deprecated: bool
        :param include_retired: Whether to include models marked as retired in the response (default true).
        :type include_retired: bool
        :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._models_get_serialize(
            provider=provider,
            limit=limit,
            offset=offset,
            organisation=organisation,
            include_endpoints=include_endpoints,
            exclude_endpoints=exclude_endpoints,
            input_types=input_types,
            output_types=output_types,
            include_rumoured=include_rumoured,
            include_deprecated=include_deprecated,
            include_retired=include_retired,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "ModelListResponse",
            '401': "GatewayError",
            '429': "GatewayError",
            '500': "GatewayError",
        }
        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 models_get_without_preload_content(
        self,
        provider: Annotated[Optional[Any], Field(description="Filter results to models served by one or more provider identifiers.")] = None,
        limit: Annotated[Optional[Annotated[int, Field(le=250, strict=True, ge=1)]], Field(description="Maximum number of models to return (default 50).")] = None,
        offset: Annotated[Optional[Annotated[int, Field(strict=True, ge=0)]], Field(description="Number of models to skip before starting the page.")] = None,
        organisation: Annotated[Optional[Any], Field(description="Restrict results to models associated with one or more organisation identifiers.")] = None,
        include_endpoints: Annotated[Optional[Any], Field(description="Only return models that support at least one of the specified gateway endpoints.")] = None,
        exclude_endpoints: Annotated[Optional[Any], Field(description="Exclude models that support any of the specified gateway endpoints.")] = None,
        input_types: Annotated[Optional[Any], Field(description="Only return models that advertise support for at least one of the requested input content types.")] = None,
        output_types: Annotated[Optional[Any], Field(description="Only return models that advertise support for at least one of the requested output content types.")] = None,
        include_rumoured: Annotated[Optional[StrictBool], Field(description="Whether to include models marked as rumoured in the response (default true).")] = None,
        include_deprecated: Annotated[Optional[StrictBool], Field(description="Whether to include models marked as deprecated in the response (default true).")] = None,
        include_retired: Annotated[Optional[StrictBool], Field(description="Whether to include models marked as retired in the response (default true).")] = 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:
        """List all gateway models

        Returns a paginated catalogue of models with provider mappings, aliases, and endpoint support. Results are sorted by release date (falling back to announcement date) in descending order.

        :param provider: Filter results to models served by one or more provider identifiers.
        :type provider: ModelsGetProviderParameter
        :param limit: Maximum number of models to return (default 50).
        :type limit: int
        :param offset: Number of models to skip before starting the page.
        :type offset: int
        :param organisation: Restrict results to models associated with one or more organisation identifiers.
        :type organisation: ModelsGetOrganisationParameter
        :param include_endpoints: Only return models that support at least one of the specified gateway endpoints.
        :type include_endpoints: ModelsGetIncludeEndpointsParameter
        :param exclude_endpoints: Exclude models that support any of the specified gateway endpoints.
        :type exclude_endpoints: ModelsGetIncludeEndpointsParameter
        :param input_types: Only return models that advertise support for at least one of the requested input content types.
        :type input_types: ModelsGetProviderParameter
        :param output_types: Only return models that advertise support for at least one of the requested output content types.
        :type output_types: ModelsGetProviderParameter
        :param include_rumoured: Whether to include models marked as rumoured in the response (default true).
        :type include_rumoured: bool
        :param include_deprecated: Whether to include models marked as deprecated in the response (default true).
        :type include_deprecated: bool
        :param include_retired: Whether to include models marked as retired in the response (default true).
        :type include_retired: bool
        :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._models_get_serialize(
            provider=provider,
            limit=limit,
            offset=offset,
            organisation=organisation,
            include_endpoints=include_endpoints,
            exclude_endpoints=exclude_endpoints,
            input_types=input_types,
            output_types=output_types,
            include_rumoured=include_rumoured,
            include_deprecated=include_deprecated,
            include_retired=include_retired,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "ModelListResponse",
            '401': "GatewayError",
            '429': "GatewayError",
            '500': "GatewayError",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        return response_data.response


    def _models_get_serialize(
        self,
        provider,
        limit,
        offset,
        organisation,
        include_endpoints,
        exclude_endpoints,
        input_types,
        output_types,
        include_rumoured,
        include_deprecated,
        include_retired,
        _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 provider is not None:
            
            _query_params.append(('provider', provider))
            
        if limit is not None:
            
            _query_params.append(('limit', limit))
            
        if offset is not None:
            
            _query_params.append(('offset', offset))
            
        if organisation is not None:
            
            _query_params.append(('organisation', organisation))
            
        if include_endpoints is not None:
            
            _query_params.append(('include_endpoints', include_endpoints))
            
        if exclude_endpoints is not None:
            
            _query_params.append(('exclude_endpoints', exclude_endpoints))
            
        if input_types is not None:
            
            _query_params.append(('input_types', input_types))
            
        if output_types is not None:
            
            _query_params.append(('output_types', output_types))
            
        if include_rumoured is not None:
            
            _query_params.append(('include_rumoured', include_rumoured))
            
        if include_deprecated is not None:
            
            _query_params.append(('include_deprecated', include_deprecated))
            
        if include_retired is not None:
            
            _query_params.append(('include_retired', include_retired))
            
        # 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] = [
            'GatewayAuth'
        ]

        return self.api_client.param_serialize(
            method='GET',
            resource_path='/models',
            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
        )


