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


class RequestQueryParams(RequestRequiredQueryParams, RequestOptionalQueryParams):
    pass


request_query_serial_number = api_client.QueryParameter(
    name="SerialNumber",
    style=api_client.ParameterStyle.FORM,
    schema=SerialNumberSchema,
    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:
            DeviceID = schemas.StrSchema
            MACAddress = schemas.StrSchema
            UDID = schemas.StrSchema
            SerialNumber = schemas.StrSchema
            RegisteredStatus = schemas.IntSchema
            CompromisedStatus = schemas.StrSchema
            ComplianceStatus = schemas.StrSchema
            OEMInfo = schemas.StrSchema
            Model = schemas.StrSchema
            Platform = schemas.StrSchema
            Ownership = schemas.StrSchema
            DeviceJSON = schemas.StrSchema
            Name = schemas.StrSchema
            
            
            class Email(
                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,
                ) -> 'Email':
                    return super().__new__(
                        cls,
                        arg,
                        _configuration=_configuration,
                    )
            
                def __getitem__(self, i: int) -> MetaOapg.items:
                    return super().__getitem__(i)
            Groups = schemas.IntSchema
            UserAgent = schemas.StrSchema
            IPAddress = schemas.StrSchema
            Architecture = schemas.StrSchema
            Source = schemas.StrSchema
            ShieldUUID = schemas.StrSchema
            __annotations__ = {
                "DeviceID": DeviceID,
                "MACAddress": MACAddress,
                "UDID": UDID,
                "SerialNumber": SerialNumber,
                "RegisteredStatus": RegisteredStatus,
                "CompromisedStatus": CompromisedStatus,
                "ComplianceStatus": ComplianceStatus,
                "OEMInfo": OEMInfo,
                "Model": Model,
                "Platform": Platform,
                "Ownership": Ownership,
                "DeviceJSON": DeviceJSON,
                "Name": Name,
                "Email": Email,
                "Groups": Groups,
                "UserAgent": UserAgent,
                "IPAddress": IPAddress,
                "Architecture": Architecture,
                "Source": Source,
                "ShieldUUID": ShieldUUID,
            }
    
    @typing.overload
    def __getitem__(self, name: typing_extensions.Literal["DeviceID"]) -> MetaOapg.properties.DeviceID: ...
    
    @typing.overload
    def __getitem__(self, name: typing_extensions.Literal["MACAddress"]) -> MetaOapg.properties.MACAddress: ...
    
    @typing.overload
    def __getitem__(self, name: typing_extensions.Literal["UDID"]) -> MetaOapg.properties.UDID: ...
    
    @typing.overload
    def __getitem__(self, name: typing_extensions.Literal["SerialNumber"]) -> MetaOapg.properties.SerialNumber: ...
    
    @typing.overload
    def __getitem__(self, name: typing_extensions.Literal["RegisteredStatus"]) -> MetaOapg.properties.RegisteredStatus: ...
    
    @typing.overload
    def __getitem__(self, name: typing_extensions.Literal["CompromisedStatus"]) -> MetaOapg.properties.CompromisedStatus: ...
    
    @typing.overload
    def __getitem__(self, name: typing_extensions.Literal["ComplianceStatus"]) -> MetaOapg.properties.ComplianceStatus: ...
    
    @typing.overload
    def __getitem__(self, name: typing_extensions.Literal["OEMInfo"]) -> MetaOapg.properties.OEMInfo: ...
    
    @typing.overload
    def __getitem__(self, name: typing_extensions.Literal["Model"]) -> MetaOapg.properties.Model: ...
    
    @typing.overload
    def __getitem__(self, name: typing_extensions.Literal["Platform"]) -> MetaOapg.properties.Platform: ...
    
    @typing.overload
    def __getitem__(self, name: typing_extensions.Literal["Ownership"]) -> MetaOapg.properties.Ownership: ...
    
    @typing.overload
    def __getitem__(self, name: typing_extensions.Literal["DeviceJSON"]) -> MetaOapg.properties.DeviceJSON: ...
    
    @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["UserAgent"]) -> MetaOapg.properties.UserAgent: ...
    
    @typing.overload
    def __getitem__(self, name: typing_extensions.Literal["IPAddress"]) -> MetaOapg.properties.IPAddress: ...
    
    @typing.overload
    def __getitem__(self, name: typing_extensions.Literal["Architecture"]) -> MetaOapg.properties.Architecture: ...
    
    @typing.overload
    def __getitem__(self, name: typing_extensions.Literal["Source"]) -> MetaOapg.properties.Source: ...
    
    @typing.overload
    def __getitem__(self, name: typing_extensions.Literal["ShieldUUID"]) -> MetaOapg.properties.ShieldUUID: ...
    
    @typing.overload
    def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ...
    
    def __getitem__(self, name: typing.Union[typing_extensions.Literal["DeviceID", "MACAddress", "UDID", "SerialNumber", "RegisteredStatus", "CompromisedStatus", "ComplianceStatus", "OEMInfo", "Model", "Platform", "Ownership", "DeviceJSON", "Name", "Email", "Groups", "UserAgent", "IPAddress", "Architecture", "Source", "ShieldUUID", ], 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["MACAddress"]) -> typing.Union[MetaOapg.properties.MACAddress, schemas.Unset]: ...
    
    @typing.overload
    def get_item_oapg(self, name: typing_extensions.Literal["UDID"]) -> typing.Union[MetaOapg.properties.UDID, 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["RegisteredStatus"]) -> typing.Union[MetaOapg.properties.RegisteredStatus, schemas.Unset]: ...
    
    @typing.overload
    def get_item_oapg(self, name: typing_extensions.Literal["CompromisedStatus"]) -> typing.Union[MetaOapg.properties.CompromisedStatus, schemas.Unset]: ...
    
    @typing.overload
    def get_item_oapg(self, name: typing_extensions.Literal["ComplianceStatus"]) -> typing.Union[MetaOapg.properties.ComplianceStatus, schemas.Unset]: ...
    
    @typing.overload
    def get_item_oapg(self, name: typing_extensions.Literal["OEMInfo"]) -> typing.Union[MetaOapg.properties.OEMInfo, 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["Platform"]) -> typing.Union[MetaOapg.properties.Platform, 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["DeviceJSON"]) -> typing.Union[MetaOapg.properties.DeviceJSON, 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["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["UserAgent"]) -> typing.Union[MetaOapg.properties.UserAgent, schemas.Unset]: ...
    
    @typing.overload
    def get_item_oapg(self, name: typing_extensions.Literal["IPAddress"]) -> typing.Union[MetaOapg.properties.IPAddress, 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["Source"]) -> typing.Union[MetaOapg.properties.Source, schemas.Unset]: ...
    
    @typing.overload
    def get_item_oapg(self, name: typing_extensions.Literal["ShieldUUID"]) -> typing.Union[MetaOapg.properties.ShieldUUID, 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", "MACAddress", "UDID", "SerialNumber", "RegisteredStatus", "CompromisedStatus", "ComplianceStatus", "OEMInfo", "Model", "Platform", "Ownership", "DeviceJSON", "Name", "Email", "Groups", "UserAgent", "IPAddress", "Architecture", "Source", "ShieldUUID", ], 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,
        MACAddress: typing.Union[MetaOapg.properties.MACAddress, str, schemas.Unset] = schemas.unset,
        UDID: typing.Union[MetaOapg.properties.UDID, str, schemas.Unset] = schemas.unset,
        SerialNumber: typing.Union[MetaOapg.properties.SerialNumber, str, schemas.Unset] = schemas.unset,
        RegisteredStatus: typing.Union[MetaOapg.properties.RegisteredStatus, decimal.Decimal, int, schemas.Unset] = schemas.unset,
        CompromisedStatus: typing.Union[MetaOapg.properties.CompromisedStatus, str, schemas.Unset] = schemas.unset,
        ComplianceStatus: typing.Union[MetaOapg.properties.ComplianceStatus, str, schemas.Unset] = schemas.unset,
        OEMInfo: typing.Union[MetaOapg.properties.OEMInfo, str, schemas.Unset] = schemas.unset,
        Model: typing.Union[MetaOapg.properties.Model, str, schemas.Unset] = schemas.unset,
        Platform: typing.Union[MetaOapg.properties.Platform, str, schemas.Unset] = schemas.unset,
        Ownership: typing.Union[MetaOapg.properties.Ownership, str, schemas.Unset] = schemas.unset,
        DeviceJSON: typing.Union[MetaOapg.properties.DeviceJSON, str, schemas.Unset] = schemas.unset,
        Name: typing.Union[MetaOapg.properties.Name, str, schemas.Unset] = schemas.unset,
        Email: typing.Union[MetaOapg.properties.Email, list, tuple, schemas.Unset] = schemas.unset,
        Groups: typing.Union[MetaOapg.properties.Groups, decimal.Decimal, int, schemas.Unset] = schemas.unset,
        UserAgent: typing.Union[MetaOapg.properties.UserAgent, str, schemas.Unset] = schemas.unset,
        IPAddress: typing.Union[MetaOapg.properties.IPAddress, str, schemas.Unset] = schemas.unset,
        Architecture: typing.Union[MetaOapg.properties.Architecture, str, schemas.Unset] = schemas.unset,
        Source: typing.Union[MetaOapg.properties.Source, str, schemas.Unset] = schemas.unset,
        ShieldUUID: typing.Union[MetaOapg.properties.ShieldUUID, 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],
    ) -> 'SchemaFor200ResponseBodyApplicationJson':
        return super().__new__(
            cls,
            *args,
            DeviceID=DeviceID,
            MACAddress=MACAddress,
            UDID=UDID,
            SerialNumber=SerialNumber,
            RegisteredStatus=RegisteredStatus,
            CompromisedStatus=CompromisedStatus,
            ComplianceStatus=ComplianceStatus,
            OEMInfo=OEMInfo,
            Model=Model,
            Platform=Platform,
            Ownership=Ownership,
            DeviceJSON=DeviceJSON,
            Name=Name,
            Email=Email,
            Groups=Groups,
            UserAgent=UserAgent,
            IPAddress=IPAddress,
            Architecture=Architecture,
            Source=Source,
            ShieldUUID=ShieldUUID,
            _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_mdm_device_info_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 Device Info
        :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_serial_number,
            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 V1MdmDeviceInfoGet(BaseApi):
    # this class is used by api classes that refer to endpoints with operationId fn names

    def v1_mdm_device_info_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_mdm_device_info_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_mdm_device_info_get_oapg(
            query_params=query_params,
            accept_content_types=accept_content_types,
            stream=stream,
            timeout=timeout,
            skip_deserialization=skip_deserialization
        )


