# 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
SerialnumberSchema = schemas.StrSchema
EmailSchema = schemas.StrSchema
SkipSchema = schemas.IntSchema
LimitSchema = schemas.IntSchema
NameSchema = schemas.StrSchema
OrderSchema = schemas.StrSchema
OrderBySchema = schemas.StrSchema
ExactEmailSchema = schemas.StrSchema
ExactSerialNumberSchema = schemas.StrSchema
RequestRequiredQueryParams = typing_extensions.TypedDict(
    'RequestRequiredQueryParams',
    {
    }
)
RequestOptionalQueryParams = typing_extensions.TypedDict(
    'RequestOptionalQueryParams',
    {
        'Serialnumber': typing.Union[SerialnumberSchema, str, ],
        'Email': typing.Union[EmailSchema, str, ],
        'Skip': typing.Union[SkipSchema, decimal.Decimal, int, ],
        'Limit': typing.Union[LimitSchema, decimal.Decimal, int, ],
        'Name': typing.Union[NameSchema, str, ],
        'Order': typing.Union[OrderSchema, str, ],
        'OrderBy': typing.Union[OrderBySchema, str, ],
        'exact_email': typing.Union[ExactEmailSchema, str, ],
        'exact_serial_number': typing.Union[ExactSerialNumberSchema, str, ],
    },
    total=False
)


class RequestQueryParams(RequestRequiredQueryParams, RequestOptionalQueryParams):
    pass


request_query_serialnumber = api_client.QueryParameter(
    name="Serialnumber",
    style=api_client.ParameterStyle.FORM,
    schema=SerialnumberSchema,
    explode=True,
)
request_query_email = api_client.QueryParameter(
    name="Email",
    style=api_client.ParameterStyle.FORM,
    schema=EmailSchema,
    explode=True,
)
request_query_skip = api_client.QueryParameter(
    name="Skip",
    style=api_client.ParameterStyle.FORM,
    schema=SkipSchema,
    explode=True,
)
request_query_limit = api_client.QueryParameter(
    name="Limit",
    style=api_client.ParameterStyle.FORM,
    schema=LimitSchema,
    explode=True,
)
request_query_name = api_client.QueryParameter(
    name="Name",
    style=api_client.ParameterStyle.FORM,
    schema=NameSchema,
    explode=True,
)
request_query_order = api_client.QueryParameter(
    name="Order",
    style=api_client.ParameterStyle.FORM,
    schema=OrderSchema,
    explode=True,
)
request_query_order_by = api_client.QueryParameter(
    name="OrderBy",
    style=api_client.ParameterStyle.FORM,
    schema=OrderBySchema,
    explode=True,
)
request_query_exact_email = api_client.QueryParameter(
    name="exact_email",
    style=api_client.ParameterStyle.FORM,
    schema=ExactEmailSchema,
    explode=True,
)
request_query_exact_serial_number = api_client.QueryParameter(
    name="exact_serial_number",
    style=api_client.ParameterStyle.FORM,
    schema=ExactSerialNumberSchema,
    explode=True,
)
_auth = [
    'bearerAuthToken',
]


