|
| 1 | +# coding: utf-8 |
| 2 | + |
| 3 | +# |
| 4 | +# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 5 | +# |
| 6 | +# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file |
| 7 | +# except in compliance with the License. A copy of the License is located at |
| 8 | +# |
| 9 | +# http://aws.amazon.com/apache2.0/ |
| 10 | +# |
| 11 | +# or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for |
| 13 | +# the specific language governing permissions and limitations under the License. |
| 14 | +# |
| 15 | + |
| 16 | +import pprint |
| 17 | +import re # noqa: F401 |
| 18 | +import six |
| 19 | +import typing |
| 20 | +from enum import Enum |
| 21 | + |
| 22 | + |
| 23 | +if typing.TYPE_CHECKING: |
| 24 | + from typing import Dict, List, Optional, Union |
| 25 | + from datetime import datetime |
| 26 | + from ask_sdk_model.services.endpoint_enumeration.endpoint_capability import EndpointCapability |
| 27 | + |
| 28 | + |
| 29 | +class EndpointInfo(object): |
| 30 | + """ |
| 31 | + Contains the list of connected endpoints and their declared capabilities. |
| 32 | +
|
| 33 | +
|
| 34 | + :param endpoint_id: A unique identifier for the endpoint. |
| 35 | + :type endpoint_id: (optional) str |
| 36 | + :param friendly_name: The name of the endpoint. Because this name might be changed by the user or the platform, it might be different than the Bluetooth friendly name. |
| 37 | + :type friendly_name: (optional) str |
| 38 | + :param capabilities: The list of endpoint capabilities. |
| 39 | + :type capabilities: (optional) list[ask_sdk_model.services.endpoint_enumeration.endpoint_capability.EndpointCapability] |
| 40 | +
|
| 41 | + """ |
| 42 | + deserialized_types = { |
| 43 | + 'endpoint_id': 'str', |
| 44 | + 'friendly_name': 'str', |
| 45 | + 'capabilities': 'list[ask_sdk_model.services.endpoint_enumeration.endpoint_capability.EndpointCapability]' |
| 46 | + } # type: Dict |
| 47 | + |
| 48 | + attribute_map = { |
| 49 | + 'endpoint_id': 'endpointId', |
| 50 | + 'friendly_name': 'friendlyName', |
| 51 | + 'capabilities': 'capabilities' |
| 52 | + } # type: Dict |
| 53 | + |
| 54 | + def __init__(self, endpoint_id=None, friendly_name=None, capabilities=None): |
| 55 | + # type: (Optional[str], Optional[str], Optional[List[EndpointCapability]]) -> None |
| 56 | + """Contains the list of connected endpoints and their declared capabilities. |
| 57 | +
|
| 58 | + :param endpoint_id: A unique identifier for the endpoint. |
| 59 | + :type endpoint_id: (optional) str |
| 60 | + :param friendly_name: The name of the endpoint. Because this name might be changed by the user or the platform, it might be different than the Bluetooth friendly name. |
| 61 | + :type friendly_name: (optional) str |
| 62 | + :param capabilities: The list of endpoint capabilities. |
| 63 | + :type capabilities: (optional) list[ask_sdk_model.services.endpoint_enumeration.endpoint_capability.EndpointCapability] |
| 64 | + """ |
| 65 | + self.__discriminator_value = None # type: str |
| 66 | + |
| 67 | + self.endpoint_id = endpoint_id |
| 68 | + self.friendly_name = friendly_name |
| 69 | + self.capabilities = capabilities |
| 70 | + |
| 71 | + def to_dict(self): |
| 72 | + # type: () -> Dict[str, object] |
| 73 | + """Returns the model properties as a dict""" |
| 74 | + result = {} # type: Dict |
| 75 | + |
| 76 | + for attr, _ in six.iteritems(self.deserialized_types): |
| 77 | + value = getattr(self, attr) |
| 78 | + if isinstance(value, list): |
| 79 | + result[attr] = list(map( |
| 80 | + lambda x: x.to_dict() if hasattr(x, "to_dict") else |
| 81 | + x.value if isinstance(x, Enum) else x, |
| 82 | + value |
| 83 | + )) |
| 84 | + elif isinstance(value, Enum): |
| 85 | + result[attr] = value.value |
| 86 | + elif hasattr(value, "to_dict"): |
| 87 | + result[attr] = value.to_dict() |
| 88 | + elif isinstance(value, dict): |
| 89 | + result[attr] = dict(map( |
| 90 | + lambda item: (item[0], item[1].to_dict()) |
| 91 | + if hasattr(item[1], "to_dict") else |
| 92 | + (item[0], item[1].value) |
| 93 | + if isinstance(item[1], Enum) else item, |
| 94 | + value.items() |
| 95 | + )) |
| 96 | + else: |
| 97 | + result[attr] = value |
| 98 | + |
| 99 | + return result |
| 100 | + |
| 101 | + def to_str(self): |
| 102 | + # type: () -> str |
| 103 | + """Returns the string representation of the model""" |
| 104 | + return pprint.pformat(self.to_dict()) |
| 105 | + |
| 106 | + def __repr__(self): |
| 107 | + # type: () -> str |
| 108 | + """For `print` and `pprint`""" |
| 109 | + return self.to_str() |
| 110 | + |
| 111 | + def __eq__(self, other): |
| 112 | + # type: (object) -> bool |
| 113 | + """Returns true if both objects are equal""" |
| 114 | + if not isinstance(other, EndpointInfo): |
| 115 | + return False |
| 116 | + |
| 117 | + return self.__dict__ == other.__dict__ |
| 118 | + |
| 119 | + def __ne__(self, other): |
| 120 | + # type: (object) -> bool |
| 121 | + """Returns true if both objects are not equal""" |
| 122 | + return not self == other |
0 commit comments