# coding: utf-8

"""


    Generated by: https://openapi-generator.tech
"""

from dataclasses import dataclass
import typing_extensions
import urllib3
from urllib3._collections import HTTPHeaderDict

from banyanclient import api_client, exceptions
from datetime import date, datetime  # noqa: F401
import decimal  # noqa: F401
import functools  # noqa: F401
import io  # noqa: F401
import re  # noqa: F401
import typing  # noqa: F401
import typing_extensions  # noqa: F401
import uuid  # noqa: F401

import frozendict  # noqa: F401

from banyanclient import schemas  # noqa: F401

from . import path

# query params
ServiceIDSchema = schemas.StrSchema
DefaultServicesSchema = schemas.BoolSchema
ServiceNameSchema = schemas.StrSchema
FriendlyNameSchema = schemas.StrSchema
RequestRequiredQueryParams = typing_extensions.TypedDict(
    'RequestRequiredQueryParams',
    {
    }
)
RequestOptionalQueryParams = typing_extensions.TypedDict(
    'RequestOptionalQueryParams',
    {
        'ServiceID': typing.Union[ServiceIDSchema, str, ],
        'DefaultServices': typing.Union[DefaultServicesSchema, bool, ],
        'ServiceName': typing.Union[ServiceNameSchema, str, ],
        'FriendlyName': typing.Union[FriendlyNameSchema, str, ],
    },
    total=False
)


class RequestQueryParams(RequestRequiredQueryParams, RequestOptionalQueryParams):
    pass


request_query_service_id = api_client.QueryParameter(
    name="ServiceID",
    style=api_client.ParameterStyle.FORM,
    schema=ServiceIDSchema,
    explode=True,
)
request_query_default_services = api_client.QueryParameter(
    name="DefaultServices",
    style=api_client.ParameterStyle.FORM,
    schema=DefaultServicesSchema,
    explode=True,
)
request_query_service_name = api_client.QueryParameter(
    name="ServiceName",
    style=api_client.ParameterStyle.FORM,
    schema=ServiceNameSchema,
    explode=True,
)
request_query_friendly_name = api_client.QueryParameter(
    name="FriendlyName",
    style=api_client.ParameterStyle.FORM,
    schema=FriendlyNameSchema,
    explode=True,
)
_auth = [
    'bearerAuthToken',
]


