# 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

_auth = [
    'bearerAuthToken',
]


class SchemaFor200ResponseBodyApplicationJson(
    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],
    ) -> 'SchemaFor200ResponseBodyApplicationJson':
        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,
        )


@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),
    },
)


@dataclass
class ApiResponseFor400(api_client.ApiResponse):
    response: urllib3.HTTPResponse
    body: schemas.Unset = schemas.unset
    headers: schemas.Unset = schemas.unset


_response_for_400 = api_client.OpenApiResponse(
    response_cls=ApiResponseFor400,
)


@dataclass
class ApiResponseFor500(api_client.ApiResponse):
    response: urllib3.HTTPResponse
    body: schemas.Unset = schemas.unset
    headers: schemas.Unset = schemas.unset


_response_for_500 = api_client.OpenApiResponse(
    response_cls=ApiResponseFor500,
)
_status_code_to_response = {
    '200': _response_for_200,
    '400': _response_for_400,
    '500': _response_for_500,
}
_all_accept_content_types = (
    'application/json',
)


class BaseApi(api_client.Api):

    def _v1_insert_registered_service_post_oapg(
        self: api_client.Api,
        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
    ]:
        """
         Create a new service or update an existing service
        :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
        """
        used_path = path.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='post'.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 V1InsertRegisteredServicePost(BaseApi):
    # this class is used by api classes that refer to endpoints with operationId fn names

    def v1_insert_registered_service_post(
        self: BaseApi,
        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_insert_registered_service_post_oapg(
            accept_content_types=accept_content_types,
            stream=stream,
            timeout=timeout,
            skip_deserialization=skip_deserialization
        )


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

    def post(
        self: BaseApi,
        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_insert_registered_service_post_oapg(
            accept_content_types=accept_content_types,
            stream=stream,
            timeout=timeout,
            skip_deserialization=skip_deserialization
        )


