# 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
FilterBySchema = schemas.StrSchema
SourceSchema = schemas.StrSchema
EmailSchema = schemas.StrSchema
SerialNumberSchema = schemas.StrSchema
ExactEmailSchema = schemas.StrSchema
ExactSerialNumberSchema = schemas.StrSchema
RequestRequiredQueryParams = typing_extensions.TypedDict(
    'RequestRequiredQueryParams',
    {
    }
)
RequestOptionalQueryParams = typing_extensions.TypedDict(
    'RequestOptionalQueryParams',
    {
        'FilterBy': typing.Union[FilterBySchema, str, ],
        'Source': typing.Union[SourceSchema, str, ],
        'Email': typing.Union[EmailSchema, str, ],
        'SerialNumber': typing.Union[SerialNumberSchema, str, ],
        'exact_email': typing.Union[ExactEmailSchema, str, ],
        'exact_serial_number': typing.Union[ExactSerialNumberSchema, str, ],
    },
    total=False
)


class RequestQueryParams(RequestRequiredQueryParams, RequestOptionalQueryParams):
    pass


request_query_filter_by = api_client.QueryParameter(
    name="FilterBy",
    style=api_client.ParameterStyle.FORM,
    schema=FilterBySchema,
    explode=True,
)
request_query_source = api_client.QueryParameter(
    name="Source",
    style=api_client.ParameterStyle.FORM,
    schema=SourceSchema,
    explode=True,
)
request_query_email = api_client.QueryParameter(
    name="Email",
    style=api_client.ParameterStyle.FORM,
    schema=EmailSchema,
    explode=True,
)
request_query_serial_number = api_client.QueryParameter(
    name="SerialNumber",
    style=api_client.ParameterStyle.FORM,
    schema=SerialNumberSchema,
    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.ListSchema
):


    class MetaOapg:
        
        
        class items(
            schemas.DictSchema
        ):
        
        
            class MetaOapg:
                
                class properties:
                    DeviceID = schemas.StrSchema
                    Email = schemas.StrSchema
                    SerialNumber = schemas.StrSchema
                    Model = schemas.StrSchema
                    Ownership = schemas.StrSchema
                    Platform = schemas.StrSchema
                    Enrolled = schemas.StrSchema
                    Compromised = schemas.StrSchema
                    LastLogin = schemas.IntSchema
                    CreatedAt = schemas.IntSchema
                    Architecture = schemas.StrSchema
                    RegisteredStatus = schemas.StrSchema
                    Source = schemas.StrSchema
                    Name = schemas.StrSchema
                    LoginCount = schemas.IntSchema
                    Groups = schemas.StrSchema
                    __annotations__ = {
                        "DeviceID": DeviceID,
                        "Email": Email,
                        "SerialNumber": SerialNumber,
                        "Model": Model,
                        "Ownership": Ownership,
                        "Platform": Platform,
                        "Enrolled": Enrolled,
                        "Compromised": Compromised,
                        "LastLogin": LastLogin,
                        "CreatedAt": CreatedAt,
                        "Architecture": Architecture,
                        "RegisteredStatus": RegisteredStatus,
                        "Source": Source,
                        "Name": Name,
                        "LoginCount": LoginCount,
                        "Groups": Groups,
                    }
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["DeviceID"]) -> MetaOapg.properties.DeviceID: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["Email"]) -> MetaOapg.properties.Email: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["SerialNumber"]) -> MetaOapg.properties.SerialNumber: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["Model"]) -> MetaOapg.properties.Model: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["Ownership"]) -> MetaOapg.properties.Ownership: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["Platform"]) -> MetaOapg.properties.Platform: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["Enrolled"]) -> MetaOapg.properties.Enrolled: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["Compromised"]) -> MetaOapg.properties.Compromised: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["LastLogin"]) -> MetaOapg.properties.LastLogin: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["CreatedAt"]) -> MetaOapg.properties.CreatedAt: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["Architecture"]) -> MetaOapg.properties.Architecture: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["RegisteredStatus"]) -> MetaOapg.properties.RegisteredStatus: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["Source"]) -> MetaOapg.properties.Source: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["Name"]) -> MetaOapg.properties.Name: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["LoginCount"]) -> MetaOapg.properties.LoginCount: ...
            
            @typing.overload
            def __getitem__(self, name: typing_extensions.Literal["Groups"]) -> MetaOapg.properties.Groups: ...
            
            @typing.overload
            def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ...
            
            def __getitem__(self, name: typing.Union[typing_extensions.Literal["DeviceID", "Email", "SerialNumber", "Model", "Ownership", "Platform", "Enrolled", "Compromised", "LastLogin", "CreatedAt", "Architecture", "RegisteredStatus", "Source", "Name", "LoginCount", "Groups", ], str]):
                # dict_instance[name] accessor
                return super().__getitem__(name)
            
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["DeviceID"]) -> typing.Union[MetaOapg.properties.DeviceID, 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["SerialNumber"]) -> typing.Union[MetaOapg.properties.SerialNumber, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["Model"]) -> typing.Union[MetaOapg.properties.Model, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["Ownership"]) -> typing.Union[MetaOapg.properties.Ownership, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["Platform"]) -> typing.Union[MetaOapg.properties.Platform, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["Enrolled"]) -> typing.Union[MetaOapg.properties.Enrolled, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["Compromised"]) -> typing.Union[MetaOapg.properties.Compromised, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["LastLogin"]) -> typing.Union[MetaOapg.properties.LastLogin, 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["Architecture"]) -> typing.Union[MetaOapg.properties.Architecture, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["RegisteredStatus"]) -> typing.Union[MetaOapg.properties.RegisteredStatus, schemas.Unset]: ...
            
            @typing.overload
            def get_item_oapg(self, name: typing_extensions.Literal["Source"]) -> typing.Union[MetaOapg.properties.Source, schemas.Unset]: ...
            
            @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["LoginCount"]) -> typing.Union[MetaOapg.properties.LoginCount, 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: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...
            
            def get_item_oapg(self, name: typing.Union[typing_extensions.Literal["DeviceID", "Email", "SerialNumber", "Model", "Ownership", "Platform", "Enrolled", "Compromised", "LastLogin", "CreatedAt", "Architecture", "RegisteredStatus", "Source", "Name", "LoginCount", "Groups", ], str]):
                return super().get_item_oapg(name)
            
        
            def __new__(
                cls,
                *args: typing.Union[dict, frozendict.frozendict, ],
                DeviceID: typing.Union[MetaOapg.properties.DeviceID, str, schemas.Unset] = schemas.unset,
                Email: typing.Union[MetaOapg.properties.Email, str, schemas.Unset] = schemas.unset,
                SerialNumber: typing.Union[MetaOapg.properties.SerialNumber, str, schemas.Unset] = schemas.unset,
                Model: typing.Union[MetaOapg.properties.Model, str, schemas.Unset] = schemas.unset,
                Ownership: typing.Union[MetaOapg.properties.Ownership, str, schemas.Unset] = schemas.unset,
                Platform: typing.Union[MetaOapg.properties.Platform, str, schemas.Unset] = schemas.unset,
                Enrolled: typing.Union[MetaOapg.properties.Enrolled, str, schemas.Unset] = schemas.unset,
                Compromised: typing.Union[MetaOapg.properties.Compromised, str, schemas.Unset] = schemas.unset,
                LastLogin: typing.Union[MetaOapg.properties.LastLogin, decimal.Decimal, int, schemas.Unset] = schemas.unset,
                CreatedAt: typing.Union[MetaOapg.properties.CreatedAt, decimal.Decimal, int, schemas.Unset] = schemas.unset,
                Architecture: typing.Union[MetaOapg.properties.Architecture, str, schemas.Unset] = schemas.unset,
                RegisteredStatus: typing.Union[MetaOapg.properties.RegisteredStatus, str, schemas.Unset] = schemas.unset,
                Source: typing.Union[MetaOapg.properties.Source, str, schemas.Unset] = schemas.unset,
                Name: typing.Union[MetaOapg.properties.Name, str, schemas.Unset] = schemas.unset,
                LoginCount: typing.Union[MetaOapg.properties.LoginCount, decimal.Decimal, int, schemas.Unset] = schemas.unset,
                Groups: typing.Union[MetaOapg.properties.Groups, str, 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,
                    DeviceID=DeviceID,
                    Email=Email,
                    SerialNumber=SerialNumber,
                    Model=Model,
                    Ownership=Ownership,
                    Platform=Platform,
                    Enrolled=Enrolled,
                    Compromised=Compromised,
                    LastLogin=LastLogin,
                    CreatedAt=CreatedAt,
                    Architecture=Architecture,
                    RegisteredStatus=RegisteredStatus,
                    Source=Source,
                    Name=Name,
                    LoginCount=LoginCount,
                    Groups=Groups,
                    _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),
    },
)


@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_enduser_devices_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 End User Devices
        :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_filter_by,
            request_query_source,
            request_query_email,
            request_query_serial_number,
            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 V1EnduserDevicesGet(BaseApi):
    # this class is used by api classes that refer to endpoints with operationId fn names

    def v1_enduser_devices_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_enduser_devices_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_enduser_devices_get_oapg(
            query_params=query_params,
            accept_content_types=accept_content_types,
            stream=stream,
            timeout=timeout,
            skip_deserialization=skip_deserialization
        )