class SchemaFor200ResponseBodyApplicationJson(
    schemas.ListSchema
):


    class MetaOapg:
        
        
        class items(
            schemas.DictSchema
        ):
        
        
            class MetaOapg:
                
                class properties:
                    ServiceID = schemas.StrSchema
                    ServiceName = schemas.StrSchema
                    FriendlyName = schemas.StrSchema
                    ClusterName = schemas.StrSchema
                    ServiceType = schemas.StrSchema
                    ServiceDiscovery = schemas.StrSchema
                    ServiceVersion = schemas.IntSchema
                    Description = schemas.StrSchema
                    CreatedBy = schemas.StrSchema
                    CreatedAt = schemas.IntSchema
                    LastUpdatedBy = schemas.StrSchema
                    LastUpdatedAt = schemas.IntSchema
                    DeletedBy = schemas.StrSchema
                    DeletedAt = schemas.IntSchema
                    External = schemas.StrSchema
                    OIDCEnabled = schemas.StrSchema
                    OIDCClientSpec = schemas.StrSchema
                    ServiceSpec = schemas.StrSchema
                    UserFacing = schemas.StrSchema
                    Protocol = schemas.StrSchema
                    Domain = schemas.StrSchema
                    Port = schemas.IntSchema
                    Enabled = schemas.StrSchema
                    IsDefault = schemas.BoolSchema
                    __annotations__ = {
                        "ServiceID": ServiceID,
                        "ServiceName": ServiceName,
                        "FriendlyName": FriendlyName,
                        "ClusterName": ClusterName,
                        "ServiceType": ServiceType,
                        "ServiceDiscovery": ServiceDiscovery,
                        "ServiceVersion": ServiceVersion,
                        "Description": Description,
                        "CreatedBy": CreatedBy,
                        "CreatedAt": CreatedAt,
                        "LastUpdatedBy": LastUpdatedBy,
                        "LastUpdatedAt": LastUpdatedAt,
                        "DeletedBy": DeletedBy,
                        "DeletedAt": DeletedAt,
                        "External": External,
                        "OIDCEnabled": OIDCEnabled,
                        "OIDCClientSpec": OIDCClientSpec,
                        "ServiceSpec": ServiceSpec,
                        "UserFacing": UserFacing,
                        "Protocol": Protocol,
                        "Domain": Domain,
                        "Port": Port,
                        "Enabled": Enabled,
                        "IsDefault": IsDefault,
                    }
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["ServiceID"]) -> MetaOapg.properties.ServiceID: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["ServiceName"]) -> MetaOapg.properties.ServiceName: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["FriendlyName"]) -> MetaOapg.properties.FriendlyName: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["ClusterName"]) -> MetaOapg.properties.ClusterName: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["ServiceType"]) -> MetaOapg.properties.ServiceType: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["ServiceDiscovery"]) -> MetaOapg.properties.ServiceDiscovery: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["ServiceVersion"]) -> MetaOapg.properties.ServiceVersion: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["Description"]) -> MetaOapg.properties.Description: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["CreatedBy"]) -> MetaOapg.properties.CreatedBy: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["CreatedAt"]) -> MetaOapg.properties.CreatedAt: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["LastUpdatedBy"]) -> MetaOapg.properties.LastUpdatedBy: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["LastUpdatedAt"]) -> MetaOapg.properties.LastUpdatedAt: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["DeletedBy"]) -> MetaOapg.properties.DeletedBy: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["DeletedAt"]) -> MetaOapg.properties.DeletedAt: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["External"]) -> MetaOapg.properties.External: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["OIDCEnabled"]) -> MetaOapg.properties.OIDCEnabled: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["OIDCClientSpec"]) -> MetaOapg.properties.OIDCClientSpec: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["ServiceSpec"]) -> MetaOapg.properties.ServiceSpec: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["UserFacing"]) -> MetaOapg.properties.UserFacing: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["Protocol"]) -> MetaOapg.properties.Protocol: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["Domain"]) -> MetaOapg.properties.Domain: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["Port"]) -> MetaOapg.properties.Port: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["Enabled"]) -> MetaOapg.properties.Enabled: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["IsDefault"]) -> MetaOapg.properties.IsDefault: ...
            
            @typing.overload
            def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ...
            
            def __getitem__(self, name: typing.Union[typing_extensions.Literal["ServiceID", "ServiceName", "FriendlyName", "ClusterName", "ServiceType", "ServiceDiscovery", "ServiceVersion", "Description", "CreatedBy", "CreatedAt", "LastUpdatedBy", "LastUpdatedAt", "DeletedBy", "DeletedAt", "External", "OIDCEnabled", "OIDCClientSpec", "ServiceSpec", "UserFacing", "Protocol", "Domain", "Port", "Enabled", "IsDefault", ], str]):
                # dict_instance[name] accessor
                return super().__getitem__(name)
            
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["ServiceID"]) -> typing.Union[MetaOapg.properties.ServiceID, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["ServiceName"]) -> typing.Union[MetaOapg.properties.ServiceName, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["FriendlyName"]) -> typing.Union[MetaOapg.properties.FriendlyName, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["ClusterName"]) -> typing.Union[MetaOapg.properties.ClusterName, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["ServiceType"]) -> typing.Union[MetaOapg.properties.ServiceType, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["ServiceDiscovery"]) -> typing.Union[MetaOapg.properties.ServiceDiscovery, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["ServiceVersion"]) -> typing.Union[MetaOapg.properties.ServiceVersion, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["Description"]) -> typing.Union[MetaOapg.properties.Description, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["CreatedBy"]) -> typing.Union[MetaOapg.properties.CreatedBy, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["CreatedAt"]) -> typing.Union[MetaOapg.properties.CreatedAt, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["LastUpdatedBy"]) -> typing.Union[MetaOapg.properties.LastUpdatedBy, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["LastUpdatedAt"]) -> typing.Union[MetaOapg.properties.LastUpdatedAt, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["DeletedBy"]) -> typing.Union[MetaOapg.properties.DeletedBy, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["DeletedAt"]) -> typing.Union[MetaOapg.properties.DeletedAt, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["External"]) -> typing.Union[MetaOapg.properties.External, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["OIDCEnabled"]) -> typing.Union[MetaOapg.properties.OIDCEnabled, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["OIDCClientSpec"]) -> typing.Union[MetaOapg.properties.OIDCClientSpec, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["ServiceSpec"]) -> typing.Union[MetaOapg.properties.ServiceSpec, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["UserFacing"]) -> typing.Union[MetaOapg.properties.UserFacing, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["Protocol"]) -> typing.Union[MetaOapg.properties.Protocol, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["Domain"]) -> typing.Union[MetaOapg.properties.Domain, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["Port"]) -> typing.Union[MetaOapg.properties.Port, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["Enabled"]) -> typing.Union[MetaOapg.properties.Enabled, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["IsDefault"]) -> typing.Union[MetaOapg.properties.IsDefault, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...
            
            def get_item_oapg(self, name: typing.Union[typing_extensions.Literal["ServiceID", "ServiceName", "FriendlyName", "ClusterName", "ServiceType", "ServiceDiscovery", "ServiceVersion", "Description", "CreatedBy", "CreatedAt", "LastUpdatedBy", "LastUpdatedAt", "DeletedBy", "DeletedAt", "External", "OIDCEnabled", "OIDCClientSpec", "ServiceSpec", "UserFacing", "Protocol", "Domain", "Port", "Enabled", "IsDefault", ], str]):
                return super().get_item_oapg(name)
            
        
            def __new__(
                cls,
                *args: typing.Union[dict, frozendict.frozendict, ],
                ServiceID: typing.Union[MetaOapg.properties.ServiceID, str, schemas.Unset] = schemas.unset,
                ServiceName: typing.Union[MetaOapg.properties.ServiceName, str, schemas.Unset] = schemas.unset,
                FriendlyName: typing.Union[MetaOapg.properties.FriendlyName, str, schemas.Unset] = schemas.unset,
                ClusterName: typing.Union[MetaOapg.properties.ClusterName, str, schemas.Unset] = schemas.unset,
                ServiceType: typing.Union[MetaOapg.properties.ServiceType, str, schemas.Unset] = schemas.unset,
                ServiceDiscovery: typing.Union[MetaOapg.properties.ServiceDiscovery, str, schemas.Unset] = schemas.unset,
                ServiceVersion: typing.Union[MetaOapg.properties.ServiceVersion, decimal.Decimal, int, schemas.Unset] = schemas.unset,
                Description: typing.Union[MetaOapg.properties.Description, str, schemas.Unset] = schemas.unset,
                CreatedBy: typing.Union[MetaOapg.properties.CreatedBy, str, schemas.Unset] = schemas.unset,
                CreatedAt: typing.Union[MetaOapg.properties.CreatedAt, decimal.Decimal, int, schemas.Unset] = schemas.unset,
                LastUpdatedBy: typing.Union[MetaOapg.properties.LastUpdatedBy, str, schemas.Unset] = schemas.unset,
                LastUpdatedAt: typing.Union[MetaOapg.properties.LastUpdatedAt, decimal.Decimal, int, schemas.Unset] = schemas.unset,
                DeletedBy: typing.Union[MetaOapg.properties.DeletedBy, str, schemas.Unset] = schemas.unset,
                DeletedAt: typing.Union[MetaOapg.properties.DeletedAt, decimal.Decimal, int, schemas.Unset] = schemas.unset,
                External: typing.Union[MetaOapg.properties.External, str, schemas.Unset] = schemas.unset,
                OIDCEnabled: typing.Union[MetaOapg.properties.OIDCEnabled, str, schemas.Unset] = schemas.unset,
                OIDCClientSpec: typing.Union[MetaOapg.properties.OIDCClientSpec, str, schemas.Unset] = schemas.unset,
                ServiceSpec: typing.Union[MetaOapg.properties.ServiceSpec, str, schemas.Unset] = schemas.unset,
                UserFacing: typing.Union[MetaOapg.properties.UserFacing, str, schemas.Unset] = schemas.unset,
                Protocol: typing.Union[MetaOapg.properties.Protocol, str, schemas.Unset] = schemas.unset,
                Domain: typing.Union[MetaOapg.properties.Domain, str, schemas.Unset] = schemas.unset,
                Port: typing.Union[MetaOapg.properties.Port, decimal.Decimal, int, schemas.Unset] = schemas.unset,
                Enabled: typing.Union[MetaOapg.properties.Enabled, str, schemas.Unset] = schemas.unset,
                IsDefault: typing.Union[MetaOapg.properties.IsDefault, bool, schemas.Unset] = schemas.unset,
                _configuration: typing.Optional[schemas.Configuration] = None,
                **kwargs: typing.Union[schemas.AnyTypeSchema, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes],
            ) -> 'items':
                return super().__new__(
                    cls,
                    *args,
                    ServiceID=ServiceID,
                    ServiceName=ServiceName,
                    FriendlyName=FriendlyName,
                    ClusterName=ClusterName,
                    ServiceType=ServiceType,
                    ServiceDiscovery=ServiceDiscovery,
                    ServiceVersion=ServiceVersion,
                    Description=Description,
                    CreatedBy=CreatedBy,
                    CreatedAt=CreatedAt,
                    LastUpdatedBy=LastUpdatedBy,
                    LastUpdatedAt=LastUpdatedAt,
                    DeletedBy=DeletedBy,
                    DeletedAt=DeletedAt,
                    External=External,
                    OIDCEnabled=OIDCEnabled,
                    OIDCClientSpec=OIDCClientSpec,
                    ServiceSpec=ServiceSpec,
                    UserFacing=UserFacing,
                    Protocol=Protocol,
                    Domain=Domain,
                    Port=Port,
                    Enabled=Enabled,
                    IsDefault=IsDefault,
                    _configuration=_configuration,
                    **kwargs,
                )

    def __new__(
        cls,
        arg: typing.Union[typing.Tuple[typing.Union[MetaOapg.items, dict, frozendict.frozendict, ]], typing.List[typing.Union[MetaOapg.items, dict, frozendict.frozendict, ]]],
        _configuration: typing.Optional[schemas.Configuration] = None,
    ) -> 'SchemaFor200ResponseBodyApplicationJson':
        return super().__new__(
            cls,
            arg,
            _configuration=_configuration,
        )

    def __getitem__(self, i: int) -> MetaOapg.items:
        return super().__getitem__(i)


@dataclass
class ApiResponseFor200(api_client.ApiResponse):
    response: urllib3.HTTPResponse
    body: typing.Union[
        SchemaFor200ResponseBodyApplicationJson,
    ]
    headers: schemas.Unset = schemas.unset


_response_for_200 = api_client.OpenApiResponse(
    response_cls=ApiResponseFor200,
    content={
        'application/json': api_client.MediaType(
            schema=SchemaFor200ResponseBodyApplicationJson),
    },
)
_status_code_to_response = {
    '200': _response_for_200,
}
_all_accept_content_types = (
    'application/json',
)


class BaseApi(api_client.Api):

    def _v1_registered_services_get_oapg(
        self: api_client.Api,
        query_params: RequestQueryParams = frozendict.frozendict(),
        accept_content_types: typing.Tuple[str] = _all_accept_content_types,
        stream: bool = False,
        timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
        skip_deserialization: bool = False,
    ) -> typing.Union[
        ApiResponseFor200,
        api_client.ApiResponseWithoutDeserialization
    ]:
        """
         List services
        :param skip_deserialization: If true then api_response.response will be set but
            api_response.body and api_response.headers will not be deserialized into schema
            class instances
        """
        self._verify_typed_dict_inputs_oapg(RequestQueryParams, query_params)
        used_path = path.value

        prefix_separator_iterator = None
        for parameter in (
            request_query_service_id,
            request_query_default_services,
            request_query_service_name,
            request_query_friendly_name,
        ):
            parameter_data = query_params.get(parameter.name, schemas.unset)
            if parameter_data is schemas.unset:
                continue
            if prefix_separator_iterator is None:
                prefix_separator_iterator = parameter.get_prefix_separator_iterator()
            serialized_data = parameter.serialize(parameter_data, prefix_separator_iterator)
            for serialized_value in serialized_data.values():
                used_path += serialized_value

        _headers = HTTPHeaderDict()
        # TODO add cookie handling
        if accept_content_types:
            for accept_content_type in accept_content_types:
                _headers.add('Accept', accept_content_type)

        response = self.api_client.call_api(
            resource_path=used_path,
            method='get'.upper(),
            headers=_headers,
            auth_settings=_auth,
            stream=stream,
            timeout=timeout,
        )

        if skip_deserialization:
            api_response = api_client.ApiResponseWithoutDeserialization(response=response)
        else:
            response_for_status = _status_code_to_response.get(str(response.status))
            if response_for_status:
                api_response = response_for_status.deserialize(response, self.api_client.configuration)
            else:
                api_response = api_client.ApiResponseWithoutDeserialization(response=response)

        if not 200 <= response.status <= 299:
            raise exceptions.ApiException(api_response=api_response)

        return api_response


class V1RegisteredServicesGet(BaseApi):
    # this class is used by api classes that refer to endpoints with operationId fn names

    def v1_registered_services_get(
        self: BaseApi,
        query_params: RequestQueryParams = frozendict.frozendict(),
        accept_content_types: typing.Tuple[str] = _all_accept_content_types,
        stream: bool = False,
        timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
        skip_deserialization: bool = False,
    ) -> typing.Union[
        ApiResponseFor200,
        api_client.ApiResponseWithoutDeserialization
    ]:
        return self._v1_registered_services_get_oapg(
            query_params=query_params,
            accept_content_types=accept_content_types,
            stream=stream,
            timeout=timeout,
            skip_deserialization=skip_deserialization
        )


class ApiForget(BaseApi):
    # this class is used by api classes that refer to endpoints by path and http method names

    def get(
        self: BaseApi,
        query_params: RequestQueryParams = frozendict.frozendict(),
        accept_content_types: typing.Tuple[str] = _all_accept_content_types,
        stream: bool = False,
        timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
        skip_deserialization: bool = False,
    ) -> typing.Union[
        ApiResponseFor200,
        api_client.ApiResponseWithoutDeserialization
    ]:
        return self._v1_registered_services_get_oapg(
            query_params=query_params,
            accept_content_types=accept_content_types,
            stream=stream,
            timeout=timeout,
            skip_deserialization=skip_deserialization
        )