class SchemaFor200ResponseBodyApplicationJson(
    schemas.DictSchema
):


    class MetaOapg:
        
        class properties:
            
            
            class endusers(
                schemas.ListSchema
            ):
            
            
                class MetaOapg:
                    
                    
                    class items(
                        schemas.DictSchema
                    ):
                    
                    
                        class MetaOapg:
                            
                            class properties:
                                Name = schemas.StrSchema
                                Email = schemas.StrSchema
                                Groups = schemas.StrSchema
                                
                                
                                class TrustData(
                                    schemas.DictSchema
                                ):
                                
                                
                                    class MetaOapg:
                                        
                                        class properties:
                                            EntityTrustscore = schemas.IntSchema
                                            OverrideTrustscore = schemas.IntSchema
                                            AccessTrustscore = schemas.IntSchema
                                            OverrideActive = schemas.StrSchema
                                            Level = schemas.StrSchema
                                            UpdatedAt = schemas.IntSchema
                                            Factors = schemas.IntSchema
                                            __annotations__ = {
                                                "EntityTrustscore": EntityTrustscore,
                                                "OverrideTrustscore": OverrideTrustscore,
                                                "AccessTrustscore": AccessTrustscore,
                                                "OverrideActive": OverrideActive,
                                                "Level": Level,
                                                "UpdatedAt": UpdatedAt,
                                                "Factors": Factors,
                                            }
                                    
                                    @typing.overload
                                    def __getitem__(self, name: typing_extensions.Literal["EntityTrustscore"]) -> MetaOapg.properties.EntityTrustscore: ...
                                    
                                    @typing.overload
                                    def __getitem__(self, name: typing_extensions.Literal["OverrideTrustscore"]) -> MetaOapg.properties.OverrideTrustscore: ...
                                    
                                    @typing.overload
                                    def __getitem__(self, name: typing_extensions.Literal["AccessTrustscore"]) -> MetaOapg.properties.AccessTrustscore: ...
                                    
                                    @typing.overload
                                    def __getitem__(self, name: typing_extensions.Literal["OverrideActive"]) -> MetaOapg.properties.OverrideActive: ...
                                    
                                    @typing.overload
                                    def __getitem__(self, name: typing_extensions.Literal["Level"]) -> MetaOapg.properties.Level: ...
                                    
                                    @typing.overload
                                    def __getitem__(self, name: typing_extensions.Literal["UpdatedAt"]) -> MetaOapg.properties.UpdatedAt: ...
                                    
                                    @typing.overload
                                    def __getitem__(self, name: typing_extensions.Literal["Factors"]) -> MetaOapg.properties.Factors: ...
                                    
                                    @typing.overload
                                    def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ...
                                    
                                    def __getitem__(self, name: typing.Union[typing_extensions.Literal["EntityTrustscore", "OverrideTrustscore", "AccessTrustscore", "OverrideActive", "Level", "UpdatedAt", "Factors", ], str]):
                                        # dict_instance[name] accessor
                                        return super().__getitem__(name)
                                    
                                    
                                    @typing.overload
                                    def get_item_oapg(self, name: typing_extensions.Literal["EntityTrustscore"]) -> typing.Union[MetaOapg.properties.EntityTrustscore, schemas.Unset]: ...
                                    
                                    @typing.overload
                                    def get_item_oapg(self, name: typing_extensions.Literal["OverrideTrustscore"]) -> typing.Union[MetaOapg.properties.OverrideTrustscore, schemas.Unset]: ...
                                    
                                    @typing.overload
                                    def get_item_oapg(self, name: typing_extensions.Literal["AccessTrustscore"]) -> typing.Union[MetaOapg.properties.AccessTrustscore, schemas.Unset]: ...
                                    
                                    @typing.overload
                                    def get_item_oapg(self, name: typing_extensions.Literal["OverrideActive"]) -> typing.Union[MetaOapg.properties.OverrideActive, schemas.Unset]: ...
                                    
                                    @typing.overload
                                    def get_item_oapg(self, name: typing_extensions.Literal["Level"]) -> typing.Union[MetaOapg.properties.Level, schemas.Unset]: ...
                                    
                                    @typing.overload
                                    def get_item_oapg(self, name: typing_extensions.Literal["UpdatedAt"]) -> typing.Union[MetaOapg.properties.UpdatedAt, schemas.Unset]: ...
                                    
                                    @typing.overload
                                    def get_item_oapg(self, name: typing_extensions.Literal["Factors"]) -> typing.Union[MetaOapg.properties.Factors, 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["EntityTrustscore", "OverrideTrustscore", "AccessTrustscore", "OverrideActive", "Level", "UpdatedAt", "Factors", ], str]):
                                        return super().get_item_oapg(name)
                                    
                                
                                    def __new__(
                                        cls,
                                        *args: typing.Union[dict, frozendict.frozendict, ],
                                        EntityTrustscore: typing.Union[MetaOapg.properties.EntityTrustscore, decimal.Decimal, int, schemas.Unset] = schemas.unset,
                                        OverrideTrustscore: typing.Union[MetaOapg.properties.OverrideTrustscore, decimal.Decimal, int, schemas.Unset] = schemas.unset,
                                        AccessTrustscore: typing.Union[MetaOapg.properties.AccessTrustscore, decimal.Decimal, int, schemas.Unset] = schemas.unset,
                                        OverrideActive: typing.Union[MetaOapg.properties.OverrideActive, str, schemas.Unset] = schemas.unset,
                                        Level: typing.Union[MetaOapg.properties.Level, str, schemas.Unset] = schemas.unset,
                                        UpdatedAt: typing.Union[MetaOapg.properties.UpdatedAt, decimal.Decimal, int, schemas.Unset] = schemas.unset,
                                        Factors: typing.Union[MetaOapg.properties.Factors, decimal.Decimal, int, 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],
                                    ) -> 'TrustData':
                                        return super().__new__(
                                            cls,
                                            *args,
                                            EntityTrustscore=EntityTrustscore,
                                            OverrideTrustscore=OverrideTrustscore,
                                            AccessTrustscore=AccessTrustscore,
                                            OverrideActive=OverrideActive,
                                            Level=Level,
                                            UpdatedAt=UpdatedAt,
                                            Factors=Factors,
                                            _configuration=_configuration,
                                            **kwargs,
                                        )
                                
                                
                                class Roles(
                                    schemas.ListSchema
                                ):
                                
                                
                                    class MetaOapg:
                                        items = schemas.StrSchema
                                
                                    def __new__(
                                        cls,
                                        arg: typing.Union[typing.Tuple[typing.Union[MetaOapg.items, str, ]], typing.List[typing.Union[MetaOapg.items, str, ]]],
                                        _configuration: typing.Optional[schemas.Configuration] = None,
                                    ) -> 'Roles':
                                        return super().__new__(
                                            cls,
                                            arg,
                                            _configuration=_configuration,
                                        )
                                
                                    def __getitem__(self, i: int) -> MetaOapg.items:
                                        return super().__getitem__(i)
                                __annotations__ = {
                                    "Name": Name,
                                    "Email": Email,
                                    "Groups": Groups,
                                    "TrustData": TrustData,
                                    "Roles": Roles,
                                }
                        
                        @typing.overload
                        def __getitem__(self, name: typing_extensions.Literal["Name"]) -> MetaOapg.properties.Name: ...
                        
                        @typing.overload
                        def __getitem__(self, name: typing_extensions.Literal["Email"]) -> MetaOapg.properties.Email: ...
                        
                        @typing.overload
                        def __getitem__(self, name: typing_extensions.Literal["Groups"]) -> MetaOapg.properties.Groups: ...
                        
                        @typing.overload
                        def __getitem__(self, name: typing_extensions.Literal["TrustData"]) -> MetaOapg.properties.TrustData: ...
                        
                        @typing.overload
                        def __getitem__(self, name: typing_extensions.Literal["Roles"]) -> MetaOapg.properties.Roles: ...
                        
                        @typing.overload
                        def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ...
                        
                        def __getitem__(self, name: typing.Union[typing_extensions.Literal["Name", "Email", "Groups", "TrustData", "Roles", ], str]):
                            # dict_instance[name] accessor
                            return super().__getitem__(name)
                        
                        
                        @typing.overload
                        def get_item_oapg(self, name: typing_extensions.Literal["Name"]) -> typing.Union[MetaOapg.properties.Name, schemas.Unset]: ...
                        
                        @typing.overload
                        def get_item_oapg(self, name: typing_extensions.Literal["Email"]) -> typing.Union[MetaOapg.properties.Email, schemas.Unset]: ...
                        
                        @typing.overload
                        def get_item_oapg(self, name: typing_extensions.Literal["Groups"]) -> typing.Union[MetaOapg.properties.Groups, schemas.Unset]: ...
                        
                        @typing.overload
                        def get_item_oapg(self, name: typing_extensions.Literal["TrustData"]) -> typing.Union[MetaOapg.properties.TrustData, schemas.Unset]: ...
                        
                        @typing.overload
                        def get_item_oapg(self, name: typing_extensions.Literal["Roles"]) -> typing.Union[MetaOapg.properties.Roles, 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["Name", "Email", "Groups", "TrustData", "Roles", ], str]):
                            return super().get_item_oapg(name)
                        
                    
                        def __new__(
                            cls,
                            *args: typing.Union[dict, frozendict.frozendict, ],
                            Name: typing.Union[MetaOapg.properties.Name, str, schemas.Unset] = schemas.unset,
                            Email: typing.Union[MetaOapg.properties.Email, str, schemas.Unset] = schemas.unset,
                            Groups: typing.Union[MetaOapg.properties.Groups, str, schemas.Unset] = schemas.unset,
                            TrustData: typing.Union[MetaOapg.properties.TrustData, dict, frozendict.frozendict, schemas.Unset] = schemas.unset,
                            Roles: typing.Union[MetaOapg.properties.Roles, list, tuple, 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,
                                Name=Name,
                                Email=Email,
                                Groups=Groups,
                                TrustData=TrustData,
                                Roles=Roles,
                                _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,
                ) -> 'endusers':
                    return super().__new__(
                        cls,
                        arg,
                        _configuration=_configuration,
                    )
            
                def __getitem__(self, i: int) -> MetaOapg.items:
                    return super().__getitem__(i)
            count = schemas.IntSchema
            __annotations__ = {
                "endusers": endusers,
                "count": count,
            }
    
    @typing.overload
    def __getitem__(self, name: typing_extensions.Literal["endusers"]) -> MetaOapg.properties.endusers: ...
    
    @typing.overload
    def __getitem__(self, name: typing_extensions.Literal["count"]) -> MetaOapg.properties.count: ...
    
    @typing.overload
    def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ...
    
    def __getitem__(self, name: typing.Union[typing_extensions.Literal["endusers", "count", ], str]):
        # dict_instance[name] accessor
        return super().__getitem__(name)
    
    
    @typing.overload
    def get_item_oapg(self, name: typing_extensions.Literal["endusers"]) -> typing.Union[MetaOapg.properties.endusers, schemas.Unset]: ...
    
    @typing.overload
    def get_item_oapg(self, name: typing_extensions.Literal["count"]) -> typing.Union[MetaOapg.properties.count, 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["endusers", "count", ], str]):
        return super().get_item_oapg(name)
    

    def __new__(
        cls,
        *args: typing.Union[dict, frozendict.frozendict, ],
        endusers: typing.Union[MetaOapg.properties.endusers, list, tuple, schemas.Unset] = schemas.unset,
        count: typing.Union[MetaOapg.properties.count, decimal.Decimal, int, 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,
            endusers=endusers,
            count=count,
            _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_endusers_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
    ]:
        """
        Get the End Users in an Organization
        :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_serialnumber,
            request_query_email,
            request_query_skip,
            request_query_limit,
            request_query_name,
            request_query_order,
            request_query_order_by,
            request_query_exact_email,
            request_query_exact_serial_number,
        ):
            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 V1EndusersGet(BaseApi):
    # this class is used by api classes that refer to endpoints with operationId fn names

    def v1_endusers_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_endusers_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_endusers_get_oapg(
            query_params=query_params,
            accept_content_types=accept_content_types,
            stream=stream,
            timeout=timeout,
            skip_deserialization=skip_deserialization
        )


