diff --git a/sdk/iothub/azure-mgmt-iothub/_meta.json b/sdk/iothub/azure-mgmt-iothub/_meta.json index 89e810bfbd5e..d7a49b3bfd88 100644 --- a/sdk/iothub/azure-mgmt-iothub/_meta.json +++ b/sdk/iothub/azure-mgmt-iothub/_meta.json @@ -1,11 +1,28 @@ { - "commit": "396209531039d3e211cb1ec0982606dbbdf64ac2", + "commit": "fa720d560a43fde8264d2a6d9d8407b1464e6c12", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.9.7", "use": [ - "@autorest/python@6.4.3", - "@autorest/modelerfour@4.24.3" + "@autorest/python@6.7.1", + "@autorest/modelerfour@4.26.2" ], - "autorest_command": "autorest specification/iothub/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.4.3 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", - "readme": "specification/iothub/resource-manager/readme.md" + "autorest_command": "autorest specification/iothub/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False", + "readme": "specification/iothub/resource-manager/readme.md", + "package-2023-06": "2023-08-16 18:48:22 -0700 8fa9b5051129dd4808c9be1f5b753af226b044db Microsoft.Devices/stable/2023-06-30/iothub.json", + "package-preview-2023-06": "2023-08-14 22:58:07 -0700 d99f18b18405cd446f7abc2c9e6b3884f5c549f8 Microsoft.Devices/preview/2023-06-30-preview/iothub.json", + "package-preview-2022-11": "2023-03-14 21:37:19 -0700 7e5861ad01a796a72617080e89e42f428e66242e Microsoft.Devices/preview/2022-11-15-preview/iothub.json", + "package-preview-2022-04-30": "2022-08-09 20:31:29 -0700 1f75c8b5d3f55387d6e07e7f2f879a88f529180d Microsoft.Devices/preview/2022-04-30-preview/iothub.json", + "package-2021-07-02": "2023-01-27 19:16:47 -0800 0b0f8d5b088da606ffbb8b2828dc366982f106e5 Microsoft.Devices/stable/2021-07-02/iothub.json", + "package-2021-07": "2023-01-27 19:16:47 -0800 0b0f8d5b088da606ffbb8b2828dc366982f106e5 Microsoft.Devices/stable/2021-07-02/iothub.json", + "package-2021-03": "2021-05-07 19:43:30 -0700 4b7dca50a9a7559865803927a87a06ad0d73ff06 Microsoft.Devices/stable/2021-03-31/iothub.json", + "package-preview-2021-03": "2021-04-05 22:04:32 -0700 2331a635ead0549b8c0f3891bf9bf2e5e5ad76bc Microsoft.Devices/preview/2021-03-03-preview/iothub.json", + "package-2020-03": "2021-05-05 01:19:33 -0700 8c76ee1ab76c977e1bdd4abc5369704684576111 Microsoft.Devices/stable/2020-03-01/iothub.json", + "package-2019-11": "2021-04-27 02:22:18 -0700 8873dabb56a800c037ca56beab11dd5a9ed988ad Microsoft.Devices/stable/2019-11-04/iothub.json", + "package-preview-2019-07": "2021-04-27 02:22:18 -0700 8873dabb56a800c037ca56beab11dd5a9ed988ad Microsoft.Devices/preview/2019-07-01-preview/iothub.json", + "package-2019-03": "2021-04-27 02:22:18 -0700 8873dabb56a800c037ca56beab11dd5a9ed988ad Microsoft.Devices/stable/2019-03-22/iothub.json", + "package-2018-04": "2021-04-27 02:22:18 -0700 8873dabb56a800c037ca56beab11dd5a9ed988ad Microsoft.Devices/stable/2018-04-01/iothub.json", + "package-2018-01": "2021-04-27 02:22:18 -0700 8873dabb56a800c037ca56beab11dd5a9ed988ad Microsoft.Devices/stable/2018-01-22/iothub.json", + "package-2017-07": "2021-04-27 02:22:18 -0700 8873dabb56a800c037ca56beab11dd5a9ed988ad Microsoft.Devices/stable/2017-07-01/iothub.json", + "package-2017-01": "2021-04-27 02:22:18 -0700 8873dabb56a800c037ca56beab11dd5a9ed988ad Microsoft.Devices/stable/2017-01-19/iothub.json", + "package-2016-02": "2021-04-27 02:22:18 -0700 8873dabb56a800c037ca56beab11dd5a9ed988ad Microsoft.Devices/stable/2016-02-03/iothub.json" } \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_iot_hub_client.py index 755034c47738..478db50e38ef 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_iot_hub_client.py @@ -53,7 +53,7 @@ class IotHubClient(MultiApiClientMixin, _SDKClient): :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ - DEFAULT_API_VERSION = '2021-07-02' + DEFAULT_API_VERSION = '2023-06-30' _PROFILE_TAG = "azure.mgmt.iothub.IotHubClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -71,6 +71,8 @@ def __init__( profile: KnownProfiles=KnownProfiles.default, **kwargs: Any ): + if api_version: + kwargs.setdefault('api_version', api_version) self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(IotHubClient, self).__init__( @@ -101,6 +103,8 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2021-07-02: :mod:`v2021_07_02.models` * 2022-04-30-preview: :mod:`v2022_04_30_preview.models` * 2022-11-15-preview: :mod:`v2022_11_15_preview.models` + * 2023-06-30: :mod:`v2023_06_30.models` + * 2023-06-30-preview: :mod:`v2023_06_30_preview.models` """ if api_version == '2016-02-03': from .v2016_02_03 import models @@ -147,6 +151,12 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2022-11-15-preview': from .v2022_11_15_preview import models return models + elif api_version == '2023-06-30': + from .v2023_06_30 import models + return models + elif api_version == '2023-06-30-preview': + from .v2023_06_30_preview import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -166,6 +176,8 @@ def certificates(self): * 2021-07-02: :class:`CertificatesOperations` * 2022-04-30-preview: :class:`CertificatesOperations` * 2022-11-15-preview: :class:`CertificatesOperations` + * 2023-06-30: :class:`CertificatesOperations` + * 2023-06-30-preview: :class:`CertificatesOperations` """ api_version = self._get_api_version('certificates') if api_version == '2017-07-01': @@ -194,10 +206,14 @@ def certificates(self): from .v2022_04_30_preview.operations import CertificatesOperations as OperationClass elif api_version == '2022-11-15-preview': from .v2022_11_15_preview.operations import CertificatesOperations as OperationClass + elif api_version == '2023-06-30': + from .v2023_06_30.operations import CertificatesOperations as OperationClass + elif api_version == '2023-06-30-preview': + from .v2023_06_30_preview.operations import CertificatesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'certificates'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def iot_hub(self): @@ -213,6 +229,8 @@ def iot_hub(self): * 2021-07-02: :class:`IotHubOperations` * 2022-04-30-preview: :class:`IotHubOperations` * 2022-11-15-preview: :class:`IotHubOperations` + * 2023-06-30: :class:`IotHubOperations` + * 2023-06-30-preview: :class:`IotHubOperations` """ api_version = self._get_api_version('iot_hub') if api_version == '2019-03-22': @@ -235,10 +253,14 @@ def iot_hub(self): from .v2022_04_30_preview.operations import IotHubOperations as OperationClass elif api_version == '2022-11-15-preview': from .v2022_11_15_preview.operations import IotHubOperations as OperationClass + elif api_version == '2023-06-30': + from .v2023_06_30.operations import IotHubOperations as OperationClass + elif api_version == '2023-06-30-preview': + from .v2023_06_30_preview.operations import IotHubOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'iot_hub'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def iot_hub_resource(self): @@ -259,6 +281,8 @@ def iot_hub_resource(self): * 2021-07-02: :class:`IotHubResourceOperations` * 2022-04-30-preview: :class:`IotHubResourceOperations` * 2022-11-15-preview: :class:`IotHubResourceOperations` + * 2023-06-30: :class:`IotHubResourceOperations` + * 2023-06-30-preview: :class:`IotHubResourceOperations` """ api_version = self._get_api_version('iot_hub_resource') if api_version == '2016-02-03': @@ -291,10 +315,14 @@ def iot_hub_resource(self): from .v2022_04_30_preview.operations import IotHubResourceOperations as OperationClass elif api_version == '2022-11-15-preview': from .v2022_11_15_preview.operations import IotHubResourceOperations as OperationClass + elif api_version == '2023-06-30': + from .v2023_06_30.operations import IotHubResourceOperations as OperationClass + elif api_version == '2023-06-30-preview': + from .v2023_06_30_preview.operations import IotHubResourceOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'iot_hub_resource'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def operations(self): @@ -313,6 +341,8 @@ def operations(self): * 2021-07-02: :class:`Operations` * 2022-04-30-preview: :class:`Operations` * 2022-11-15-preview: :class:`Operations` + * 2023-06-30: :class:`Operations` + * 2023-06-30-preview: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2017-07-01': @@ -341,10 +371,14 @@ def operations(self): from .v2022_04_30_preview.operations import Operations as OperationClass elif api_version == '2022-11-15-preview': from .v2022_11_15_preview.operations import Operations as OperationClass + elif api_version == '2023-06-30': + from .v2023_06_30.operations import Operations as OperationClass + elif api_version == '2023-06-30-preview': + from .v2023_06_30_preview.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def private_endpoint_connections(self): @@ -357,6 +391,8 @@ def private_endpoint_connections(self): * 2021-07-02: :class:`PrivateEndpointConnectionsOperations` * 2022-04-30-preview: :class:`PrivateEndpointConnectionsOperations` * 2022-11-15-preview: :class:`PrivateEndpointConnectionsOperations` + * 2023-06-30: :class:`PrivateEndpointConnectionsOperations` + * 2023-06-30-preview: :class:`PrivateEndpointConnectionsOperations` """ api_version = self._get_api_version('private_endpoint_connections') if api_version == '2020-03-01': @@ -373,10 +409,14 @@ def private_endpoint_connections(self): from .v2022_04_30_preview.operations import PrivateEndpointConnectionsOperations as OperationClass elif api_version == '2022-11-15-preview': from .v2022_11_15_preview.operations import PrivateEndpointConnectionsOperations as OperationClass + elif api_version == '2023-06-30': + from .v2023_06_30.operations import PrivateEndpointConnectionsOperations as OperationClass + elif api_version == '2023-06-30-preview': + from .v2023_06_30_preview.operations import PrivateEndpointConnectionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'private_endpoint_connections'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def private_link_resources(self): @@ -389,6 +429,8 @@ def private_link_resources(self): * 2021-07-02: :class:`PrivateLinkResourcesOperations` * 2022-04-30-preview: :class:`PrivateLinkResourcesOperations` * 2022-11-15-preview: :class:`PrivateLinkResourcesOperations` + * 2023-06-30: :class:`PrivateLinkResourcesOperations` + * 2023-06-30-preview: :class:`PrivateLinkResourcesOperations` """ api_version = self._get_api_version('private_link_resources') if api_version == '2020-03-01': @@ -405,10 +447,14 @@ def private_link_resources(self): from .v2022_04_30_preview.operations import PrivateLinkResourcesOperations as OperationClass elif api_version == '2022-11-15-preview': from .v2022_11_15_preview.operations import PrivateLinkResourcesOperations as OperationClass + elif api_version == '2023-06-30': + from .v2023_06_30.operations import PrivateLinkResourcesOperations as OperationClass + elif api_version == '2023-06-30-preview': + from .v2023_06_30_preview.operations import PrivateLinkResourcesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'private_link_resources'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def resource_provider_common(self): @@ -425,6 +471,8 @@ def resource_provider_common(self): * 2021-07-02: :class:`ResourceProviderCommonOperations` * 2022-04-30-preview: :class:`ResourceProviderCommonOperations` * 2022-11-15-preview: :class:`ResourceProviderCommonOperations` + * 2023-06-30: :class:`ResourceProviderCommonOperations` + * 2023-06-30-preview: :class:`ResourceProviderCommonOperations` """ api_version = self._get_api_version('resource_provider_common') if api_version == '2018-04-01': @@ -449,10 +497,14 @@ def resource_provider_common(self): from .v2022_04_30_preview.operations import ResourceProviderCommonOperations as OperationClass elif api_version == '2022-11-15-preview': from .v2022_11_15_preview.operations import ResourceProviderCommonOperations as OperationClass + elif api_version == '2023-06-30': + from .v2023_06_30.operations import ResourceProviderCommonOperations as OperationClass + elif api_version == '2023-06-30-preview': + from .v2023_06_30_preview.operations import ResourceProviderCommonOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'resource_provider_common'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) def close(self): self._client.close() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_serialization.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_serialization.py index 25467dfc00bb..a00658b1fc19 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_serialization.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_serialization.py @@ -631,7 +631,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if xml_desc.get("attr", False): if xml_ns: ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) serialized.set(xml_name, new_attr) # type: ignore continue if xml_desc.get("text", False): @@ -664,8 +664,9 @@ def _serialize(self, target_obj, data_type=None, **kwargs): _serialized.update(_new_attr) # type: ignore _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] - except ValueError: - continue + except ValueError as err: + if isinstance(err, SerializationError): + raise except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) @@ -743,6 +744,8 @@ def query(self, name, data, data_type, **kwargs): :param data: The data to be serialized. :param str data_type: The type to be serialized from. + :keyword bool skip_quote: Whether to skip quote the serialized result. + Defaults to False. :rtype: str :raises: TypeError if serialization fails. :raises: ValueError if data is None @@ -751,10 +754,8 @@ def query(self, name, data, data_type, **kwargs): # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] - if not kwargs.get("skip_quote", False): - data = [quote(str(d), safe="") for d in data] - return str(self.serialize_iter(data, internal_data_type, **kwargs)) + do_quote = not kwargs.get('skip_quote', False) + return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs)) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -893,6 +894,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. + :keyword bool do_quote: Whether to quote the serialized result of each iterable element. + Defaults to False. :rtype: list, str """ if isinstance(data, str): @@ -905,9 +908,18 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): for d in data: try: serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized.append(None) + if kwargs.get('do_quote', False): + serialized = [ + '' if s is None else quote(str(s), safe='') + for s + in serialized + ] + if div: serialized = ["" if s is None else str(s) for s in serialized] serialized = div.join(serialized) @@ -952,7 +964,9 @@ def serialize_dict(self, attr, dict_type, **kwargs): for key, value in attr.items(): try: serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized[self.serialize_unicode(key)] = None if "xml" in serialization_ctxt: @@ -1273,7 +1287,7 @@ def _extract_name_from_internal_type(internal_type): xml_name = internal_type_xml_map.get("name", internal_type.__name__) xml_ns = internal_type_xml_map.get("ns", None) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) return xml_name @@ -1297,7 +1311,7 @@ def xml_key_extractor(attr, attr_desc, data): # Integrate namespace if necessary xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) # If it's an attribute, that's simple if xml_desc.get("attr", False): diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/_iot_hub_client.py index 84e2ac460fe0..31e1e371bb12 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/_iot_hub_client.py @@ -53,7 +53,7 @@ class IotHubClient(MultiApiClientMixin, _SDKClient): :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ - DEFAULT_API_VERSION = '2021-07-02' + DEFAULT_API_VERSION = '2023-06-30' _PROFILE_TAG = "azure.mgmt.iothub.IotHubClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -71,6 +71,8 @@ def __init__( profile: KnownProfiles = KnownProfiles.default, **kwargs: Any ) -> None: + if api_version: + kwargs.setdefault('api_version', api_version) self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(IotHubClient, self).__init__( @@ -101,6 +103,8 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2021-07-02: :mod:`v2021_07_02.models` * 2022-04-30-preview: :mod:`v2022_04_30_preview.models` * 2022-11-15-preview: :mod:`v2022_11_15_preview.models` + * 2023-06-30: :mod:`v2023_06_30.models` + * 2023-06-30-preview: :mod:`v2023_06_30_preview.models` """ if api_version == '2016-02-03': from ..v2016_02_03 import models @@ -147,6 +151,12 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2022-11-15-preview': from ..v2022_11_15_preview import models return models + elif api_version == '2023-06-30': + from ..v2023_06_30 import models + return models + elif api_version == '2023-06-30-preview': + from ..v2023_06_30_preview import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -166,6 +176,8 @@ def certificates(self): * 2021-07-02: :class:`CertificatesOperations` * 2022-04-30-preview: :class:`CertificatesOperations` * 2022-11-15-preview: :class:`CertificatesOperations` + * 2023-06-30: :class:`CertificatesOperations` + * 2023-06-30-preview: :class:`CertificatesOperations` """ api_version = self._get_api_version('certificates') if api_version == '2017-07-01': @@ -194,10 +206,14 @@ def certificates(self): from ..v2022_04_30_preview.aio.operations import CertificatesOperations as OperationClass elif api_version == '2022-11-15-preview': from ..v2022_11_15_preview.aio.operations import CertificatesOperations as OperationClass + elif api_version == '2023-06-30': + from ..v2023_06_30.aio.operations import CertificatesOperations as OperationClass + elif api_version == '2023-06-30-preview': + from ..v2023_06_30_preview.aio.operations import CertificatesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'certificates'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def iot_hub(self): @@ -213,6 +229,8 @@ def iot_hub(self): * 2021-07-02: :class:`IotHubOperations` * 2022-04-30-preview: :class:`IotHubOperations` * 2022-11-15-preview: :class:`IotHubOperations` + * 2023-06-30: :class:`IotHubOperations` + * 2023-06-30-preview: :class:`IotHubOperations` """ api_version = self._get_api_version('iot_hub') if api_version == '2019-03-22': @@ -235,10 +253,14 @@ def iot_hub(self): from ..v2022_04_30_preview.aio.operations import IotHubOperations as OperationClass elif api_version == '2022-11-15-preview': from ..v2022_11_15_preview.aio.operations import IotHubOperations as OperationClass + elif api_version == '2023-06-30': + from ..v2023_06_30.aio.operations import IotHubOperations as OperationClass + elif api_version == '2023-06-30-preview': + from ..v2023_06_30_preview.aio.operations import IotHubOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'iot_hub'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def iot_hub_resource(self): @@ -259,6 +281,8 @@ def iot_hub_resource(self): * 2021-07-02: :class:`IotHubResourceOperations` * 2022-04-30-preview: :class:`IotHubResourceOperations` * 2022-11-15-preview: :class:`IotHubResourceOperations` + * 2023-06-30: :class:`IotHubResourceOperations` + * 2023-06-30-preview: :class:`IotHubResourceOperations` """ api_version = self._get_api_version('iot_hub_resource') if api_version == '2016-02-03': @@ -291,10 +315,14 @@ def iot_hub_resource(self): from ..v2022_04_30_preview.aio.operations import IotHubResourceOperations as OperationClass elif api_version == '2022-11-15-preview': from ..v2022_11_15_preview.aio.operations import IotHubResourceOperations as OperationClass + elif api_version == '2023-06-30': + from ..v2023_06_30.aio.operations import IotHubResourceOperations as OperationClass + elif api_version == '2023-06-30-preview': + from ..v2023_06_30_preview.aio.operations import IotHubResourceOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'iot_hub_resource'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def operations(self): @@ -313,6 +341,8 @@ def operations(self): * 2021-07-02: :class:`Operations` * 2022-04-30-preview: :class:`Operations` * 2022-11-15-preview: :class:`Operations` + * 2023-06-30: :class:`Operations` + * 2023-06-30-preview: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2017-07-01': @@ -341,10 +371,14 @@ def operations(self): from ..v2022_04_30_preview.aio.operations import Operations as OperationClass elif api_version == '2022-11-15-preview': from ..v2022_11_15_preview.aio.operations import Operations as OperationClass + elif api_version == '2023-06-30': + from ..v2023_06_30.aio.operations import Operations as OperationClass + elif api_version == '2023-06-30-preview': + from ..v2023_06_30_preview.aio.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def private_endpoint_connections(self): @@ -357,6 +391,8 @@ def private_endpoint_connections(self): * 2021-07-02: :class:`PrivateEndpointConnectionsOperations` * 2022-04-30-preview: :class:`PrivateEndpointConnectionsOperations` * 2022-11-15-preview: :class:`PrivateEndpointConnectionsOperations` + * 2023-06-30: :class:`PrivateEndpointConnectionsOperations` + * 2023-06-30-preview: :class:`PrivateEndpointConnectionsOperations` """ api_version = self._get_api_version('private_endpoint_connections') if api_version == '2020-03-01': @@ -373,10 +409,14 @@ def private_endpoint_connections(self): from ..v2022_04_30_preview.aio.operations import PrivateEndpointConnectionsOperations as OperationClass elif api_version == '2022-11-15-preview': from ..v2022_11_15_preview.aio.operations import PrivateEndpointConnectionsOperations as OperationClass + elif api_version == '2023-06-30': + from ..v2023_06_30.aio.operations import PrivateEndpointConnectionsOperations as OperationClass + elif api_version == '2023-06-30-preview': + from ..v2023_06_30_preview.aio.operations import PrivateEndpointConnectionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'private_endpoint_connections'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def private_link_resources(self): @@ -389,6 +429,8 @@ def private_link_resources(self): * 2021-07-02: :class:`PrivateLinkResourcesOperations` * 2022-04-30-preview: :class:`PrivateLinkResourcesOperations` * 2022-11-15-preview: :class:`PrivateLinkResourcesOperations` + * 2023-06-30: :class:`PrivateLinkResourcesOperations` + * 2023-06-30-preview: :class:`PrivateLinkResourcesOperations` """ api_version = self._get_api_version('private_link_resources') if api_version == '2020-03-01': @@ -405,10 +447,14 @@ def private_link_resources(self): from ..v2022_04_30_preview.aio.operations import PrivateLinkResourcesOperations as OperationClass elif api_version == '2022-11-15-preview': from ..v2022_11_15_preview.aio.operations import PrivateLinkResourcesOperations as OperationClass + elif api_version == '2023-06-30': + from ..v2023_06_30.aio.operations import PrivateLinkResourcesOperations as OperationClass + elif api_version == '2023-06-30-preview': + from ..v2023_06_30_preview.aio.operations import PrivateLinkResourcesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'private_link_resources'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def resource_provider_common(self): @@ -425,6 +471,8 @@ def resource_provider_common(self): * 2021-07-02: :class:`ResourceProviderCommonOperations` * 2022-04-30-preview: :class:`ResourceProviderCommonOperations` * 2022-11-15-preview: :class:`ResourceProviderCommonOperations` + * 2023-06-30: :class:`ResourceProviderCommonOperations` + * 2023-06-30-preview: :class:`ResourceProviderCommonOperations` """ api_version = self._get_api_version('resource_provider_common') if api_version == '2018-04-01': @@ -449,10 +497,14 @@ def resource_provider_common(self): from ..v2022_04_30_preview.aio.operations import ResourceProviderCommonOperations as OperationClass elif api_version == '2022-11-15-preview': from ..v2022_11_15_preview.aio.operations import ResourceProviderCommonOperations as OperationClass + elif api_version == '2023-06-30': + from ..v2023_06_30.aio.operations import ResourceProviderCommonOperations as OperationClass + elif api_version == '2023-06-30-preview': + from ..v2023_06_30_preview.aio.operations import ResourceProviderCommonOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'resource_provider_common'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) async def close(self): await self._client.close() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/models.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/models.py index 6fb6f205536e..a1be3842afe2 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/models.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/models.py @@ -4,4 +4,4 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -from .v2021_07_02.models import * +from .v2023_06_30.models import * diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_configuration.py index 83e3cf977747..2bd099b647b0 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", "2016-02-03") + api_version: str = kwargs.pop("api_version", "2016-02-03") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_iot_hub_client.py index 165f9173ddc2..bd57604d1c4a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_iot_hub_client.py @@ -54,7 +54,9 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2016-02-03" + ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): if files: request.set_formdata_body(files) return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_version.py index 1d9186e2318f..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.4.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_configuration.py index fecc19feceaa..2a14e4e3cae1 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", "2016-02-03") + api_version: str = kwargs.pop("api_version", "2016-02-03") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_iot_hub_client.py index 1cb2d3b3dac5..fe379c896db3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_iot_hub_client.py @@ -55,7 +55,9 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2016-02-03" + ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/operations/_iot_hub_resource_operations.py index 2650b53920fa..9d080ec80a47 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -53,10 +53,6 @@ build_list_keys_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -79,6 +75,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -106,7 +103,7 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -162,14 +159,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -343,7 +340,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -402,7 +399,7 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) request = build_delete_request( @@ -478,7 +475,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -535,7 +532,7 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDe _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -624,7 +621,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -724,7 +721,7 @@ async def get_stats( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) request = build_get_stats_request( @@ -784,7 +781,7 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -881,7 +878,7 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) error_map = { @@ -988,7 +985,7 @@ async def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_get_event_hub_consumer_group_request( @@ -1061,7 +1058,7 @@ async def create_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_create_event_hub_consumer_group_request( @@ -1134,7 +1131,7 @@ async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-retur _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_event_hub_consumer_group_request( @@ -1193,7 +1190,7 @@ def list_jobs( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) error_map = { @@ -1298,7 +1295,7 @@ async def get_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) request = build_get_job_request( @@ -1359,7 +1356,7 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) error_map = { @@ -1502,14 +1499,14 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -1574,7 +1571,7 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { @@ -1679,7 +1676,7 @@ async def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) request = build_get_keys_for_key_name_request( @@ -1829,14 +1826,14 @@ async def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -1990,14 +1987,14 @@ async def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_iot_hub_client_enums.py index d36ac303bb1f..dfcfe92b4aa7 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_iot_hub_client_enums.py @@ -101,6 +101,7 @@ class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): REBOOT_DEVICE = "rebootDevice" FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" + IMPORT_ENUM = "import" class OperationMonitoringLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_models_py3.py index f5a423435543..d1c62bb56a20 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_models_py3.py @@ -967,7 +967,7 @@ class JobResponse(_serialization.Model): :vartype end_time_utc: ~datetime.datetime :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", - "factoryResetDevice", and "firmwareUpdate". + "factoryResetDevice", "firmwareUpdate", and "import". :vartype type: str or ~azure.mgmt.iothub.v2016_02_03.models.JobType :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", "completed", "failed", and "cancelled". diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/operations/_iot_hub_resource_operations.py index 663ef287e4e7..e877bae44dbc 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -30,12 +30,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +43,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) accept = _headers.pop("Accept", "application/json, text/json") # Construct URL @@ -61,7 +57,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +74,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json, text/json") @@ -93,7 +89,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -112,7 +108,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) accept = _headers.pop("Accept", "application/json, text/json") # Construct URL @@ -126,7 +122,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -141,7 +137,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) accept = _headers.pop("Accept", "application/json, text/json") # Construct URL @@ -150,7 +146,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -165,7 +161,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) accept = _headers.pop("Accept", "application/json, text/json") # Construct URL @@ -178,7 +174,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -195,7 +191,7 @@ def build_get_stats_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) accept = _headers.pop("Accept", "application/json, text/json") # Construct URL @@ -209,7 +205,7 @@ def build_get_stats_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -226,7 +222,7 @@ def build_get_valid_skus_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) accept = _headers.pop("Accept", "application/json, text/json") # Construct URL @@ -240,7 +236,7 @@ def build_get_valid_skus_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -257,7 +253,7 @@ def build_list_event_hub_consumer_groups_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) accept = _headers.pop("Accept", "application/json, text/json") # Construct URL @@ -272,7 +268,7 @@ def build_list_event_hub_consumer_groups_request( "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -294,7 +290,7 @@ def build_get_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) accept = _headers.pop("Accept", "application/json, text/json") # Construct URL @@ -310,7 +306,7 @@ def build_get_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -332,7 +328,7 @@ def build_create_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) accept = _headers.pop("Accept", "application/json, text/json") # Construct URL @@ -348,7 +344,7 @@ def build_create_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -370,7 +366,7 @@ def build_delete_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) accept = _headers.pop("Accept", "application/json, text/json") # Construct URL @@ -386,7 +382,7 @@ def build_delete_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -403,7 +399,7 @@ def build_list_jobs_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) accept = _headers.pop("Accept", "application/json, text/json") # Construct URL @@ -417,7 +413,7 @@ def build_list_jobs_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -434,7 +430,7 @@ def build_get_job_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) accept = _headers.pop("Accept", "application/json, text/json") # Construct URL @@ -449,7 +445,7 @@ def build_get_job_request( "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -466,7 +462,7 @@ def build_get_quota_metrics_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) accept = _headers.pop("Accept", "application/json, text/json") # Construct URL @@ -480,7 +476,7 @@ def build_get_quota_metrics_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -495,7 +491,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json, text/json") @@ -507,7 +503,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -526,7 +522,7 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) accept = _headers.pop("Accept", "application/json, text/json") # Construct URL @@ -540,7 +536,7 @@ def build_list_keys_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -557,7 +553,7 @@ def build_get_keys_for_key_name_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) accept = _headers.pop("Accept", "application/json, text/json") # Construct URL @@ -572,7 +568,7 @@ def build_get_keys_for_key_name_request( "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -589,7 +585,7 @@ def build_export_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json, text/json") @@ -604,7 +600,7 @@ def build_export_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -623,7 +619,7 @@ def build_import_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json, text/json") @@ -638,7 +634,7 @@ def build_import_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -669,6 +665,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -696,7 +693,7 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -752,14 +749,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -930,7 +927,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -989,7 +986,7 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) request = build_delete_request( @@ -1064,7 +1061,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1120,7 +1117,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescrip _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1206,7 +1203,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1304,7 +1301,7 @@ def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) request = build_get_stats_request( @@ -1364,7 +1361,7 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1461,7 +1458,7 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) error_map = { @@ -1568,7 +1565,7 @@ def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_get_event_hub_consumer_group_request( @@ -1641,7 +1638,7 @@ def create_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_create_event_hub_consumer_group_request( @@ -1714,7 +1711,7 @@ def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-stat _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_event_hub_consumer_group_request( @@ -1770,7 +1767,7 @@ def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) error_map = { @@ -1873,7 +1870,7 @@ def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **k _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) request = build_get_job_request( @@ -1934,7 +1931,7 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) error_map = { @@ -2077,14 +2074,14 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -2149,7 +2146,7 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { @@ -2254,7 +2251,7 @@ def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) request = build_get_keys_for_key_name_request( @@ -2404,14 +2401,14 @@ def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -2565,14 +2562,14 @@ def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2016-02-03"] = kwargs.pop("api_version", _params.pop("api-version", "2016-02-03")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2016-02-03")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_configuration.py index 2c7d4dfbbf14..14db50baaf02 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", "2017-01-19") + api_version: str = kwargs.pop("api_version", "2017-01-19") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_iot_hub_client.py index 2da1f2d62936..d3dc2179b9cd 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_iot_hub_client.py @@ -54,7 +54,9 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2017-01-19" + ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): if files: request.set_formdata_body(files) return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_version.py index 1d9186e2318f..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.4.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_configuration.py index 43001a34920d..ff1cd674b074 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", "2017-01-19") + api_version: str = kwargs.pop("api_version", "2017-01-19") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_iot_hub_client.py index 7de77c63d16f..58f52f97d220 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_iot_hub_client.py @@ -55,7 +55,9 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2017-01-19" + ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/operations/_iot_hub_resource_operations.py index cd4b3e2a1c08..e57a591a8718 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -53,10 +53,6 @@ build_list_keys_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -79,6 +75,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -106,7 +103,7 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -162,14 +159,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -343,7 +340,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -402,7 +399,7 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) request = build_delete_request( @@ -478,7 +475,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -535,7 +532,7 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDe _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -624,7 +621,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -724,7 +721,7 @@ async def get_stats( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) request = build_get_stats_request( @@ -784,7 +781,7 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -881,7 +878,7 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) error_map = { @@ -988,7 +985,7 @@ async def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_get_event_hub_consumer_group_request( @@ -1061,7 +1058,7 @@ async def create_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_create_event_hub_consumer_group_request( @@ -1134,7 +1131,7 @@ async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-retur _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_event_hub_consumer_group_request( @@ -1193,7 +1190,7 @@ def list_jobs( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) error_map = { @@ -1298,7 +1295,7 @@ async def get_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) request = build_get_job_request( @@ -1359,7 +1356,7 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) error_map = { @@ -1502,14 +1499,14 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -1574,7 +1571,7 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { @@ -1679,7 +1676,7 @@ async def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) request = build_get_keys_for_key_name_request( @@ -1829,14 +1826,14 @@ async def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -1990,14 +1987,14 @@ async def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_iot_hub_client_enums.py index ab000036578c..ce288bade6cc 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_iot_hub_client_enums.py @@ -101,6 +101,7 @@ class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): REBOOT_DEVICE = "rebootDevice" FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" + IMPORT_ENUM = "import" class OperationMonitoringLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_models_py3.py index d6c0d7659470..cae982bc098d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_models_py3.py @@ -1043,7 +1043,7 @@ class JobResponse(_serialization.Model): :vartype end_time_utc: ~datetime.datetime :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", - "factoryResetDevice", and "firmwareUpdate". + "factoryResetDevice", "firmwareUpdate", and "import". :vartype type: str or ~azure.mgmt.iothub.v2017_01_19.models.JobType :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", "completed", "failed", and "cancelled". diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/operations/_iot_hub_resource_operations.py index 8c16279e0753..0d9a4acea497 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -30,12 +30,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +43,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +57,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +74,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -93,7 +89,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -112,7 +108,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -126,7 +122,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -141,7 +137,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -150,7 +146,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -165,7 +161,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -178,7 +174,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -195,7 +191,7 @@ def build_get_stats_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -209,7 +205,7 @@ def build_get_stats_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -226,7 +222,7 @@ def build_get_valid_skus_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -240,7 +236,7 @@ def build_get_valid_skus_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -257,7 +253,7 @@ def build_list_event_hub_consumer_groups_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -272,7 +268,7 @@ def build_list_event_hub_consumer_groups_request( "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -294,7 +290,7 @@ def build_get_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -310,7 +306,7 @@ def build_get_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -332,7 +328,7 @@ def build_create_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -348,7 +344,7 @@ def build_create_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -370,7 +366,7 @@ def build_delete_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -386,7 +382,7 @@ def build_delete_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -403,7 +399,7 @@ def build_list_jobs_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -417,7 +413,7 @@ def build_list_jobs_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -434,7 +430,7 @@ def build_get_job_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -449,7 +445,7 @@ def build_get_job_request( "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -466,7 +462,7 @@ def build_get_quota_metrics_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -480,7 +476,7 @@ def build_get_quota_metrics_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -495,7 +491,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -507,7 +503,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -526,7 +522,7 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -540,7 +536,7 @@ def build_list_keys_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -557,7 +553,7 @@ def build_get_keys_for_key_name_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -572,7 +568,7 @@ def build_get_keys_for_key_name_request( "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -589,7 +585,7 @@ def build_export_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -604,7 +600,7 @@ def build_export_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -623,7 +619,7 @@ def build_import_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -638,7 +634,7 @@ def build_import_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -669,6 +665,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -696,7 +693,7 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -752,14 +749,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -930,7 +927,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -989,7 +986,7 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) request = build_delete_request( @@ -1064,7 +1061,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1120,7 +1117,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescrip _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1206,7 +1203,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1304,7 +1301,7 @@ def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) request = build_get_stats_request( @@ -1364,7 +1361,7 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1461,7 +1458,7 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) error_map = { @@ -1568,7 +1565,7 @@ def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_get_event_hub_consumer_group_request( @@ -1641,7 +1638,7 @@ def create_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_create_event_hub_consumer_group_request( @@ -1714,7 +1711,7 @@ def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-stat _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_event_hub_consumer_group_request( @@ -1770,7 +1767,7 @@ def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) error_map = { @@ -1873,7 +1870,7 @@ def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **k _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) request = build_get_job_request( @@ -1934,7 +1931,7 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) error_map = { @@ -2077,14 +2074,14 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -2149,7 +2146,7 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { @@ -2254,7 +2251,7 @@ def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) request = build_get_keys_for_key_name_request( @@ -2404,14 +2401,14 @@ def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -2565,14 +2562,14 @@ def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-01-19"] = kwargs.pop("api_version", _params.pop("api-version", "2017-01-19")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-01-19")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_configuration.py index e38ae7135670..2cbd20a90d16 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", "2017-07-01") + api_version: str = kwargs.pop("api_version", "2017-07-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_iot_hub_client.py index d8c2715c89f7..eaa5568b5a6a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_iot_hub_client.py @@ -58,9 +58,13 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2017-07-01") + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2017-07-01" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2017-07-01" + ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): if files: request.set_formdata_body(files) return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_version.py index 1d9186e2318f..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.4.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_configuration.py index 584edefb0edc..6a55dc4d60e2 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", "2017-07-01") + api_version: str = kwargs.pop("api_version", "2017-07-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_iot_hub_client.py index 734f65b30fb6..3e74f2ff9349 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_iot_hub_client.py @@ -59,9 +59,13 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2017-07-01") + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2017-07-01" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2017-07-01" + ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_certificates_operations.py index 65ec7a769018..97469d71e00d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_certificates_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -35,10 +35,6 @@ build_verify_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list_by_iot_hub( @@ -90,7 +87,7 @@ async def list_by_iot_hub( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) request = build_list_by_iot_hub_request( @@ -158,7 +155,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -315,14 +312,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_description, (IO, bytes)): + if isinstance(certificate_description, (IOBase, bytes)): _content = certificate_description else: _json = self._serialize.body(certificate_description, "CertificateBodyDescription") @@ -403,7 +400,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -472,7 +469,7 @@ async def generate_verification_code( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) request = build_generate_verification_code_request( @@ -631,14 +628,14 @@ async def verify( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_verification_body, (IO, bytes)): + if isinstance(certificate_verification_body, (IOBase, bytes)): _content = certificate_verification_body else: _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_iot_hub_resource_operations.py index d526db87ba85..83b4b5f9128f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -53,10 +53,6 @@ build_list_keys_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -79,6 +75,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -106,7 +103,7 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -163,14 +160,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -357,7 +354,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -417,7 +414,7 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) request = build_delete_request( @@ -493,7 +490,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -550,7 +547,7 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDe _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -638,7 +635,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -738,7 +735,7 @@ async def get_stats( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) request = build_get_stats_request( @@ -798,7 +795,7 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -895,7 +892,7 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) error_map = { @@ -1002,7 +999,7 @@ async def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_get_event_hub_consumer_group_request( @@ -1075,7 +1072,7 @@ async def create_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_create_event_hub_consumer_group_request( @@ -1148,7 +1145,7 @@ async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-retur _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_event_hub_consumer_group_request( @@ -1207,7 +1204,7 @@ def list_jobs( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) error_map = { @@ -1312,7 +1309,7 @@ async def get_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) request = build_get_job_request( @@ -1373,7 +1370,7 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) error_map = { @@ -1516,14 +1513,14 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -1588,7 +1585,7 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { @@ -1693,7 +1690,7 @@ async def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) request = build_get_keys_for_key_name_request( @@ -1843,14 +1840,14 @@ async def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -2004,14 +2001,14 @@ async def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_operations.py index 56b9cce358b9..0edb08373f8a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._operations import build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,6 +51,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: @@ -70,7 +66,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_iot_hub_client_enums.py index ab000036578c..ce288bade6cc 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_iot_hub_client_enums.py @@ -101,6 +101,7 @@ class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): REBOOT_DEVICE = "rebootDevice" FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" + IMPORT_ENUM = "import" class OperationMonitoringLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_models_py3.py index 15965b3e1fe9..db97f7070cc3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_models_py3.py @@ -1302,7 +1302,7 @@ class JobResponse(_serialization.Model): :vartype end_time_utc: ~datetime.datetime :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", - "factoryResetDevice", and "firmwareUpdate". + "factoryResetDevice", "firmwareUpdate", and "import". :vartype type: str or ~azure.mgmt.iothub.v2017_07_01.models.JobType :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", "completed", "failed", and "cancelled". diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_certificates_operations.py index 4094acf3c9d4..075fb4da87dc 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_certificates_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -26,12 +26,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +41,7 @@ def build_list_by_iot_hub_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +55,7 @@ def build_list_by_iot_hub_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +72,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -93,7 +89,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,7 +112,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -134,7 +130,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -161,7 +157,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -178,7 +174,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -202,7 +198,7 @@ def build_generate_verification_code_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -219,7 +215,7 @@ def build_generate_verification_code_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -243,7 +239,7 @@ def build_verify_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -261,7 +257,7 @@ def build_verify_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -293,6 +289,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_iot_hub( @@ -322,7 +319,7 @@ def list_by_iot_hub( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) request = build_list_by_iot_hub_request( @@ -390,7 +387,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -547,14 +544,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_description, (IO, bytes)): + if isinstance(certificate_description, (IOBase, bytes)): _content = certificate_description else: _json = self._serialize.body(certificate_description, "CertificateBodyDescription") @@ -635,7 +632,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -704,7 +701,7 @@ def generate_verification_code( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) request = build_generate_verification_code_request( @@ -863,14 +860,14 @@ def verify( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_verification_body, (IO, bytes)): + if isinstance(certificate_verification_body, (IOBase, bytes)): _content = certificate_verification_body else: _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_iot_hub_resource_operations.py index 8c3f68fa6175..7e02bef480f3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -30,12 +30,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +43,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +57,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +74,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -93,7 +89,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +110,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -128,7 +124,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -143,7 +139,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -152,7 +148,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -167,7 +163,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -180,7 +176,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -197,7 +193,7 @@ def build_get_stats_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -211,7 +207,7 @@ def build_get_stats_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -228,7 +224,7 @@ def build_get_valid_skus_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -242,7 +238,7 @@ def build_get_valid_skus_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -259,7 +255,7 @@ def build_list_event_hub_consumer_groups_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -274,7 +270,7 @@ def build_list_event_hub_consumer_groups_request( "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -296,7 +292,7 @@ def build_get_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -312,7 +308,7 @@ def build_get_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -334,7 +330,7 @@ def build_create_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -350,7 +346,7 @@ def build_create_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -372,7 +368,7 @@ def build_delete_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -388,7 +384,7 @@ def build_delete_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -405,7 +401,7 @@ def build_list_jobs_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -419,7 +415,7 @@ def build_list_jobs_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -436,7 +432,7 @@ def build_get_job_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -451,7 +447,7 @@ def build_get_job_request( "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -468,7 +464,7 @@ def build_get_quota_metrics_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -482,7 +478,7 @@ def build_get_quota_metrics_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -497,7 +493,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -509,7 +505,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -528,7 +524,7 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -542,7 +538,7 @@ def build_list_keys_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -559,7 +555,7 @@ def build_get_keys_for_key_name_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -574,7 +570,7 @@ def build_get_keys_for_key_name_request( "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -591,7 +587,7 @@ def build_export_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -606,7 +602,7 @@ def build_export_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -625,7 +621,7 @@ def build_import_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -640,7 +636,7 @@ def build_import_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -671,6 +667,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -698,7 +695,7 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -755,14 +752,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -946,7 +943,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1006,7 +1003,7 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) request = build_delete_request( @@ -1081,7 +1078,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1137,7 +1134,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescrip _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1222,7 +1219,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1320,7 +1317,7 @@ def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) request = build_get_stats_request( @@ -1380,7 +1377,7 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1477,7 +1474,7 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) error_map = { @@ -1584,7 +1581,7 @@ def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_get_event_hub_consumer_group_request( @@ -1657,7 +1654,7 @@ def create_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_create_event_hub_consumer_group_request( @@ -1730,7 +1727,7 @@ def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-stat _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_event_hub_consumer_group_request( @@ -1786,7 +1783,7 @@ def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) error_map = { @@ -1889,7 +1886,7 @@ def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **k _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) request = build_get_job_request( @@ -1950,7 +1947,7 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) error_map = { @@ -2093,14 +2090,14 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -2165,7 +2162,7 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { @@ -2270,7 +2267,7 @@ def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) request = build_get_keys_for_key_name_request( @@ -2420,14 +2417,14 @@ def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -2581,14 +2578,14 @@ def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_operations.py index 95cf125e0b0a..1dc093f8c3c9 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +40,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,6 +73,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: @@ -91,7 +87,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2017-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-07-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_configuration.py index c70e009c1afa..670b711f8e9f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", "2018-01-22") + api_version: str = kwargs.pop("api_version", "2018-01-22") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_iot_hub_client.py index ed611ac054d0..4d1f8dcd91ef 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_iot_hub_client.py @@ -58,9 +58,13 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2018-01-22") + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2018-01-22" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2018-01-22" + ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): if files: request.set_formdata_body(files) return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_version.py index 1d9186e2318f..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.4.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_configuration.py index 48dd29af1cd4..499e0bcd128b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", "2018-01-22") + api_version: str = kwargs.pop("api_version", "2018-01-22") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_iot_hub_client.py index c4fdb6296e3b..3bd23ee6cdf7 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_iot_hub_client.py @@ -59,9 +59,13 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2018-01-22") + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2018-01-22" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2018-01-22" + ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_certificates_operations.py index de520fdd801f..ea6bd33cce08 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_certificates_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -35,10 +35,6 @@ build_verify_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list_by_iot_hub( @@ -90,7 +87,7 @@ async def list_by_iot_hub( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) request = build_list_by_iot_hub_request( @@ -158,7 +155,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -315,14 +312,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_description, (IO, bytes)): + if isinstance(certificate_description, (IOBase, bytes)): _content = certificate_description else: _json = self._serialize.body(certificate_description, "CertificateBodyDescription") @@ -403,7 +400,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -472,7 +469,7 @@ async def generate_verification_code( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) request = build_generate_verification_code_request( @@ -631,14 +628,14 @@ async def verify( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_verification_body, (IO, bytes)): + if isinstance(certificate_verification_body, (IOBase, bytes)): _content = certificate_verification_body else: _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_iot_hub_resource_operations.py index 81d9f20727d6..312ffa52056f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -54,10 +54,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -80,6 +76,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -107,7 +104,7 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -164,14 +161,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -358,7 +355,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -418,14 +415,14 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_tags, (IO, bytes)): + if isinstance(iot_hub_tags, (IOBase, bytes)): _content = iot_hub_tags else: _json = self._serialize.body(iot_hub_tags, "TagsResource") @@ -578,7 +575,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -637,7 +634,7 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) request = build_delete_request( @@ -713,7 +710,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -770,7 +767,7 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDe _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -858,7 +855,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -958,7 +955,7 @@ async def get_stats( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) request = build_get_stats_request( @@ -1018,7 +1015,7 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1117,7 +1114,7 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) error_map = { @@ -1224,7 +1221,7 @@ async def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_get_event_hub_consumer_group_request( @@ -1297,7 +1294,7 @@ async def create_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_create_event_hub_consumer_group_request( @@ -1370,7 +1367,7 @@ async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-retur _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_event_hub_consumer_group_request( @@ -1429,7 +1426,7 @@ def list_jobs( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) error_map = { @@ -1534,7 +1531,7 @@ async def get_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) request = build_get_job_request( @@ -1595,7 +1592,7 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) error_map = { @@ -1738,14 +1735,14 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -1810,7 +1807,7 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { @@ -1915,7 +1912,7 @@ async def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) request = build_get_keys_for_key_name_request( @@ -2065,14 +2062,14 @@ async def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -2226,14 +2223,14 @@ async def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_operations.py index 98cc00e63bf4..0f18d766dcba 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._operations import build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,6 +51,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: @@ -70,7 +66,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_iot_hub_client_enums.py index ab000036578c..ce288bade6cc 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_iot_hub_client_enums.py @@ -101,6 +101,7 @@ class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): REBOOT_DEVICE = "rebootDevice" FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" + IMPORT_ENUM = "import" class OperationMonitoringLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_models_py3.py index 92f2b0b2eb5d..1c8a1aaabfdc 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_models_py3.py @@ -1303,7 +1303,7 @@ class JobResponse(_serialization.Model): :vartype end_time_utc: ~datetime.datetime :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", - "factoryResetDevice", and "firmwareUpdate". + "factoryResetDevice", "firmwareUpdate", and "import". :vartype type: str or ~azure.mgmt.iothub.v2018_01_22.models.JobType :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", "completed", "failed", and "cancelled". diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_certificates_operations.py index c3944bbc8a15..39bde7faf1a7 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_certificates_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -26,12 +26,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +41,7 @@ def build_list_by_iot_hub_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +55,7 @@ def build_list_by_iot_hub_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +72,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -93,7 +89,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,7 +112,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -134,7 +130,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -161,7 +157,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -178,7 +174,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -202,7 +198,7 @@ def build_generate_verification_code_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -219,7 +215,7 @@ def build_generate_verification_code_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -243,7 +239,7 @@ def build_verify_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -261,7 +257,7 @@ def build_verify_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -293,6 +289,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_iot_hub( @@ -322,7 +319,7 @@ def list_by_iot_hub( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) request = build_list_by_iot_hub_request( @@ -390,7 +387,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -547,14 +544,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_description, (IO, bytes)): + if isinstance(certificate_description, (IOBase, bytes)): _content = certificate_description else: _json = self._serialize.body(certificate_description, "CertificateBodyDescription") @@ -635,7 +632,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -704,7 +701,7 @@ def generate_verification_code( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) request = build_generate_verification_code_request( @@ -863,14 +860,14 @@ def verify( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_verification_body, (IO, bytes)): + if isinstance(certificate_verification_body, (IOBase, bytes)): _content = certificate_verification_body else: _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_iot_hub_resource_operations.py index 5d6bd7e16a7d..a7bb49bb5855 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -30,12 +30,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +43,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +57,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +74,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -93,7 +89,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +110,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -129,7 +125,7 @@ def build_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -148,7 +144,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -162,7 +158,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -177,7 +173,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -186,7 +182,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -201,7 +197,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -214,7 +210,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -231,7 +227,7 @@ def build_get_stats_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -245,7 +241,7 @@ def build_get_stats_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -262,7 +258,7 @@ def build_get_valid_skus_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -276,7 +272,7 @@ def build_get_valid_skus_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -293,7 +289,7 @@ def build_list_event_hub_consumer_groups_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -308,7 +304,7 @@ def build_list_event_hub_consumer_groups_request( "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -330,7 +326,7 @@ def build_get_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -346,7 +342,7 @@ def build_get_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -368,7 +364,7 @@ def build_create_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -384,7 +380,7 @@ def build_create_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -406,7 +402,7 @@ def build_delete_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -422,7 +418,7 @@ def build_delete_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -439,7 +435,7 @@ def build_list_jobs_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -453,7 +449,7 @@ def build_list_jobs_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -470,7 +466,7 @@ def build_get_job_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -485,7 +481,7 @@ def build_get_job_request( "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -502,7 +498,7 @@ def build_get_quota_metrics_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -516,7 +512,7 @@ def build_get_quota_metrics_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -531,7 +527,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -543,7 +539,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -562,7 +558,7 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -576,7 +572,7 @@ def build_list_keys_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -593,7 +589,7 @@ def build_get_keys_for_key_name_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -608,7 +604,7 @@ def build_get_keys_for_key_name_request( "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -625,7 +621,7 @@ def build_export_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -640,7 +636,7 @@ def build_export_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -659,7 +655,7 @@ def build_import_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -674,7 +670,7 @@ def build_import_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -705,6 +701,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -732,7 +729,7 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -789,14 +786,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -980,7 +977,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1040,14 +1037,14 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_tags, (IO, bytes)): + if isinstance(iot_hub_tags, (IOBase, bytes)): _content = iot_hub_tags else: _json = self._serialize.body(iot_hub_tags, "TagsResource") @@ -1197,7 +1194,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1256,7 +1253,7 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) request = build_delete_request( @@ -1331,7 +1328,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1387,7 +1384,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescrip _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1472,7 +1469,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1570,7 +1567,7 @@ def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) request = build_get_stats_request( @@ -1630,7 +1627,7 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1729,7 +1726,7 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) error_map = { @@ -1836,7 +1833,7 @@ def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_get_event_hub_consumer_group_request( @@ -1909,7 +1906,7 @@ def create_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_create_event_hub_consumer_group_request( @@ -1982,7 +1979,7 @@ def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-stat _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_event_hub_consumer_group_request( @@ -2038,7 +2035,7 @@ def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) error_map = { @@ -2141,7 +2138,7 @@ def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **k _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) request = build_get_job_request( @@ -2202,7 +2199,7 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) error_map = { @@ -2345,14 +2342,14 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -2417,7 +2414,7 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { @@ -2522,7 +2519,7 @@ def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) request = build_get_keys_for_key_name_request( @@ -2672,14 +2669,14 @@ def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -2833,14 +2830,14 @@ def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_operations.py index 789e9ed4d68f..901d6096ccd3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +40,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,6 +73,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: @@ -91,7 +87,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-01-22"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-01-22")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_configuration.py index b45f2e6a7f39..5445c0c1aef4 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", "2018-04-01") + api_version: str = kwargs.pop("api_version", "2018-04-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_iot_hub_client.py index 22ad5713296c..a2b280475f1f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_iot_hub_client.py @@ -61,12 +61,16 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2018-04-01") + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2018-04-01" + ) self.resource_provider_common = ResourceProviderCommonOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2018-04-01" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2018-04-01" ) - self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): if files: request.set_formdata_body(files) return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_version.py index 1d9186e2318f..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.4.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_configuration.py index 5ed4bc5e6cc4..4220d50e8457 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", "2018-04-01") + api_version: str = kwargs.pop("api_version", "2018-04-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_iot_hub_client.py index 9a97ebde0490..765e8162fa96 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_iot_hub_client.py @@ -62,12 +62,16 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2018-04-01") + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2018-04-01" + ) self.resource_provider_common = ResourceProviderCommonOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2018-04-01" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2018-04-01" ) - self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_certificates_operations.py index f27971b407fa..4e449e5348e2 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_certificates_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -35,10 +35,6 @@ build_verify_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list_by_iot_hub( @@ -90,7 +87,7 @@ async def list_by_iot_hub( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) request = build_list_by_iot_hub_request( @@ -158,7 +155,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -315,14 +312,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_description, (IO, bytes)): + if isinstance(certificate_description, (IOBase, bytes)): _content = certificate_description else: _json = self._serialize.body(certificate_description, "CertificateBodyDescription") @@ -403,7 +400,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -472,7 +469,7 @@ async def generate_verification_code( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) request = build_generate_verification_code_request( @@ -631,14 +628,14 @@ async def verify( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_verification_body, (IO, bytes)): + if isinstance(certificate_verification_body, (IOBase, bytes)): _content = certificate_verification_body else: _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_iot_hub_resource_operations.py index bea23e695650..b5b8299c85e3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -57,10 +57,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -83,6 +79,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -110,7 +107,7 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -167,14 +164,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -361,7 +358,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -421,14 +418,14 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_tags, (IO, bytes)): + if isinstance(iot_hub_tags, (IOBase, bytes)): _content = iot_hub_tags else: _json = self._serialize.body(iot_hub_tags, "TagsResource") @@ -581,7 +578,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -640,7 +637,7 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) request = build_delete_request( @@ -716,7 +713,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -773,7 +770,7 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDe _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -861,7 +858,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -961,7 +958,7 @@ async def get_stats( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) request = build_get_stats_request( @@ -1021,7 +1018,7 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1120,7 +1117,7 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) error_map = { @@ -1227,7 +1224,7 @@ async def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_get_event_hub_consumer_group_request( @@ -1300,7 +1297,7 @@ async def create_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_create_event_hub_consumer_group_request( @@ -1373,7 +1370,7 @@ async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-retur _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_event_hub_consumer_group_request( @@ -1432,7 +1429,7 @@ def list_jobs( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) error_map = { @@ -1537,7 +1534,7 @@ async def get_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) request = build_get_job_request( @@ -1598,7 +1595,7 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) error_map = { @@ -1692,7 +1689,7 @@ def get_endpoint_health( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) error_map = { @@ -1835,14 +1832,14 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -1975,14 +1972,14 @@ async def test_all_routes( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestAllRoutesInput") @@ -2117,14 +2114,14 @@ async def test_route( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestRouteInput") @@ -2191,7 +2188,7 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { @@ -2296,7 +2293,7 @@ async def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) request = build_get_keys_for_key_name_request( @@ -2446,14 +2443,14 @@ async def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -2607,14 +2604,14 @@ async def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_operations.py index 1697a622b9cf..ca06dfb055ae 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._operations import build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,6 +51,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: @@ -70,7 +66,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_resource_provider_common_operations.py index 3ad7fb5cc95f..ee2319a71eee 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_resource_provider_common_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -28,10 +27,6 @@ from ..._vendor import _convert_request from ...operations._resource_provider_common_operations import build_get_subscription_quota_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: @@ -77,7 +73,7 @@ async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptio _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) request = build_get_subscription_quota_request( diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_iot_hub_client_enums.py index 6331d5811554..ae98567cc465 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_iot_hub_client_enums.py @@ -114,6 +114,7 @@ class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): REBOOT_DEVICE = "rebootDevice" FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" + IMPORT_ENUM = "import" class OperationMonitoringLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_models_py3.py index 2d559720c36d..d2c01665a5f5 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_models_py3.py @@ -1389,7 +1389,7 @@ class JobResponse(_serialization.Model): :vartype end_time_utc: ~datetime.datetime :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", - "factoryResetDevice", and "firmwareUpdate". + "factoryResetDevice", "firmwareUpdate", and "import". :vartype type: str or ~azure.mgmt.iothub.v2018_04_01.models.JobType :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", "completed", "failed", and "cancelled". diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_certificates_operations.py index 3d335ee31bde..424dfeac9b0d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_certificates_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -26,12 +26,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +41,7 @@ def build_list_by_iot_hub_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +55,7 @@ def build_list_by_iot_hub_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +72,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -93,7 +89,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,7 +112,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -134,7 +130,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -161,7 +157,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -178,7 +174,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -202,7 +198,7 @@ def build_generate_verification_code_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -219,7 +215,7 @@ def build_generate_verification_code_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -243,7 +239,7 @@ def build_verify_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -261,7 +257,7 @@ def build_verify_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -293,6 +289,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_iot_hub( @@ -322,7 +319,7 @@ def list_by_iot_hub( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) request = build_list_by_iot_hub_request( @@ -390,7 +387,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -547,14 +544,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_description, (IO, bytes)): + if isinstance(certificate_description, (IOBase, bytes)): _content = certificate_description else: _json = self._serialize.body(certificate_description, "CertificateBodyDescription") @@ -635,7 +632,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -704,7 +701,7 @@ def generate_verification_code( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) request = build_generate_verification_code_request( @@ -863,14 +860,14 @@ def verify( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_verification_body, (IO, bytes)): + if isinstance(certificate_verification_body, (IOBase, bytes)): _content = certificate_verification_body else: _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_iot_hub_resource_operations.py index 7d1d2f3ff826..e3b14cf0c143 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -30,12 +30,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +43,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +57,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +74,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -93,7 +89,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +110,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -129,7 +125,7 @@ def build_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -148,7 +144,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -162,7 +158,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -177,7 +173,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -186,7 +182,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -201,7 +197,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -214,7 +210,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -231,7 +227,7 @@ def build_get_stats_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -245,7 +241,7 @@ def build_get_stats_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -262,7 +258,7 @@ def build_get_valid_skus_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -276,7 +272,7 @@ def build_get_valid_skus_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -293,7 +289,7 @@ def build_list_event_hub_consumer_groups_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -308,7 +304,7 @@ def build_list_event_hub_consumer_groups_request( "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -330,7 +326,7 @@ def build_get_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -346,7 +342,7 @@ def build_get_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -368,7 +364,7 @@ def build_create_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -384,7 +380,7 @@ def build_create_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -406,7 +402,7 @@ def build_delete_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -422,7 +418,7 @@ def build_delete_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -439,7 +435,7 @@ def build_list_jobs_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -453,7 +449,7 @@ def build_list_jobs_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -470,7 +466,7 @@ def build_get_job_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -485,7 +481,7 @@ def build_get_job_request( "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -502,7 +498,7 @@ def build_get_quota_metrics_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -516,7 +512,7 @@ def build_get_quota_metrics_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -533,7 +529,7 @@ def build_get_endpoint_health_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -547,7 +543,7 @@ def build_get_endpoint_health_request( "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -562,7 +558,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -574,7 +570,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -593,7 +589,7 @@ def build_test_all_routes_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -608,7 +604,7 @@ def build_test_all_routes_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -627,7 +623,7 @@ def build_test_route_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -642,7 +638,7 @@ def build_test_route_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -661,7 +657,7 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -675,7 +671,7 @@ def build_list_keys_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -692,7 +688,7 @@ def build_get_keys_for_key_name_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -707,7 +703,7 @@ def build_get_keys_for_key_name_request( "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -724,7 +720,7 @@ def build_export_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -739,7 +735,7 @@ def build_export_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -758,7 +754,7 @@ def build_import_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -773,7 +769,7 @@ def build_import_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -804,6 +800,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -831,7 +828,7 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -888,14 +885,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -1079,7 +1076,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1139,14 +1136,14 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_tags, (IO, bytes)): + if isinstance(iot_hub_tags, (IOBase, bytes)): _content = iot_hub_tags else: _json = self._serialize.body(iot_hub_tags, "TagsResource") @@ -1296,7 +1293,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1355,7 +1352,7 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) request = build_delete_request( @@ -1430,7 +1427,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1486,7 +1483,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescrip _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1571,7 +1568,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1669,7 +1666,7 @@ def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) request = build_get_stats_request( @@ -1729,7 +1726,7 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1828,7 +1825,7 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) error_map = { @@ -1935,7 +1932,7 @@ def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_get_event_hub_consumer_group_request( @@ -2008,7 +2005,7 @@ def create_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_create_event_hub_consumer_group_request( @@ -2081,7 +2078,7 @@ def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-stat _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_event_hub_consumer_group_request( @@ -2137,7 +2134,7 @@ def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) error_map = { @@ -2240,7 +2237,7 @@ def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **k _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) request = build_get_job_request( @@ -2301,7 +2298,7 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) error_map = { @@ -2394,7 +2391,7 @@ def get_endpoint_health( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) error_map = { @@ -2537,14 +2534,14 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -2677,14 +2674,14 @@ def test_all_routes( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestAllRoutesInput") @@ -2819,14 +2816,14 @@ def test_route( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestRouteInput") @@ -2893,7 +2890,7 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { @@ -2998,7 +2995,7 @@ def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) request = build_get_keys_for_key_name_request( @@ -3148,14 +3145,14 @@ def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -3309,14 +3306,14 @@ def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_operations.py index 03bef3960b7d..b721f6e37854 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +40,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,6 +73,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: @@ -91,7 +87,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_resource_provider_common_operations.py index fe69fbc47469..3e4287e6951b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_resource_provider_common_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -26,12 +25,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +38,7 @@ def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -52,7 +47,7 @@ def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -81,6 +76,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: @@ -104,7 +100,7 @@ def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuota _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-04-01")) cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) request = build_get_subscription_quota_request( diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_configuration.py index 1652a7a9b244..74a45bbfe2f8 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", "2019-03-22") + api_version: str = kwargs.pop("api_version", "2019-03-22") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_iot_hub_client.py index b97447bc727a..da55c6371aa9 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_iot_hub_client.py @@ -69,13 +69,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2019-03-22") + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2019-03-22" + ) self.resource_provider_common = ResourceProviderCommonOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2019-03-22" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2019-03-22" ) - self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) + self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize, "2019-03-22") def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): if files: request.set_formdata_body(files) return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_version.py index 1d9186e2318f..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.4.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_configuration.py index 02cbb7971fcf..c28354bb6ea1 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", "2019-03-22") + api_version: str = kwargs.pop("api_version", "2019-03-22") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_iot_hub_client.py index f7049cab0d2b..769a87917628 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_iot_hub_client.py @@ -70,13 +70,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2019-03-22") + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2019-03-22" + ) self.resource_provider_common = ResourceProviderCommonOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2019-03-22" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2019-03-22" ) - self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) + self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize, "2019-03-22") def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_certificates_operations.py index 88315007ea70..c9bd39673aa8 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_certificates_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -35,10 +35,6 @@ build_verify_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list_by_iot_hub( @@ -90,7 +87,7 @@ async def list_by_iot_hub( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) request = build_list_by_iot_hub_request( @@ -158,7 +155,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -315,14 +312,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_description, (IO, bytes)): + if isinstance(certificate_description, (IOBase, bytes)): _content = certificate_description else: _json = self._serialize.body(certificate_description, "CertificateBodyDescription") @@ -403,7 +400,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -472,7 +469,7 @@ async def generate_verification_code( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) request = build_generate_verification_code_request( @@ -631,14 +628,14 @@ async def verify( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_verification_body, (IO, bytes)): + if isinstance(certificate_verification_body, (IOBase, bytes)): _content = certificate_verification_body else: _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_iot_hub_operations.py index ec91b13b794b..0fdb6927fb6f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_iot_hub_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._iot_hub_operations import build_manual_failover_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") async def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, @@ -75,14 +72,14 @@ async def _manual_failover_initial( # pylint: disable=inconsistent-return-state _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(failover_input, (IO, bytes)): + if isinstance(failover_input, (IOBase, bytes)): _content = failover_input else: _json = self._serialize.body(failover_input, "FailoverInput") @@ -241,7 +238,7 @@ async def begin_manual_failover( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_iot_hub_resource_operations.py index 2e0a8f603b15..1b2907d7ffe4 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -57,10 +57,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -83,6 +79,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -110,7 +107,7 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -167,14 +164,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -361,7 +358,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -421,14 +418,14 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_tags, (IO, bytes)): + if isinstance(iot_hub_tags, (IOBase, bytes)): _content = iot_hub_tags else: _json = self._serialize.body(iot_hub_tags, "TagsResource") @@ -581,7 +578,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -640,7 +637,7 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) request = build_delete_request( @@ -716,7 +713,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -773,7 +770,7 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDe _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -861,7 +858,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -961,7 +958,7 @@ async def get_stats( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) request = build_get_stats_request( @@ -1021,7 +1018,7 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1120,7 +1117,7 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) error_map = { @@ -1227,7 +1224,7 @@ async def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_get_event_hub_consumer_group_request( @@ -1300,7 +1297,7 @@ async def create_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_create_event_hub_consumer_group_request( @@ -1373,7 +1370,7 @@ async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-retur _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_event_hub_consumer_group_request( @@ -1432,7 +1429,7 @@ def list_jobs( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) error_map = { @@ -1537,7 +1534,7 @@ async def get_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) request = build_get_job_request( @@ -1598,7 +1595,7 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) error_map = { @@ -1692,7 +1689,7 @@ def get_endpoint_health( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) error_map = { @@ -1835,14 +1832,14 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -1975,14 +1972,14 @@ async def test_all_routes( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestAllRoutesInput") @@ -2117,14 +2114,14 @@ async def test_route( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestRouteInput") @@ -2191,7 +2188,7 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { @@ -2296,7 +2293,7 @@ async def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) request = build_get_keys_for_key_name_request( @@ -2446,14 +2443,14 @@ async def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -2607,14 +2604,14 @@ async def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_operations.py index 59a83418bc59..2ceede85cd65 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._operations import build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,6 +51,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: @@ -70,7 +66,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_resource_provider_common_operations.py index daae2f92d08d..63c74bf05c60 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_resource_provider_common_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -28,10 +27,6 @@ from ..._vendor import _convert_request from ...operations._resource_provider_common_operations import build_get_subscription_quota_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: @@ -77,7 +73,7 @@ async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptio _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) request = build_get_subscription_quota_request( diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_iot_hub_client_enums.py index e59777721cda..2a2b2ef64ffa 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_iot_hub_client_enums.py @@ -133,6 +133,7 @@ class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): REBOOT_DEVICE = "rebootDevice" FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" + IMPORT_ENUM = "import" class RouteErrorSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_models_py3.py index d9ee18b34cb8..427425db95dd 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_models_py3.py @@ -1456,7 +1456,7 @@ class JobResponse(_serialization.Model): :vartype end_time_utc: ~datetime.datetime :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", - "factoryResetDevice", and "firmwareUpdate". + "factoryResetDevice", "firmwareUpdate", and "import". :vartype type: str or ~azure.mgmt.iothub.v2019_03_22.models.JobType :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", "completed", "failed", and "cancelled". diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_certificates_operations.py index 81c6c5b2665a..64d6ff335fe5 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_certificates_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -26,12 +26,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +41,7 @@ def build_list_by_iot_hub_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +55,7 @@ def build_list_by_iot_hub_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +72,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -93,7 +89,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,7 +112,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -134,7 +130,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -161,7 +157,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -178,7 +174,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -202,7 +198,7 @@ def build_generate_verification_code_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -219,7 +215,7 @@ def build_generate_verification_code_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -243,7 +239,7 @@ def build_verify_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -261,7 +257,7 @@ def build_verify_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -293,6 +289,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_iot_hub( @@ -322,7 +319,7 @@ def list_by_iot_hub( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) request = build_list_by_iot_hub_request( @@ -390,7 +387,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -547,14 +544,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_description, (IO, bytes)): + if isinstance(certificate_description, (IOBase, bytes)): _content = certificate_description else: _json = self._serialize.body(certificate_description, "CertificateBodyDescription") @@ -635,7 +632,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -704,7 +701,7 @@ def generate_verification_code( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) request = build_generate_verification_code_request( @@ -863,14 +860,14 @@ def verify( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_verification_body, (IO, bytes)): + if isinstance(certificate_verification_body, (IOBase, bytes)): _content = certificate_verification_body else: _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_iot_hub_operations.py index d3824f2a2512..dd27a483a98d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_iot_hub_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -28,12 +28,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +43,7 @@ def build_manual_failover_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -62,7 +58,7 @@ def build_manual_failover_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -93,6 +89,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, @@ -112,14 +109,14 @@ def _manual_failover_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(failover_input, (IO, bytes)): + if isinstance(failover_input, (IOBase, bytes)): _content = failover_input else: _json = self._serialize.body(failover_input, "FailoverInput") @@ -278,7 +275,7 @@ def begin_manual_failover( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_iot_hub_resource_operations.py index 10180611fcbd..0ab5cd2bd40e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -30,12 +30,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +43,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +57,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +74,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -93,7 +89,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +110,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -129,7 +125,7 @@ def build_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -148,7 +144,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -162,7 +158,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -177,7 +173,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -186,7 +182,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -201,7 +197,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -214,7 +210,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -231,7 +227,7 @@ def build_get_stats_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -245,7 +241,7 @@ def build_get_stats_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -262,7 +258,7 @@ def build_get_valid_skus_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -276,7 +272,7 @@ def build_get_valid_skus_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -293,7 +289,7 @@ def build_list_event_hub_consumer_groups_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -308,7 +304,7 @@ def build_list_event_hub_consumer_groups_request( "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -330,7 +326,7 @@ def build_get_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -346,7 +342,7 @@ def build_get_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -368,7 +364,7 @@ def build_create_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -384,7 +380,7 @@ def build_create_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -406,7 +402,7 @@ def build_delete_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -422,7 +418,7 @@ def build_delete_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -439,7 +435,7 @@ def build_list_jobs_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -453,7 +449,7 @@ def build_list_jobs_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -470,7 +466,7 @@ def build_get_job_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -485,7 +481,7 @@ def build_get_job_request( "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -502,7 +498,7 @@ def build_get_quota_metrics_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -516,7 +512,7 @@ def build_get_quota_metrics_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -533,7 +529,7 @@ def build_get_endpoint_health_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -547,7 +543,7 @@ def build_get_endpoint_health_request( "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -562,7 +558,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -574,7 +570,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -593,7 +589,7 @@ def build_test_all_routes_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -608,7 +604,7 @@ def build_test_all_routes_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -627,7 +623,7 @@ def build_test_route_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -642,7 +638,7 @@ def build_test_route_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -661,7 +657,7 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -675,7 +671,7 @@ def build_list_keys_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -692,7 +688,7 @@ def build_get_keys_for_key_name_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -707,7 +703,7 @@ def build_get_keys_for_key_name_request( "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -724,7 +720,7 @@ def build_export_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -739,7 +735,7 @@ def build_export_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -758,7 +754,7 @@ def build_import_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -773,7 +769,7 @@ def build_import_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -804,6 +800,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -831,7 +828,7 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -888,14 +885,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -1079,7 +1076,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1139,14 +1136,14 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_tags, (IO, bytes)): + if isinstance(iot_hub_tags, (IOBase, bytes)): _content = iot_hub_tags else: _json = self._serialize.body(iot_hub_tags, "TagsResource") @@ -1296,7 +1293,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1355,7 +1352,7 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) request = build_delete_request( @@ -1430,7 +1427,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1486,7 +1483,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescrip _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1571,7 +1568,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1669,7 +1666,7 @@ def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) request = build_get_stats_request( @@ -1729,7 +1726,7 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1828,7 +1825,7 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) error_map = { @@ -1935,7 +1932,7 @@ def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_get_event_hub_consumer_group_request( @@ -2008,7 +2005,7 @@ def create_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_create_event_hub_consumer_group_request( @@ -2081,7 +2078,7 @@ def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-stat _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_event_hub_consumer_group_request( @@ -2137,7 +2134,7 @@ def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) error_map = { @@ -2240,7 +2237,7 @@ def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **k _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) request = build_get_job_request( @@ -2301,7 +2298,7 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) error_map = { @@ -2394,7 +2391,7 @@ def get_endpoint_health( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) error_map = { @@ -2537,14 +2534,14 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -2677,14 +2674,14 @@ def test_all_routes( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestAllRoutesInput") @@ -2819,14 +2816,14 @@ def test_route( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestRouteInput") @@ -2893,7 +2890,7 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { @@ -2998,7 +2995,7 @@ def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) request = build_get_keys_for_key_name_request( @@ -3148,14 +3145,14 @@ def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -3309,14 +3306,14 @@ def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_operations.py index 7f46e2b67b03..c0cab2bb5252 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +40,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,6 +73,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: @@ -91,7 +87,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_resource_provider_common_operations.py index 01aac4672da3..1c17604cf5f7 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_resource_provider_common_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -26,12 +25,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +38,7 @@ def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -52,7 +47,7 @@ def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -81,6 +76,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: @@ -104,7 +100,7 @@ def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuota _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-03-22"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-03-22")) cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) request = build_get_subscription_quota_request( diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_configuration.py index 2fac9d2365e6..cbc572e65322 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2019-07-01-preview"] = kwargs.pop("api_version", "2019-07-01-preview") + api_version: str = kwargs.pop("api_version", "2019-07-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_iot_hub_client.py index 024e9cbf8ed5..fabd9ee4a2e9 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_iot_hub_client.py @@ -70,13 +70,21 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize, "2019-07-01-preview" + ) + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2019-07-01-preview" + ) self.resource_provider_common = ResourceProviderCommonOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2019-07-01-preview" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2019-07-01-preview" + ) + self.iot_hub = IotHubOperations( + self._client, self._config, self._serialize, self._deserialize, "2019-07-01-preview" ) - self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): if files: request.set_formdata_body(files) return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_version.py index 1d9186e2318f..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.4.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_configuration.py index 132f273707f0..fcfc753fca1b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2019-07-01-preview"] = kwargs.pop("api_version", "2019-07-01-preview") + api_version: str = kwargs.pop("api_version", "2019-07-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_iot_hub_client.py index 659996fd640e..f254aabaa925 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_iot_hub_client.py @@ -71,13 +71,21 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize, "2019-07-01-preview" + ) + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2019-07-01-preview" + ) self.resource_provider_common = ResourceProviderCommonOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2019-07-01-preview" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2019-07-01-preview" + ) + self.iot_hub = IotHubOperations( + self._client, self._config, self._serialize, self._deserialize, "2019-07-01-preview" ) - self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_certificates_operations.py index e0deb2b2b954..4702ae38700b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_certificates_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -35,10 +35,6 @@ build_verify_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list_by_iot_hub( @@ -90,8 +87,8 @@ async def list_by_iot_hub( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) @@ -160,8 +157,8 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) @@ -320,8 +317,8 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) @@ -329,7 +326,7 @@ async def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_description, (IO, bytes)): + if isinstance(certificate_description, (IOBase, bytes)): _content = certificate_description else: _json = self._serialize.body(certificate_description, "CertificateBodyDescription") @@ -410,8 +407,8 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) @@ -481,8 +478,8 @@ async def generate_verification_code( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) @@ -642,8 +639,8 @@ async def verify( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) @@ -651,7 +648,7 @@ async def verify( content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_verification_body, (IO, bytes)): + if isinstance(certificate_verification_body, (IOBase, bytes)): _content = certificate_verification_body else: _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_iot_hub_operations.py index f12309280864..ae54b25c900f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_iot_hub_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._iot_hub_operations import build_manual_failover_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") async def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, @@ -75,8 +72,8 @@ async def _manual_failover_initial( # pylint: disable=inconsistent-return-state _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -84,7 +81,7 @@ async def _manual_failover_initial( # pylint: disable=inconsistent-return-state content_type = content_type or "application/json" _json = None _content = None - if isinstance(failover_input, (IO, bytes)): + if isinstance(failover_input, (IOBase, bytes)): _content = failover_input else: _json = self._serialize.body(failover_input, "FailoverInput") @@ -232,8 +229,8 @@ async def begin_manual_failover( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_iot_hub_resource_operations.py index a2555506cd20..c2c9f047901e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -57,10 +57,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -83,6 +79,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -110,8 +107,8 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -169,8 +166,8 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -178,7 +175,7 @@ async def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -366,8 +363,8 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -428,8 +425,8 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -437,7 +434,7 @@ async def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_tags, (IO, bytes)): + if isinstance(iot_hub_tags, (IOBase, bytes)): _content = iot_hub_tags else: _json = self._serialize.body(iot_hub_tags, "TagsResource") @@ -590,8 +587,8 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -651,8 +648,8 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) @@ -730,8 +727,8 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -789,8 +786,8 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDe _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) @@ -879,8 +876,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) @@ -981,8 +978,8 @@ async def get_stats( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) @@ -1043,8 +1040,8 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) @@ -1144,8 +1141,8 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) @@ -1253,8 +1250,8 @@ async def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) @@ -1328,8 +1325,8 @@ async def create_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) @@ -1403,8 +1400,8 @@ async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-retur _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) @@ -1464,8 +1461,8 @@ def list_jobs( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) @@ -1571,8 +1568,8 @@ async def get_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) @@ -1634,8 +1631,8 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) @@ -1730,8 +1727,8 @@ def get_endpoint_health( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) @@ -1875,8 +1872,8 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) @@ -1884,7 +1881,7 @@ async def check_name_availability( content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -2017,8 +2014,8 @@ async def test_all_routes( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) @@ -2026,7 +2023,7 @@ async def test_all_routes( content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestAllRoutesInput") @@ -2161,8 +2158,8 @@ async def test_route( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) @@ -2170,7 +2167,7 @@ async def test_route( content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestRouteInput") @@ -2237,8 +2234,8 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) @@ -2344,8 +2341,8 @@ async def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) @@ -2497,8 +2494,8 @@ async def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) @@ -2506,7 +2503,7 @@ async def export_devices( content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -2661,8 +2658,8 @@ async def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) @@ -2670,7 +2667,7 @@ async def import_devices( content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_operations.py index 7b03befad2e7..d4891c414712 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._operations import build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,6 +51,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: @@ -70,8 +66,8 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_resource_provider_common_operations.py index 8abb83f074a2..6c5274a0d342 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_resource_provider_common_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -28,10 +27,6 @@ from ..._vendor import _convert_request from ...operations._resource_provider_common_operations import build_get_subscription_quota_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: @@ -77,8 +73,8 @@ async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptio _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_iot_hub_client_enums.py index 35977cfabec3..d348e72d3242 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_iot_hub_client_enums.py @@ -130,6 +130,7 @@ class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): REBOOT_DEVICE = "rebootDevice" FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" + IMPORT_ENUM = "import" class RouteErrorSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_models_py3.py index 48be276791f9..7e6adeff804a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_models_py3.py @@ -1530,7 +1530,7 @@ class JobResponse(_serialization.Model): :vartype end_time_utc: ~datetime.datetime :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", - "factoryResetDevice", and "firmwareUpdate". + "factoryResetDevice", "firmwareUpdate", and "import". :vartype type: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.JobType :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", "completed", "failed", and "cancelled". diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_certificates_operations.py index b34a874069c5..fd00cfa5b1a5 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_certificates_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -26,12 +26,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,9 +41,7 @@ def build_list_by_iot_hub_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +55,7 @@ def build_list_by_iot_hub_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,9 +72,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -97,7 +89,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -120,9 +112,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -140,7 +130,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -167,9 +157,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -186,7 +174,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -210,9 +198,7 @@ def build_generate_verification_code_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -229,7 +215,7 @@ def build_generate_verification_code_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -253,9 +239,7 @@ def build_verify_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -273,7 +257,7 @@ def build_verify_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -305,6 +289,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_iot_hub( @@ -334,8 +319,8 @@ def list_by_iot_hub( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) @@ -404,8 +389,8 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) @@ -564,8 +549,8 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) @@ -573,7 +558,7 @@ def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_description, (IO, bytes)): + if isinstance(certificate_description, (IOBase, bytes)): _content = certificate_description else: _json = self._serialize.body(certificate_description, "CertificateBodyDescription") @@ -654,8 +639,8 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) @@ -725,8 +710,8 @@ def generate_verification_code( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) @@ -886,8 +871,8 @@ def verify( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) @@ -895,7 +880,7 @@ def verify( content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_verification_body, (IO, bytes)): + if isinstance(certificate_verification_body, (IOBase, bytes)): _content = certificate_verification_body else: _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_iot_hub_operations.py index 39c8a12576b2..c8f48d8848f1 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_iot_hub_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -28,12 +28,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,9 +43,7 @@ def build_manual_failover_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -64,7 +58,7 @@ def build_manual_failover_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -95,6 +89,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, @@ -114,8 +109,8 @@ def _manual_failover_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -123,7 +118,7 @@ def _manual_failover_initial( # pylint: disable=inconsistent-return-statements content_type = content_type or "application/json" _json = None _content = None - if isinstance(failover_input, (IO, bytes)): + if isinstance(failover_input, (IOBase, bytes)): _content = failover_input else: _json = self._serialize.body(failover_input, "FailoverInput") @@ -271,8 +266,8 @@ def begin_manual_failover( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_iot_hub_resource_operations.py index 3fff2f65c14d..d57fafb87215 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -30,12 +30,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,9 +43,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +57,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,9 +74,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -97,7 +89,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -118,9 +110,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -135,7 +125,7 @@ def build_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,9 +144,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -170,7 +158,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -185,9 +173,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -196,7 +182,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -211,9 +197,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -226,7 +210,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -243,9 +227,7 @@ def build_get_stats_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -259,7 +241,7 @@ def build_get_stats_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -276,9 +258,7 @@ def build_get_valid_skus_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -292,7 +272,7 @@ def build_get_valid_skus_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -309,9 +289,7 @@ def build_list_event_hub_consumer_groups_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -326,7 +304,7 @@ def build_list_event_hub_consumer_groups_request( "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -348,9 +326,7 @@ def build_get_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -366,7 +342,7 @@ def build_get_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -388,9 +364,7 @@ def build_create_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -406,7 +380,7 @@ def build_create_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -428,9 +402,7 @@ def build_delete_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -446,7 +418,7 @@ def build_delete_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -463,9 +435,7 @@ def build_list_jobs_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -479,7 +449,7 @@ def build_list_jobs_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -496,9 +466,7 @@ def build_get_job_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -513,7 +481,7 @@ def build_get_job_request( "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -530,9 +498,7 @@ def build_get_quota_metrics_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -546,7 +512,7 @@ def build_get_quota_metrics_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -563,9 +529,7 @@ def build_get_endpoint_health_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -579,7 +543,7 @@ def build_get_endpoint_health_request( "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -594,9 +558,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -608,7 +570,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -627,9 +589,7 @@ def build_test_all_routes_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -644,7 +604,7 @@ def build_test_all_routes_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -663,9 +623,7 @@ def build_test_route_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -680,7 +638,7 @@ def build_test_route_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -699,9 +657,7 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -715,7 +671,7 @@ def build_list_keys_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -732,9 +688,7 @@ def build_get_keys_for_key_name_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -749,7 +703,7 @@ def build_get_keys_for_key_name_request( "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -766,9 +720,7 @@ def build_export_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -783,7 +735,7 @@ def build_export_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -802,9 +754,7 @@ def build_import_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -819,7 +769,7 @@ def build_import_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -850,6 +800,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -877,8 +828,8 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -936,8 +887,8 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -945,7 +896,7 @@ def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -1133,8 +1084,8 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -1195,8 +1146,8 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -1204,7 +1155,7 @@ def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_tags, (IO, bytes)): + if isinstance(iot_hub_tags, (IOBase, bytes)): _content = iot_hub_tags else: _json = self._serialize.body(iot_hub_tags, "TagsResource") @@ -1357,8 +1308,8 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -1418,8 +1369,8 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) @@ -1496,8 +1447,8 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1555,8 +1506,8 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescrip _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) @@ -1643,8 +1594,8 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) @@ -1743,8 +1694,8 @@ def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) @@ -1805,8 +1756,8 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) @@ -1906,8 +1857,8 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) @@ -2015,8 +1966,8 @@ def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) @@ -2090,8 +2041,8 @@ def create_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) @@ -2165,8 +2116,8 @@ def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-stat _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) @@ -2223,8 +2174,8 @@ def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) @@ -2328,8 +2279,8 @@ def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **k _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) @@ -2391,8 +2342,8 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) @@ -2487,8 +2438,8 @@ def get_endpoint_health( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) @@ -2632,8 +2583,8 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) @@ -2641,7 +2592,7 @@ def check_name_availability( content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -2774,8 +2725,8 @@ def test_all_routes( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) @@ -2783,7 +2734,7 @@ def test_all_routes( content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestAllRoutesInput") @@ -2918,8 +2869,8 @@ def test_route( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) @@ -2927,7 +2878,7 @@ def test_route( content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestRouteInput") @@ -2994,8 +2945,8 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) @@ -3101,8 +3052,8 @@ def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) @@ -3254,8 +3205,8 @@ def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) @@ -3263,7 +3214,7 @@ def export_devices( content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -3418,8 +3369,8 @@ def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) @@ -3427,7 +3378,7 @@ def import_devices( content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_operations.py index d8289d74242f..9a39f7b161d3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,9 +40,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -80,6 +73,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: @@ -93,8 +87,8 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_resource_provider_common_operations.py index b70b072a6734..73e17c0a9e8b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_resource_provider_common_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -26,12 +25,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,9 +38,7 @@ def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -54,7 +47,7 @@ def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,6 +76,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: @@ -106,8 +100,8 @@ def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuota _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2019-07-01-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-07-01-preview") ) cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_configuration.py index 30b6bfd41547..70ebec4213b5 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", "2019-11-04") + api_version: str = kwargs.pop("api_version", "2019-11-04") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_iot_hub_client.py index b2b88890047e..395f3e50c2fe 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_iot_hub_client.py @@ -69,13 +69,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2019-11-04") + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2019-11-04" + ) self.resource_provider_common = ResourceProviderCommonOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2019-11-04" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2019-11-04" ) - self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) + self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize, "2019-11-04") def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): if files: request.set_formdata_body(files) return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_version.py index 1d9186e2318f..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.4.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_configuration.py index 48384170c1d7..fa5d535c37cf 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", "2019-11-04") + api_version: str = kwargs.pop("api_version", "2019-11-04") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_iot_hub_client.py index 8624d0a8e0e1..ce58461dd33f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_iot_hub_client.py @@ -70,13 +70,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2019-11-04") + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2019-11-04" + ) self.resource_provider_common = ResourceProviderCommonOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2019-11-04" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2019-11-04" ) - self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) + self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize, "2019-11-04") def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_certificates_operations.py index 3eb32dbc6936..2888458c3857 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_certificates_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -35,10 +35,6 @@ build_verify_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list_by_iot_hub( @@ -90,7 +87,7 @@ async def list_by_iot_hub( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) request = build_list_by_iot_hub_request( @@ -158,7 +155,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -315,14 +312,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_description, (IO, bytes)): + if isinstance(certificate_description, (IOBase, bytes)): _content = certificate_description else: _json = self._serialize.body(certificate_description, "CertificateBodyDescription") @@ -403,7 +400,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -472,7 +469,7 @@ async def generate_verification_code( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) request = build_generate_verification_code_request( @@ -631,14 +628,14 @@ async def verify( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_verification_body, (IO, bytes)): + if isinstance(certificate_verification_body, (IOBase, bytes)): _content = certificate_verification_body else: _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_iot_hub_operations.py index 12052b01a526..b08dd921016d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_iot_hub_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._iot_hub_operations import build_manual_failover_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") async def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, @@ -75,14 +72,14 @@ async def _manual_failover_initial( # pylint: disable=inconsistent-return-state _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(failover_input, (IO, bytes)): + if isinstance(failover_input, (IOBase, bytes)): _content = failover_input else: _json = self._serialize.body(failover_input, "FailoverInput") @@ -241,7 +238,7 @@ async def begin_manual_failover( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_iot_hub_resource_operations.py index ac5d608520c0..5e714c02e6cc 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -57,10 +57,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -83,6 +79,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -110,7 +107,7 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -167,14 +164,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -361,7 +358,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -421,14 +418,14 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_tags, (IO, bytes)): + if isinstance(iot_hub_tags, (IOBase, bytes)): _content = iot_hub_tags else: _json = self._serialize.body(iot_hub_tags, "TagsResource") @@ -581,7 +578,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -640,7 +637,7 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) request = build_delete_request( @@ -716,7 +713,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -773,7 +770,7 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDe _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -861,7 +858,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -961,7 +958,7 @@ async def get_stats( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) request = build_get_stats_request( @@ -1021,7 +1018,7 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1120,7 +1117,7 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) error_map = { @@ -1227,7 +1224,7 @@ async def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_get_event_hub_consumer_group_request( @@ -1300,7 +1297,7 @@ async def create_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_create_event_hub_consumer_group_request( @@ -1373,7 +1370,7 @@ async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-retur _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_event_hub_consumer_group_request( @@ -1432,7 +1429,7 @@ def list_jobs( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) error_map = { @@ -1537,7 +1534,7 @@ async def get_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) request = build_get_job_request( @@ -1598,7 +1595,7 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) error_map = { @@ -1692,7 +1689,7 @@ def get_endpoint_health( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) error_map = { @@ -1835,14 +1832,14 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -1975,14 +1972,14 @@ async def test_all_routes( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestAllRoutesInput") @@ -2117,14 +2114,14 @@ async def test_route( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestRouteInput") @@ -2191,7 +2188,7 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { @@ -2296,7 +2293,7 @@ async def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) request = build_get_keys_for_key_name_request( @@ -2446,14 +2443,14 @@ async def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -2607,14 +2604,14 @@ async def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_operations.py index 692c84a6afa0..bbde0f217924 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._operations import build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,6 +51,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: @@ -70,7 +66,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_resource_provider_common_operations.py index a65eca2da694..e7954150fdae 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_resource_provider_common_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -28,10 +27,6 @@ from ..._vendor import _convert_request from ...operations._resource_provider_common_operations import build_get_subscription_quota_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: @@ -77,7 +73,7 @@ async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptio _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) request = build_get_subscription_quota_request( diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_iot_hub_client_enums.py index e59777721cda..2a2b2ef64ffa 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_iot_hub_client_enums.py @@ -133,6 +133,7 @@ class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): REBOOT_DEVICE = "rebootDevice" FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" + IMPORT_ENUM = "import" class RouteErrorSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_models_py3.py index 0c47213e5270..b7fabb8d6652 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_models_py3.py @@ -1498,7 +1498,7 @@ class JobResponse(_serialization.Model): :vartype end_time_utc: ~datetime.datetime :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", - "factoryResetDevice", and "firmwareUpdate". + "factoryResetDevice", "firmwareUpdate", and "import". :vartype type: str or ~azure.mgmt.iothub.v2019_11_04.models.JobType :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", "completed", "failed", and "cancelled". diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_certificates_operations.py index 91e377764807..bc59c177c8a1 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_certificates_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -26,12 +26,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +41,7 @@ def build_list_by_iot_hub_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +55,7 @@ def build_list_by_iot_hub_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +72,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -93,7 +89,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,7 +112,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -134,7 +130,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -161,7 +157,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -178,7 +174,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -202,7 +198,7 @@ def build_generate_verification_code_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -219,7 +215,7 @@ def build_generate_verification_code_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -243,7 +239,7 @@ def build_verify_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -261,7 +257,7 @@ def build_verify_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -293,6 +289,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_iot_hub( @@ -322,7 +319,7 @@ def list_by_iot_hub( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) request = build_list_by_iot_hub_request( @@ -390,7 +387,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -547,14 +544,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_description, (IO, bytes)): + if isinstance(certificate_description, (IOBase, bytes)): _content = certificate_description else: _json = self._serialize.body(certificate_description, "CertificateBodyDescription") @@ -635,7 +632,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -704,7 +701,7 @@ def generate_verification_code( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) request = build_generate_verification_code_request( @@ -863,14 +860,14 @@ def verify( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_verification_body, (IO, bytes)): + if isinstance(certificate_verification_body, (IOBase, bytes)): _content = certificate_verification_body else: _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_iot_hub_operations.py index 921820b71dbf..e5b73a4f47d7 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_iot_hub_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -28,12 +28,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +43,7 @@ def build_manual_failover_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -62,7 +58,7 @@ def build_manual_failover_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -93,6 +89,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, @@ -112,14 +109,14 @@ def _manual_failover_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(failover_input, (IO, bytes)): + if isinstance(failover_input, (IOBase, bytes)): _content = failover_input else: _json = self._serialize.body(failover_input, "FailoverInput") @@ -278,7 +275,7 @@ def begin_manual_failover( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_iot_hub_resource_operations.py index 51d41fe52430..6561f4713497 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -30,12 +30,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +43,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +57,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +74,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -93,7 +89,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +110,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -129,7 +125,7 @@ def build_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -148,7 +144,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -162,7 +158,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -177,7 +173,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -186,7 +182,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -201,7 +197,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -214,7 +210,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -231,7 +227,7 @@ def build_get_stats_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -245,7 +241,7 @@ def build_get_stats_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -262,7 +258,7 @@ def build_get_valid_skus_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -276,7 +272,7 @@ def build_get_valid_skus_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -293,7 +289,7 @@ def build_list_event_hub_consumer_groups_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -308,7 +304,7 @@ def build_list_event_hub_consumer_groups_request( "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -330,7 +326,7 @@ def build_get_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -346,7 +342,7 @@ def build_get_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -368,7 +364,7 @@ def build_create_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -384,7 +380,7 @@ def build_create_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -406,7 +402,7 @@ def build_delete_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -422,7 +418,7 @@ def build_delete_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -439,7 +435,7 @@ def build_list_jobs_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -453,7 +449,7 @@ def build_list_jobs_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -470,7 +466,7 @@ def build_get_job_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -485,7 +481,7 @@ def build_get_job_request( "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -502,7 +498,7 @@ def build_get_quota_metrics_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -516,7 +512,7 @@ def build_get_quota_metrics_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -533,7 +529,7 @@ def build_get_endpoint_health_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -547,7 +543,7 @@ def build_get_endpoint_health_request( "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -562,7 +558,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -574,7 +570,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -593,7 +589,7 @@ def build_test_all_routes_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -608,7 +604,7 @@ def build_test_all_routes_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -627,7 +623,7 @@ def build_test_route_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -642,7 +638,7 @@ def build_test_route_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -661,7 +657,7 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -675,7 +671,7 @@ def build_list_keys_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -692,7 +688,7 @@ def build_get_keys_for_key_name_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -707,7 +703,7 @@ def build_get_keys_for_key_name_request( "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -724,7 +720,7 @@ def build_export_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -739,7 +735,7 @@ def build_export_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -758,7 +754,7 @@ def build_import_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -773,7 +769,7 @@ def build_import_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -804,6 +800,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -831,7 +828,7 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -888,14 +885,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -1079,7 +1076,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1139,14 +1136,14 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_tags, (IO, bytes)): + if isinstance(iot_hub_tags, (IOBase, bytes)): _content = iot_hub_tags else: _json = self._serialize.body(iot_hub_tags, "TagsResource") @@ -1296,7 +1293,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1355,7 +1352,7 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) request = build_delete_request( @@ -1430,7 +1427,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1486,7 +1483,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescrip _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1571,7 +1568,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1669,7 +1666,7 @@ def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) request = build_get_stats_request( @@ -1729,7 +1726,7 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1828,7 +1825,7 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) error_map = { @@ -1935,7 +1932,7 @@ def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_get_event_hub_consumer_group_request( @@ -2008,7 +2005,7 @@ def create_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_create_event_hub_consumer_group_request( @@ -2081,7 +2078,7 @@ def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-stat _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_event_hub_consumer_group_request( @@ -2137,7 +2134,7 @@ def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) error_map = { @@ -2240,7 +2237,7 @@ def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **k _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) request = build_get_job_request( @@ -2301,7 +2298,7 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) error_map = { @@ -2394,7 +2391,7 @@ def get_endpoint_health( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) error_map = { @@ -2537,14 +2534,14 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -2677,14 +2674,14 @@ def test_all_routes( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestAllRoutesInput") @@ -2819,14 +2816,14 @@ def test_route( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestRouteInput") @@ -2893,7 +2890,7 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { @@ -2998,7 +2995,7 @@ def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) request = build_get_keys_for_key_name_request( @@ -3148,14 +3145,14 @@ def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -3309,14 +3306,14 @@ def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_operations.py index 803f3276d616..555a7f665e02 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +40,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,6 +73,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: @@ -91,7 +87,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_resource_provider_common_operations.py index 7c7ea00bd940..69f67e3b836e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_resource_provider_common_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -26,12 +25,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +38,7 @@ def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -52,7 +47,7 @@ def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -81,6 +76,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: @@ -104,7 +100,7 @@ def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuota _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-11-04"] = kwargs.pop("api_version", _params.pop("api-version", "2019-11-04")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-11-04")) cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) request = build_get_subscription_quota_request( diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_configuration.py index 28592c37893e..7f588d0b3874 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", "2020-03-01") + api_version: str = kwargs.pop("api_version", "2020-03-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_iot_hub_client.py index 30641876e9b9..2c572660d7c3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_iot_hub_client.py @@ -77,18 +77,22 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2020-03-01") + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2020-03-01" + ) self.resource_provider_common = ResourceProviderCommonOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-03-01" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2020-03-01" ) - self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) + self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize, "2020-03-01") self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-03-01" ) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-03-01" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): if files: request.set_formdata_body(files) return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_version.py index 1d9186e2318f..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.4.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_configuration.py index 308f9e521dc1..5d09ed364855 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", "2020-03-01") + api_version: str = kwargs.pop("api_version", "2020-03-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_iot_hub_client.py index 07823d7af8bf..6d5c11f73219 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_iot_hub_client.py @@ -78,18 +78,22 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2020-03-01") + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2020-03-01" + ) self.resource_provider_common = ResourceProviderCommonOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-03-01" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2020-03-01" ) - self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) + self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize, "2020-03-01") self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-03-01" ) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-03-01" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_certificates_operations.py index 42eae5610a37..c8632d7450f9 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_certificates_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -35,10 +35,6 @@ build_verify_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list_by_iot_hub( @@ -90,7 +87,7 @@ async def list_by_iot_hub( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) request = build_list_by_iot_hub_request( @@ -158,7 +155,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -315,14 +312,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_description, (IO, bytes)): + if isinstance(certificate_description, (IOBase, bytes)): _content = certificate_description else: _json = self._serialize.body(certificate_description, "CertificateBodyDescription") @@ -403,7 +400,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -472,7 +469,7 @@ async def generate_verification_code( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) request = build_generate_verification_code_request( @@ -631,14 +628,14 @@ async def verify( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_verification_body, (IO, bytes)): + if isinstance(certificate_verification_body, (IOBase, bytes)): _content = certificate_verification_body else: _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_iot_hub_operations.py index 082565e3380b..ebdb41af1982 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_iot_hub_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._iot_hub_operations import build_manual_failover_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") async def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, @@ -75,14 +72,14 @@ async def _manual_failover_initial( # pylint: disable=inconsistent-return-state _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(failover_input, (IO, bytes)): + if isinstance(failover_input, (IOBase, bytes)): _content = failover_input else: _json = self._serialize.body(failover_input, "FailoverInput") @@ -241,7 +238,7 @@ async def begin_manual_failover( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_iot_hub_resource_operations.py index 63544e33c0ec..ed36608ee9a5 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -57,10 +57,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -83,6 +79,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -110,7 +107,7 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -167,14 +164,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -361,7 +358,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -421,14 +418,14 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_tags, (IO, bytes)): + if isinstance(iot_hub_tags, (IOBase, bytes)): _content = iot_hub_tags else: _json = self._serialize.body(iot_hub_tags, "TagsResource") @@ -581,7 +578,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -640,7 +637,7 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) request = build_delete_request( @@ -716,7 +713,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -773,7 +770,7 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDe _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -861,7 +858,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -961,7 +958,7 @@ async def get_stats( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) request = build_get_stats_request( @@ -1021,7 +1018,7 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1120,7 +1117,7 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) error_map = { @@ -1227,7 +1224,7 @@ async def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_get_event_hub_consumer_group_request( @@ -1300,7 +1297,7 @@ async def create_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_create_event_hub_consumer_group_request( @@ -1373,7 +1370,7 @@ async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-retur _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_event_hub_consumer_group_request( @@ -1432,7 +1429,7 @@ def list_jobs( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) error_map = { @@ -1537,7 +1534,7 @@ async def get_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) request = build_get_job_request( @@ -1598,7 +1595,7 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) error_map = { @@ -1692,7 +1689,7 @@ def get_endpoint_health( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) error_map = { @@ -1835,14 +1832,14 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -1975,14 +1972,14 @@ async def test_all_routes( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestAllRoutesInput") @@ -2117,14 +2114,14 @@ async def test_route( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestRouteInput") @@ -2191,7 +2188,7 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { @@ -2296,7 +2293,7 @@ async def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) request = build_get_keys_for_key_name_request( @@ -2446,14 +2443,14 @@ async def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -2607,14 +2604,14 @@ async def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_operations.py index 99269c14696f..de642df03a74 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._operations import build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,6 +51,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: @@ -70,7 +66,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_private_endpoint_connections_operations.py index afa0c1eb4dec..3fbe4eb0f5c5 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_private_endpoint_connections_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -35,10 +35,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list( @@ -90,7 +87,7 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) request = build_list_request( @@ -158,7 +155,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) request = build_get_request( @@ -216,14 +213,14 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): + if isinstance(private_endpoint_connection, (IOBase, bytes)): _content = private_endpoint_connection else: _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") @@ -399,7 +396,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -459,7 +456,7 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) request = build_delete_request( @@ -534,7 +531,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_private_link_resources_operations.py index 9d141195b166..f1281326b9cd 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_private_link_resources_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -28,10 +27,6 @@ from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request, build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: @@ -81,7 +77,7 @@ async def list(self, resource_group_name: str, resource_name: str, **kwargs: Any _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.PrivateLinkResources] = kwargs.pop("cls", None) request = build_list_request( @@ -149,7 +145,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_resource_provider_common_operations.py index 049c87f2bb8a..c4be640fcd00 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_resource_provider_common_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -28,10 +27,6 @@ from ..._vendor import _convert_request from ...operations._resource_provider_common_operations import build_get_subscription_quota_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: @@ -77,7 +73,7 @@ async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptio _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) request = build_get_subscription_quota_request( diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_iot_hub_client_enums.py index c2b9398b02fd..79720b8e1e8d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_iot_hub_client_enums.py @@ -140,6 +140,7 @@ class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): REBOOT_DEVICE = "rebootDevice" FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" + IMPORT_ENUM = "import" class PrivateLinkServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_models_py3.py index 55d78598294e..d4daddb20061 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_models_py3.py @@ -1665,7 +1665,7 @@ class JobResponse(_serialization.Model): :vartype end_time_utc: ~datetime.datetime :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", - "factoryResetDevice", and "firmwareUpdate". + "factoryResetDevice", "firmwareUpdate", and "import". :vartype type: str or ~azure.mgmt.iothub.v2020_03_01.models.JobType :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", "completed", "failed", and "cancelled". diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_certificates_operations.py index 119f00357707..dd89c491fd5f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_certificates_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -26,12 +26,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +41,7 @@ def build_list_by_iot_hub_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +55,7 @@ def build_list_by_iot_hub_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +72,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -93,7 +89,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,7 +112,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -134,7 +130,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -161,7 +157,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -178,7 +174,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -202,7 +198,7 @@ def build_generate_verification_code_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -219,7 +215,7 @@ def build_generate_verification_code_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -243,7 +239,7 @@ def build_verify_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -261,7 +257,7 @@ def build_verify_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -293,6 +289,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_iot_hub( @@ -322,7 +319,7 @@ def list_by_iot_hub( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) request = build_list_by_iot_hub_request( @@ -390,7 +387,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -547,14 +544,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_description, (IO, bytes)): + if isinstance(certificate_description, (IOBase, bytes)): _content = certificate_description else: _json = self._serialize.body(certificate_description, "CertificateBodyDescription") @@ -635,7 +632,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -704,7 +701,7 @@ def generate_verification_code( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) request = build_generate_verification_code_request( @@ -863,14 +860,14 @@ def verify( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_verification_body, (IO, bytes)): + if isinstance(certificate_verification_body, (IOBase, bytes)): _content = certificate_verification_body else: _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_iot_hub_operations.py index 4ae4b10bc90d..2ece5df38a2b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_iot_hub_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -28,12 +28,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +43,7 @@ def build_manual_failover_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -62,7 +58,7 @@ def build_manual_failover_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -93,6 +89,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, @@ -112,14 +109,14 @@ def _manual_failover_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(failover_input, (IO, bytes)): + if isinstance(failover_input, (IOBase, bytes)): _content = failover_input else: _json = self._serialize.body(failover_input, "FailoverInput") @@ -278,7 +275,7 @@ def begin_manual_failover( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_iot_hub_resource_operations.py index 645b5628748d..a0282abe3fbf 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -30,12 +30,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +43,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +57,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +74,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -93,7 +89,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +110,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -129,7 +125,7 @@ def build_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -148,7 +144,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -162,7 +158,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -177,7 +173,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -186,7 +182,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -201,7 +197,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -214,7 +210,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -231,7 +227,7 @@ def build_get_stats_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -245,7 +241,7 @@ def build_get_stats_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -262,7 +258,7 @@ def build_get_valid_skus_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -276,7 +272,7 @@ def build_get_valid_skus_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -293,7 +289,7 @@ def build_list_event_hub_consumer_groups_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -308,7 +304,7 @@ def build_list_event_hub_consumer_groups_request( "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -330,7 +326,7 @@ def build_get_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -346,7 +342,7 @@ def build_get_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -368,7 +364,7 @@ def build_create_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -384,7 +380,7 @@ def build_create_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -406,7 +402,7 @@ def build_delete_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -422,7 +418,7 @@ def build_delete_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -439,7 +435,7 @@ def build_list_jobs_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -453,7 +449,7 @@ def build_list_jobs_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -470,7 +466,7 @@ def build_get_job_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -485,7 +481,7 @@ def build_get_job_request( "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -502,7 +498,7 @@ def build_get_quota_metrics_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -516,7 +512,7 @@ def build_get_quota_metrics_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -533,7 +529,7 @@ def build_get_endpoint_health_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -547,7 +543,7 @@ def build_get_endpoint_health_request( "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -562,7 +558,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -574,7 +570,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -593,7 +589,7 @@ def build_test_all_routes_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -608,7 +604,7 @@ def build_test_all_routes_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -627,7 +623,7 @@ def build_test_route_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -642,7 +638,7 @@ def build_test_route_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -661,7 +657,7 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -675,7 +671,7 @@ def build_list_keys_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -692,7 +688,7 @@ def build_get_keys_for_key_name_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -707,7 +703,7 @@ def build_get_keys_for_key_name_request( "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -724,7 +720,7 @@ def build_export_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -739,7 +735,7 @@ def build_export_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -758,7 +754,7 @@ def build_import_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -773,7 +769,7 @@ def build_import_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -804,6 +800,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -831,7 +828,7 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -888,14 +885,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -1079,7 +1076,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1139,14 +1136,14 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_tags, (IO, bytes)): + if isinstance(iot_hub_tags, (IOBase, bytes)): _content = iot_hub_tags else: _json = self._serialize.body(iot_hub_tags, "TagsResource") @@ -1296,7 +1293,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1355,7 +1352,7 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) request = build_delete_request( @@ -1430,7 +1427,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1486,7 +1483,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescrip _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1571,7 +1568,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1669,7 +1666,7 @@ def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) request = build_get_stats_request( @@ -1729,7 +1726,7 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1828,7 +1825,7 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) error_map = { @@ -1935,7 +1932,7 @@ def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_get_event_hub_consumer_group_request( @@ -2008,7 +2005,7 @@ def create_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_create_event_hub_consumer_group_request( @@ -2081,7 +2078,7 @@ def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-stat _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_event_hub_consumer_group_request( @@ -2137,7 +2134,7 @@ def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) error_map = { @@ -2240,7 +2237,7 @@ def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **k _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) request = build_get_job_request( @@ -2301,7 +2298,7 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) error_map = { @@ -2394,7 +2391,7 @@ def get_endpoint_health( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) error_map = { @@ -2537,14 +2534,14 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -2677,14 +2674,14 @@ def test_all_routes( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestAllRoutesInput") @@ -2819,14 +2816,14 @@ def test_route( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestRouteInput") @@ -2893,7 +2890,7 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { @@ -2998,7 +2995,7 @@ def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) request = build_get_keys_for_key_name_request( @@ -3148,14 +3145,14 @@ def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -3309,14 +3306,14 @@ def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_operations.py index ca502b509ad4..732bab62ae02 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +40,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,6 +73,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: @@ -91,7 +87,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_private_endpoint_connections_operations.py index 7ba30dfcb432..bd1330a1960a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_private_endpoint_connections_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -28,12 +28,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +43,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +57,7 @@ def build_list_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -82,7 +78,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -99,7 +95,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -120,7 +116,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -138,7 +134,7 @@ def build_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -161,7 +157,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -178,7 +174,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -207,6 +203,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -236,7 +233,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) request = build_list_request( @@ -304,7 +301,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) request = build_get_request( @@ -362,14 +359,14 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): + if isinstance(private_endpoint_connection, (IOBase, bytes)): _content = private_endpoint_connection else: _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") @@ -545,7 +542,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -605,7 +602,7 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) request = build_delete_request( @@ -680,7 +677,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_private_link_resources_operations.py index ea3002a3de7e..68ae270ceac9 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_private_link_resources_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -26,12 +25,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +40,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +54,7 @@ def build_list_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +71,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -91,7 +86,7 @@ def build_get_request( "groupId": _SERIALIZER.url("group_id", group_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -120,6 +115,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: @@ -147,7 +143,7 @@ def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.PrivateLinkResources] = kwargs.pop("cls", None) request = build_list_request( @@ -215,7 +211,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_resource_provider_common_operations.py index b759deb4b7c8..b512f8115173 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_resource_provider_common_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -26,12 +25,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +38,7 @@ def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -52,7 +47,7 @@ def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -81,6 +76,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: @@ -104,7 +100,7 @@ def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuota _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2020-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-03-01")) cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) request = build_get_subscription_quota_request( diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_configuration.py index 28a068897dd5..8fb9e914e732 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2021-03-03-preview"] = kwargs.pop("api_version", "2021-03-03-preview") + api_version: str = kwargs.pop("api_version", "2021-03-03-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_iot_hub_client.py index f3b52f38407b..0381c046d4e5 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_iot_hub_client.py @@ -78,18 +78,26 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize, "2021-03-03-preview" + ) + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-03-03-preview" + ) self.resource_provider_common = ResourceProviderCommonOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-03-03-preview" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-03-03-preview" + ) + self.iot_hub = IotHubOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-03-03-preview" ) - self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-03-03-preview" ) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-03-03-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): if files: request.set_formdata_body(files) return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_version.py index 1d9186e2318f..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.4.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_configuration.py index 4c79a7fffbcb..e18805b40afc 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2021-03-03-preview"] = kwargs.pop("api_version", "2021-03-03-preview") + api_version: str = kwargs.pop("api_version", "2021-03-03-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_iot_hub_client.py index 3c5764fab43f..adfddddde828 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_iot_hub_client.py @@ -79,18 +79,26 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize, "2021-03-03-preview" + ) + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-03-03-preview" + ) self.resource_provider_common = ResourceProviderCommonOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-03-03-preview" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-03-03-preview" + ) + self.iot_hub = IotHubOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-03-03-preview" ) - self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-03-03-preview" ) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-03-03-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_certificates_operations.py index 828fc8913839..a1909fb788e9 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_certificates_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -35,10 +35,6 @@ build_verify_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list_by_iot_hub( @@ -90,8 +87,8 @@ async def list_by_iot_hub( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) @@ -160,8 +157,8 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) @@ -320,8 +317,8 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) @@ -329,7 +326,7 @@ async def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_description, (IO, bytes)): + if isinstance(certificate_description, (IOBase, bytes)): _content = certificate_description else: _json = self._serialize.body(certificate_description, "CertificateDescription") @@ -410,8 +407,8 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) @@ -481,8 +478,8 @@ async def generate_verification_code( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) @@ -642,8 +639,8 @@ async def verify( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) @@ -651,7 +648,7 @@ async def verify( content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_verification_body, (IO, bytes)): + if isinstance(certificate_verification_body, (IOBase, bytes)): _content = certificate_verification_body else: _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_iot_hub_operations.py index e0f21467306d..b00cd27528f5 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_iot_hub_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._iot_hub_operations import build_manual_failover_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") async def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, @@ -75,8 +72,8 @@ async def _manual_failover_initial( # pylint: disable=inconsistent-return-state _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -84,7 +81,7 @@ async def _manual_failover_initial( # pylint: disable=inconsistent-return-state content_type = content_type or "application/json" _json = None _content = None - if isinstance(failover_input, (IO, bytes)): + if isinstance(failover_input, (IOBase, bytes)): _content = failover_input else: _json = self._serialize.body(failover_input, "FailoverInput") @@ -243,8 +240,8 @@ async def begin_manual_failover( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_iot_hub_resource_operations.py index 3c4f31a090bc..4ff21797502d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -57,10 +57,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -83,6 +79,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -110,8 +107,8 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -169,8 +166,8 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -178,7 +175,7 @@ async def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -360,8 +357,8 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -422,8 +419,8 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -431,7 +428,7 @@ async def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_tags, (IO, bytes)): + if isinstance(iot_hub_tags, (IOBase, bytes)): _content = iot_hub_tags else: _json = self._serialize.body(iot_hub_tags, "TagsResource") @@ -584,8 +581,8 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -645,8 +642,8 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) @@ -724,8 +721,8 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -783,8 +780,8 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDe _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) @@ -873,8 +870,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) @@ -975,8 +972,8 @@ async def get_stats( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) @@ -1037,8 +1034,8 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) @@ -1138,8 +1135,8 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) @@ -1247,8 +1244,8 @@ async def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) @@ -1408,8 +1405,8 @@ async def create_event_hub_consumer_group( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) @@ -1417,7 +1414,7 @@ async def create_event_hub_consumer_group( content_type = content_type or "application/json" _json = None _content = None - if isinstance(consumer_group_body, (IO, bytes)): + if isinstance(consumer_group_body, (IOBase, bytes)): _content = consumer_group_body else: _json = self._serialize.body(consumer_group_body, "EventHubConsumerGroupBodyDescription") @@ -1495,8 +1492,8 @@ async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-retur _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) @@ -1556,8 +1553,8 @@ def list_jobs( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) @@ -1663,8 +1660,8 @@ async def get_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) @@ -1726,8 +1723,8 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) @@ -1822,8 +1819,8 @@ def get_endpoint_health( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) @@ -1967,8 +1964,8 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) @@ -1976,7 +1973,7 @@ async def check_name_availability( content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -2109,8 +2106,8 @@ async def test_all_routes( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) @@ -2118,7 +2115,7 @@ async def test_all_routes( content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestAllRoutesInput") @@ -2253,8 +2250,8 @@ async def test_route( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) @@ -2262,7 +2259,7 @@ async def test_route( content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestRouteInput") @@ -2329,8 +2326,8 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) @@ -2436,8 +2433,8 @@ async def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) @@ -2589,8 +2586,8 @@ async def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) @@ -2598,7 +2595,7 @@ async def export_devices( content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -2753,8 +2750,8 @@ async def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) @@ -2762,7 +2759,7 @@ async def import_devices( content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_operations.py index 85a38f9a08f0..f6586471b6d0 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._operations import build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,6 +51,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: @@ -70,8 +66,8 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_private_endpoint_connections_operations.py index 9539dfaa9da4..e09814ee2651 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_private_endpoint_connections_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -35,10 +35,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list( @@ -90,8 +87,8 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) @@ -160,8 +157,8 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) @@ -220,8 +217,8 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) @@ -229,7 +226,7 @@ async def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): + if isinstance(private_endpoint_connection, (IOBase, bytes)): _content = private_endpoint_connection else: _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") @@ -405,8 +402,8 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) @@ -467,8 +464,8 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) @@ -544,8 +541,8 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_private_link_resources_operations.py index df8ebb87ebdf..bf8840492bcf 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_private_link_resources_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -28,10 +27,6 @@ from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request, build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: @@ -81,8 +77,8 @@ async def list(self, resource_group_name: str, resource_name: str, **kwargs: Any _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.PrivateLinkResources] = kwargs.pop("cls", None) @@ -151,8 +147,8 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_resource_provider_common_operations.py index d1f153943e75..79692353d928 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_resource_provider_common_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -28,10 +27,6 @@ from ..._vendor import _convert_request from ...operations._resource_provider_common_operations import build_get_subscription_quota_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: @@ -77,8 +73,8 @@ async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptio _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_iot_hub_client_enums.py index ee6a65a17273..4bc2b2973e9c 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_iot_hub_client_enums.py @@ -148,6 +148,7 @@ class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): REBOOT_DEVICE = "rebootDevice" FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" + IMPORT_ENUM = "import" class NetworkRuleIPAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_models_py3.py index 590069a2e493..bb0040fc2cd1 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_models_py3.py @@ -1935,7 +1935,7 @@ class JobResponse(_serialization.Model): :vartype end_time_utc: ~datetime.datetime :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", - "factoryResetDevice", and "firmwareUpdate". + "factoryResetDevice", "firmwareUpdate", and "import". :vartype type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.JobType :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", "completed", "failed", and "cancelled". diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_certificates_operations.py index f294cc0f17f1..024138b7b246 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_certificates_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -26,12 +26,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,9 +41,7 @@ def build_list_by_iot_hub_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +55,7 @@ def build_list_by_iot_hub_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,9 +72,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -97,7 +89,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -120,9 +112,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -140,7 +130,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -167,9 +157,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -186,7 +174,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -210,9 +198,7 @@ def build_generate_verification_code_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -229,7 +215,7 @@ def build_generate_verification_code_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -253,9 +239,7 @@ def build_verify_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -273,7 +257,7 @@ def build_verify_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -305,6 +289,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_iot_hub( @@ -334,8 +319,8 @@ def list_by_iot_hub( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) @@ -404,8 +389,8 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) @@ -564,8 +549,8 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) @@ -573,7 +558,7 @@ def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_description, (IO, bytes)): + if isinstance(certificate_description, (IOBase, bytes)): _content = certificate_description else: _json = self._serialize.body(certificate_description, "CertificateDescription") @@ -654,8 +639,8 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) @@ -725,8 +710,8 @@ def generate_verification_code( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) @@ -886,8 +871,8 @@ def verify( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) @@ -895,7 +880,7 @@ def verify( content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_verification_body, (IO, bytes)): + if isinstance(certificate_verification_body, (IOBase, bytes)): _content = certificate_verification_body else: _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_iot_hub_operations.py index c54a23df4635..ca854ed4cef6 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_iot_hub_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -28,12 +28,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,9 +43,7 @@ def build_manual_failover_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -64,7 +58,7 @@ def build_manual_failover_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -95,6 +89,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, @@ -114,8 +109,8 @@ def _manual_failover_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -123,7 +118,7 @@ def _manual_failover_initial( # pylint: disable=inconsistent-return-statements content_type = content_type or "application/json" _json = None _content = None - if isinstance(failover_input, (IO, bytes)): + if isinstance(failover_input, (IOBase, bytes)): _content = failover_input else: _json = self._serialize.body(failover_input, "FailoverInput") @@ -282,8 +277,8 @@ def begin_manual_failover( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_iot_hub_resource_operations.py index 20744b885f42..b9441588d65e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -30,12 +30,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,9 +43,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +57,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,9 +74,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -97,7 +89,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -118,9 +110,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -135,7 +125,7 @@ def build_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,9 +144,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -170,7 +158,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -185,9 +173,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -196,7 +182,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -211,9 +197,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -226,7 +210,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -243,9 +227,7 @@ def build_get_stats_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -259,7 +241,7 @@ def build_get_stats_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -276,9 +258,7 @@ def build_get_valid_skus_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -292,7 +272,7 @@ def build_get_valid_skus_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -309,9 +289,7 @@ def build_list_event_hub_consumer_groups_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -326,7 +304,7 @@ def build_list_event_hub_consumer_groups_request( "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -348,9 +326,7 @@ def build_get_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -366,7 +342,7 @@ def build_get_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -388,9 +364,7 @@ def build_create_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -407,7 +381,7 @@ def build_create_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -431,9 +405,7 @@ def build_delete_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -449,7 +421,7 @@ def build_delete_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -466,9 +438,7 @@ def build_list_jobs_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -482,7 +452,7 @@ def build_list_jobs_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -499,9 +469,7 @@ def build_get_job_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -516,7 +484,7 @@ def build_get_job_request( "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -533,9 +501,7 @@ def build_get_quota_metrics_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -549,7 +515,7 @@ def build_get_quota_metrics_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -566,9 +532,7 @@ def build_get_endpoint_health_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -582,7 +546,7 @@ def build_get_endpoint_health_request( "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -597,9 +561,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -611,7 +573,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -630,9 +592,7 @@ def build_test_all_routes_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -647,7 +607,7 @@ def build_test_all_routes_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -666,9 +626,7 @@ def build_test_route_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -683,7 +641,7 @@ def build_test_route_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -702,9 +660,7 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -718,7 +674,7 @@ def build_list_keys_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -735,9 +691,7 @@ def build_get_keys_for_key_name_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -752,7 +706,7 @@ def build_get_keys_for_key_name_request( "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -769,9 +723,7 @@ def build_export_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -786,7 +738,7 @@ def build_export_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -805,9 +757,7 @@ def build_import_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -822,7 +772,7 @@ def build_import_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -853,6 +803,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -880,8 +831,8 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -939,8 +890,8 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -948,7 +899,7 @@ def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -1130,8 +1081,8 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -1192,8 +1143,8 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -1201,7 +1152,7 @@ def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_tags, (IO, bytes)): + if isinstance(iot_hub_tags, (IOBase, bytes)): _content = iot_hub_tags else: _json = self._serialize.body(iot_hub_tags, "TagsResource") @@ -1354,8 +1305,8 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -1415,8 +1366,8 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) @@ -1493,8 +1444,8 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1552,8 +1503,8 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescrip _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) @@ -1640,8 +1591,8 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) @@ -1740,8 +1691,8 @@ def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) @@ -1802,8 +1753,8 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) @@ -1903,8 +1854,8 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) @@ -2012,8 +1963,8 @@ def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) @@ -2173,8 +2124,8 @@ def create_event_hub_consumer_group( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) @@ -2182,7 +2133,7 @@ def create_event_hub_consumer_group( content_type = content_type or "application/json" _json = None _content = None - if isinstance(consumer_group_body, (IO, bytes)): + if isinstance(consumer_group_body, (IOBase, bytes)): _content = consumer_group_body else: _json = self._serialize.body(consumer_group_body, "EventHubConsumerGroupBodyDescription") @@ -2260,8 +2211,8 @@ def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-stat _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) @@ -2318,8 +2269,8 @@ def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) @@ -2423,8 +2374,8 @@ def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **k _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) @@ -2486,8 +2437,8 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) @@ -2582,8 +2533,8 @@ def get_endpoint_health( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) @@ -2727,8 +2678,8 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) @@ -2736,7 +2687,7 @@ def check_name_availability( content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -2869,8 +2820,8 @@ def test_all_routes( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) @@ -2878,7 +2829,7 @@ def test_all_routes( content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestAllRoutesInput") @@ -3013,8 +2964,8 @@ def test_route( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) @@ -3022,7 +2973,7 @@ def test_route( content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestRouteInput") @@ -3089,8 +3040,8 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) @@ -3196,8 +3147,8 @@ def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) @@ -3349,8 +3300,8 @@ def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) @@ -3358,7 +3309,7 @@ def export_devices( content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -3513,8 +3464,8 @@ def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) @@ -3522,7 +3473,7 @@ def import_devices( content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_operations.py index 7b56cfcfd859..f35d807fb90e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,9 +40,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -80,6 +73,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: @@ -93,8 +87,8 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_private_endpoint_connections_operations.py index a894f9dc221e..24223692dfdd 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_private_endpoint_connections_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -28,12 +28,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,9 +43,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +57,7 @@ def build_list_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -84,9 +78,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -103,7 +95,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -124,9 +116,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -144,7 +134,7 @@ def build_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -167,9 +157,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -186,7 +174,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -215,6 +203,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -244,8 +233,8 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) @@ -314,8 +303,8 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) @@ -374,8 +363,8 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) @@ -383,7 +372,7 @@ def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): + if isinstance(private_endpoint_connection, (IOBase, bytes)): _content = private_endpoint_connection else: _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") @@ -559,8 +548,8 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) @@ -621,8 +610,8 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) @@ -698,8 +687,8 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_private_link_resources_operations.py index b3d57c92b90b..32163dfede1f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_private_link_resources_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -26,12 +25,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,9 +40,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +54,7 @@ def build_list_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,9 +71,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -95,7 +86,7 @@ def build_get_request( "groupId": _SERIALIZER.url("group_id", group_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -124,6 +115,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: @@ -151,8 +143,8 @@ def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.PrivateLinkResources] = kwargs.pop("cls", None) @@ -221,8 +213,8 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_resource_provider_common_operations.py index 9d50f7401bac..2b5f4c3b9851 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_resource_provider_common_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -26,12 +25,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,9 +38,7 @@ def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-03-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -54,7 +47,7 @@ def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,6 +76,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: @@ -106,8 +100,8 @@ def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuota _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-03-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-03-03-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-03-03-preview") ) cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_configuration.py index dd7091ed780e..0ecb3d75836c 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", "2021-03-31") + api_version: str = kwargs.pop("api_version", "2021-03-31") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_iot_hub_client.py index ac53f968910c..3bc7d3ada88d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_iot_hub_client.py @@ -77,18 +77,22 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2021-03-31") + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-03-31" + ) self.resource_provider_common = ResourceProviderCommonOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-03-31" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-03-31" ) - self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) + self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize, "2021-03-31") self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-03-31" ) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-03-31" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): if files: request.set_formdata_body(files) return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_version.py index 1d9186e2318f..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.4.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_configuration.py index bb36811bb171..804d5a3a2545 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", "2021-03-31") + api_version: str = kwargs.pop("api_version", "2021-03-31") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_iot_hub_client.py index 18aa85db39e7..81b9edf3b27c 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_iot_hub_client.py @@ -78,18 +78,22 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2021-03-31") + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-03-31" + ) self.resource_provider_common = ResourceProviderCommonOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-03-31" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-03-31" ) - self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) + self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize, "2021-03-31") self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-03-31" ) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-03-31" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_certificates_operations.py index 064b1035331a..400ee3c1de8f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_certificates_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -35,10 +35,6 @@ build_verify_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list_by_iot_hub( @@ -90,7 +87,7 @@ async def list_by_iot_hub( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) request = build_list_by_iot_hub_request( @@ -158,7 +155,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -315,14 +312,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_description, (IO, bytes)): + if isinstance(certificate_description, (IOBase, bytes)): _content = certificate_description else: _json = self._serialize.body(certificate_description, "CertificateDescription") @@ -403,7 +400,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -472,7 +469,7 @@ async def generate_verification_code( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) request = build_generate_verification_code_request( @@ -631,14 +628,14 @@ async def verify( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_verification_body, (IO, bytes)): + if isinstance(certificate_verification_body, (IOBase, bytes)): _content = certificate_verification_body else: _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_iot_hub_operations.py index ef0e6027cfe6..9004b2035ab2 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_iot_hub_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._iot_hub_operations import build_manual_failover_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") async def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, @@ -75,14 +72,14 @@ async def _manual_failover_initial( # pylint: disable=inconsistent-return-state _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(failover_input, (IO, bytes)): + if isinstance(failover_input, (IOBase, bytes)): _content = failover_input else: _json = self._serialize.body(failover_input, "FailoverInput") @@ -241,7 +238,7 @@ async def begin_manual_failover( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_iot_hub_resource_operations.py index 30a46702706a..5873a9448628 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -57,10 +57,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -83,6 +79,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -110,7 +107,7 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -167,14 +164,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -361,7 +358,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -421,14 +418,14 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_tags, (IO, bytes)): + if isinstance(iot_hub_tags, (IOBase, bytes)): _content = iot_hub_tags else: _json = self._serialize.body(iot_hub_tags, "TagsResource") @@ -581,7 +578,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -640,7 +637,7 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) request = build_delete_request( @@ -716,7 +713,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -773,7 +770,7 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDe _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -861,7 +858,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -961,7 +958,7 @@ async def get_stats( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) request = build_get_stats_request( @@ -1021,7 +1018,7 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1120,7 +1117,7 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) error_map = { @@ -1227,7 +1224,7 @@ async def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_get_event_hub_consumer_group_request( @@ -1386,14 +1383,14 @@ async def create_event_hub_consumer_group( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(consumer_group_body, (IO, bytes)): + if isinstance(consumer_group_body, (IOBase, bytes)): _content = consumer_group_body else: _json = self._serialize.body(consumer_group_body, "EventHubConsumerGroupBodyDescription") @@ -1471,7 +1468,7 @@ async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-retur _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_event_hub_consumer_group_request( @@ -1530,7 +1527,7 @@ def list_jobs( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) error_map = { @@ -1635,7 +1632,7 @@ async def get_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) request = build_get_job_request( @@ -1696,7 +1693,7 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) error_map = { @@ -1790,7 +1787,7 @@ def get_endpoint_health( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) error_map = { @@ -1933,14 +1930,14 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -2073,14 +2070,14 @@ async def test_all_routes( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestAllRoutesInput") @@ -2215,14 +2212,14 @@ async def test_route( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestRouteInput") @@ -2289,7 +2286,7 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { @@ -2394,7 +2391,7 @@ async def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) request = build_get_keys_for_key_name_request( @@ -2544,14 +2541,14 @@ async def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -2705,14 +2702,14 @@ async def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_operations.py index 4f7cbc6cef22..6e03c765cafa 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._operations import build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,6 +51,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: @@ -70,7 +66,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_private_endpoint_connections_operations.py index 8ab6669135c4..2dd4e9fe0bc4 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_private_endpoint_connections_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -35,10 +35,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list( @@ -90,7 +87,7 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) request = build_list_request( @@ -158,7 +155,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) request = build_get_request( @@ -216,14 +213,14 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): + if isinstance(private_endpoint_connection, (IOBase, bytes)): _content = private_endpoint_connection else: _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") @@ -399,7 +396,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -459,7 +456,7 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) request = build_delete_request( @@ -534,7 +531,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_private_link_resources_operations.py index d8db197dee64..c51013ed947b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_private_link_resources_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -28,10 +27,6 @@ from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request, build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: @@ -81,7 +77,7 @@ async def list(self, resource_group_name: str, resource_name: str, **kwargs: Any _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.PrivateLinkResources] = kwargs.pop("cls", None) request = build_list_request( @@ -149,7 +145,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_resource_provider_common_operations.py index d43949d0404c..0f48265c2491 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_resource_provider_common_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -28,10 +27,6 @@ from ..._vendor import _convert_request from ...operations._resource_provider_common_operations import build_get_subscription_quota_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: @@ -77,7 +73,7 @@ async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptio _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) request = build_get_subscription_quota_request( diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_iot_hub_client_enums.py index 582048bfa653..4d9507b40cc5 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_iot_hub_client_enums.py @@ -148,6 +148,7 @@ class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): REBOOT_DEVICE = "rebootDevice" FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" + IMPORT_ENUM = "import" class NetworkRuleIPAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_models_py3.py index 4fd683d8042a..293d7c1abd72 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_models_py3.py @@ -1893,7 +1893,7 @@ class JobResponse(_serialization.Model): :vartype end_time_utc: ~datetime.datetime :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", - "factoryResetDevice", and "firmwareUpdate". + "factoryResetDevice", "firmwareUpdate", and "import". :vartype type: str or ~azure.mgmt.iothub.v2021_03_31.models.JobType :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", "completed", "failed", and "cancelled". diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_certificates_operations.py index f580150e1b5e..96bb1cd45186 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_certificates_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -26,12 +26,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +41,7 @@ def build_list_by_iot_hub_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +55,7 @@ def build_list_by_iot_hub_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +72,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -93,7 +89,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,7 +112,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -134,7 +130,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -161,7 +157,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -178,7 +174,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -202,7 +198,7 @@ def build_generate_verification_code_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -219,7 +215,7 @@ def build_generate_verification_code_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -243,7 +239,7 @@ def build_verify_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -261,7 +257,7 @@ def build_verify_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -293,6 +289,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_iot_hub( @@ -322,7 +319,7 @@ def list_by_iot_hub( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) request = build_list_by_iot_hub_request( @@ -390,7 +387,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -547,14 +544,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_description, (IO, bytes)): + if isinstance(certificate_description, (IOBase, bytes)): _content = certificate_description else: _json = self._serialize.body(certificate_description, "CertificateDescription") @@ -635,7 +632,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -704,7 +701,7 @@ def generate_verification_code( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) request = build_generate_verification_code_request( @@ -863,14 +860,14 @@ def verify( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_verification_body, (IO, bytes)): + if isinstance(certificate_verification_body, (IOBase, bytes)): _content = certificate_verification_body else: _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_iot_hub_operations.py index 973c93294e21..1efbe4e75369 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_iot_hub_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -28,12 +28,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +43,7 @@ def build_manual_failover_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -62,7 +58,7 @@ def build_manual_failover_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -93,6 +89,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, @@ -112,14 +109,14 @@ def _manual_failover_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(failover_input, (IO, bytes)): + if isinstance(failover_input, (IOBase, bytes)): _content = failover_input else: _json = self._serialize.body(failover_input, "FailoverInput") @@ -278,7 +275,7 @@ def begin_manual_failover( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_iot_hub_resource_operations.py index 776ee3db5902..dbd36ba36034 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -30,12 +30,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +43,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +57,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +74,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -93,7 +89,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +110,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -129,7 +125,7 @@ def build_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -148,7 +144,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -162,7 +158,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -177,7 +173,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -186,7 +182,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -201,7 +197,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -214,7 +210,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -231,7 +227,7 @@ def build_get_stats_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -245,7 +241,7 @@ def build_get_stats_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -262,7 +258,7 @@ def build_get_valid_skus_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -276,7 +272,7 @@ def build_get_valid_skus_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -293,7 +289,7 @@ def build_list_event_hub_consumer_groups_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -308,7 +304,7 @@ def build_list_event_hub_consumer_groups_request( "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -330,7 +326,7 @@ def build_get_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -346,7 +342,7 @@ def build_get_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -368,7 +364,7 @@ def build_create_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -385,7 +381,7 @@ def build_create_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -409,7 +405,7 @@ def build_delete_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -425,7 +421,7 @@ def build_delete_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -442,7 +438,7 @@ def build_list_jobs_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -456,7 +452,7 @@ def build_list_jobs_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -473,7 +469,7 @@ def build_get_job_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -488,7 +484,7 @@ def build_get_job_request( "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -505,7 +501,7 @@ def build_get_quota_metrics_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -519,7 +515,7 @@ def build_get_quota_metrics_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -536,7 +532,7 @@ def build_get_endpoint_health_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -550,7 +546,7 @@ def build_get_endpoint_health_request( "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -565,7 +561,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -577,7 +573,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -596,7 +592,7 @@ def build_test_all_routes_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -611,7 +607,7 @@ def build_test_all_routes_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -630,7 +626,7 @@ def build_test_route_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -645,7 +641,7 @@ def build_test_route_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -664,7 +660,7 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -678,7 +674,7 @@ def build_list_keys_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -695,7 +691,7 @@ def build_get_keys_for_key_name_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -710,7 +706,7 @@ def build_get_keys_for_key_name_request( "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -727,7 +723,7 @@ def build_export_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -742,7 +738,7 @@ def build_export_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -761,7 +757,7 @@ def build_import_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -776,7 +772,7 @@ def build_import_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -807,6 +803,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -834,7 +831,7 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -891,14 +888,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -1082,7 +1079,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1142,14 +1139,14 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_tags, (IO, bytes)): + if isinstance(iot_hub_tags, (IOBase, bytes)): _content = iot_hub_tags else: _json = self._serialize.body(iot_hub_tags, "TagsResource") @@ -1299,7 +1296,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1358,7 +1355,7 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) request = build_delete_request( @@ -1433,7 +1430,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1489,7 +1486,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescrip _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1574,7 +1571,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1672,7 +1669,7 @@ def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) request = build_get_stats_request( @@ -1732,7 +1729,7 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1831,7 +1828,7 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) error_map = { @@ -1938,7 +1935,7 @@ def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_get_event_hub_consumer_group_request( @@ -2097,14 +2094,14 @@ def create_event_hub_consumer_group( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(consumer_group_body, (IO, bytes)): + if isinstance(consumer_group_body, (IOBase, bytes)): _content = consumer_group_body else: _json = self._serialize.body(consumer_group_body, "EventHubConsumerGroupBodyDescription") @@ -2182,7 +2179,7 @@ def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-stat _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_event_hub_consumer_group_request( @@ -2238,7 +2235,7 @@ def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) error_map = { @@ -2341,7 +2338,7 @@ def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **k _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) request = build_get_job_request( @@ -2402,7 +2399,7 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) error_map = { @@ -2495,7 +2492,7 @@ def get_endpoint_health( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) error_map = { @@ -2638,14 +2635,14 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -2778,14 +2775,14 @@ def test_all_routes( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestAllRoutesInput") @@ -2920,14 +2917,14 @@ def test_route( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestRouteInput") @@ -2994,7 +2991,7 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { @@ -3099,7 +3096,7 @@ def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) request = build_get_keys_for_key_name_request( @@ -3249,14 +3246,14 @@ def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -3410,14 +3407,14 @@ def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_operations.py index 64c7a28f8192..ebe46b1410b0 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +40,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,6 +73,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: @@ -91,7 +87,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_private_endpoint_connections_operations.py index a7591f71ee87..c527e3d93265 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_private_endpoint_connections_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -28,12 +28,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +43,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +57,7 @@ def build_list_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -82,7 +78,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -99,7 +95,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -120,7 +116,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -138,7 +134,7 @@ def build_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -161,7 +157,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -178,7 +174,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -207,6 +203,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -236,7 +233,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) request = build_list_request( @@ -304,7 +301,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) request = build_get_request( @@ -362,14 +359,14 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): + if isinstance(private_endpoint_connection, (IOBase, bytes)): _content = private_endpoint_connection else: _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") @@ -545,7 +542,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -605,7 +602,7 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) request = build_delete_request( @@ -680,7 +677,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_private_link_resources_operations.py index 77a93a2862c2..d84324aedee2 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_private_link_resources_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -26,12 +25,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +40,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +54,7 @@ def build_list_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +71,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -91,7 +86,7 @@ def build_get_request( "groupId": _SERIALIZER.url("group_id", group_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -120,6 +115,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: @@ -147,7 +143,7 @@ def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.PrivateLinkResources] = kwargs.pop("cls", None) request = build_list_request( @@ -215,7 +211,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_resource_provider_common_operations.py index 813bd13e510b..ea5402089bfb 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_resource_provider_common_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -26,12 +25,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +38,7 @@ def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -52,7 +47,7 @@ def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -81,6 +76,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: @@ -104,7 +100,7 @@ def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuota _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-03-31"] = kwargs.pop("api_version", _params.pop("api-version", "2021-03-31")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-03-31")) cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) request = build_get_subscription_quota_request( diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_configuration.py index a39f0d6e4b55..60d9f40def5d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", "2021-07-01") + api_version: str = kwargs.pop("api_version", "2021-07-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_iot_hub_client.py index 06fa09520f3c..d5d212bcc89e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_iot_hub_client.py @@ -77,18 +77,22 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2021-07-01") + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-07-01" + ) self.resource_provider_common = ResourceProviderCommonOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-07-01" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-07-01" ) - self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) + self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize, "2021-07-01") self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-07-01" ) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-07-01" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): if files: request.set_formdata_body(files) return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_version.py index 1d9186e2318f..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.4.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_configuration.py index 2b857a5926f4..2e808994cc82 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", "2021-07-01") + api_version: str = kwargs.pop("api_version", "2021-07-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_iot_hub_client.py index 2dc51d6b16cf..2784b43ea2ac 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_iot_hub_client.py @@ -78,18 +78,22 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2021-07-01") + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-07-01" + ) self.resource_provider_common = ResourceProviderCommonOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-07-01" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-07-01" ) - self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) + self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize, "2021-07-01") self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-07-01" ) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-07-01" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_certificates_operations.py index eec796fe45dd..aa41d5f57a81 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_certificates_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -35,10 +35,6 @@ build_verify_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list_by_iot_hub( @@ -90,7 +87,7 @@ async def list_by_iot_hub( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) request = build_list_by_iot_hub_request( @@ -158,7 +155,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -315,14 +312,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_description, (IO, bytes)): + if isinstance(certificate_description, (IOBase, bytes)): _content = certificate_description else: _json = self._serialize.body(certificate_description, "CertificateDescription") @@ -403,7 +400,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -472,7 +469,7 @@ async def generate_verification_code( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) request = build_generate_verification_code_request( @@ -631,14 +628,14 @@ async def verify( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_verification_body, (IO, bytes)): + if isinstance(certificate_verification_body, (IOBase, bytes)): _content = certificate_verification_body else: _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_iot_hub_operations.py index 4ab59ce55e21..b6975c1d2e80 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_iot_hub_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._iot_hub_operations import build_manual_failover_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") async def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, @@ -75,14 +72,14 @@ async def _manual_failover_initial( # pylint: disable=inconsistent-return-state _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(failover_input, (IO, bytes)): + if isinstance(failover_input, (IOBase, bytes)): _content = failover_input else: _json = self._serialize.body(failover_input, "FailoverInput") @@ -241,7 +238,7 @@ async def begin_manual_failover( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_iot_hub_resource_operations.py index 0a935f147451..a8144ee7d8eb 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -57,10 +57,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -83,6 +79,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -110,7 +107,7 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -167,14 +164,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -361,7 +358,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -421,14 +418,14 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_tags, (IO, bytes)): + if isinstance(iot_hub_tags, (IOBase, bytes)): _content = iot_hub_tags else: _json = self._serialize.body(iot_hub_tags, "TagsResource") @@ -581,7 +578,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -640,7 +637,7 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) request = build_delete_request( @@ -716,7 +713,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -773,7 +770,7 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDe _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -861,7 +858,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -961,7 +958,7 @@ async def get_stats( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) request = build_get_stats_request( @@ -1021,7 +1018,7 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1120,7 +1117,7 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) error_map = { @@ -1227,7 +1224,7 @@ async def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_get_event_hub_consumer_group_request( @@ -1386,14 +1383,14 @@ async def create_event_hub_consumer_group( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(consumer_group_body, (IO, bytes)): + if isinstance(consumer_group_body, (IOBase, bytes)): _content = consumer_group_body else: _json = self._serialize.body(consumer_group_body, "EventHubConsumerGroupBodyDescription") @@ -1471,7 +1468,7 @@ async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-retur _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_event_hub_consumer_group_request( @@ -1530,7 +1527,7 @@ def list_jobs( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) error_map = { @@ -1635,7 +1632,7 @@ async def get_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) request = build_get_job_request( @@ -1696,7 +1693,7 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) error_map = { @@ -1790,7 +1787,7 @@ def get_endpoint_health( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) error_map = { @@ -1933,14 +1930,14 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -2073,14 +2070,14 @@ async def test_all_routes( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestAllRoutesInput") @@ -2215,14 +2212,14 @@ async def test_route( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestRouteInput") @@ -2289,7 +2286,7 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { @@ -2394,7 +2391,7 @@ async def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) request = build_get_keys_for_key_name_request( @@ -2544,14 +2541,14 @@ async def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -2705,14 +2702,14 @@ async def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_operations.py index 49f6267df7bb..1aab95635061 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._operations import build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,6 +51,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: @@ -70,7 +66,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_private_endpoint_connections_operations.py index 57e9be3b5662..cc8744e51e33 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_private_endpoint_connections_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -35,10 +35,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list( @@ -90,7 +87,7 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) request = build_list_request( @@ -158,7 +155,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) request = build_get_request( @@ -216,14 +213,14 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): + if isinstance(private_endpoint_connection, (IOBase, bytes)): _content = private_endpoint_connection else: _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") @@ -399,7 +396,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -459,7 +456,7 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) request = build_delete_request( @@ -534,7 +531,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_private_link_resources_operations.py index cbee173d62d7..2449c632c368 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_private_link_resources_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -28,10 +27,6 @@ from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request, build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: @@ -81,7 +77,7 @@ async def list(self, resource_group_name: str, resource_name: str, **kwargs: Any _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.PrivateLinkResources] = kwargs.pop("cls", None) request = build_list_request( @@ -149,7 +145,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_resource_provider_common_operations.py index 4be27189cb98..4dfaaf86943e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_resource_provider_common_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -28,10 +27,6 @@ from ..._vendor import _convert_request from ...operations._resource_provider_common_operations import build_get_subscription_quota_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: @@ -77,7 +73,7 @@ async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptio _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) request = build_get_subscription_quota_request( diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_iot_hub_client_enums.py index 582048bfa653..4d9507b40cc5 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_iot_hub_client_enums.py @@ -148,6 +148,7 @@ class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): REBOOT_DEVICE = "rebootDevice" FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" + IMPORT_ENUM = "import" class NetworkRuleIPAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_models_py3.py index 6f3451b6eec9..626371628752 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_models_py3.py @@ -1947,7 +1947,7 @@ class JobResponse(_serialization.Model): :vartype end_time_utc: ~datetime.datetime :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", - "factoryResetDevice", and "firmwareUpdate". + "factoryResetDevice", "firmwareUpdate", and "import". :vartype type: str or ~azure.mgmt.iothub.v2021_07_01.models.JobType :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", "completed", "failed", and "cancelled". diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_certificates_operations.py index a010eacde859..cd34a0515309 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_certificates_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -26,12 +26,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +41,7 @@ def build_list_by_iot_hub_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +55,7 @@ def build_list_by_iot_hub_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +72,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -93,7 +89,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,7 +112,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -134,7 +130,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -161,7 +157,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -178,7 +174,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -202,7 +198,7 @@ def build_generate_verification_code_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -219,7 +215,7 @@ def build_generate_verification_code_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -243,7 +239,7 @@ def build_verify_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -261,7 +257,7 @@ def build_verify_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -293,6 +289,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_iot_hub( @@ -322,7 +319,7 @@ def list_by_iot_hub( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) request = build_list_by_iot_hub_request( @@ -390,7 +387,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -547,14 +544,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_description, (IO, bytes)): + if isinstance(certificate_description, (IOBase, bytes)): _content = certificate_description else: _json = self._serialize.body(certificate_description, "CertificateDescription") @@ -635,7 +632,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -704,7 +701,7 @@ def generate_verification_code( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) request = build_generate_verification_code_request( @@ -863,14 +860,14 @@ def verify( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_verification_body, (IO, bytes)): + if isinstance(certificate_verification_body, (IOBase, bytes)): _content = certificate_verification_body else: _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_iot_hub_operations.py index 8ad5413bf393..96ae5f3d2e99 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_iot_hub_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -28,12 +28,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +43,7 @@ def build_manual_failover_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -62,7 +58,7 @@ def build_manual_failover_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -93,6 +89,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, @@ -112,14 +109,14 @@ def _manual_failover_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(failover_input, (IO, bytes)): + if isinstance(failover_input, (IOBase, bytes)): _content = failover_input else: _json = self._serialize.body(failover_input, "FailoverInput") @@ -278,7 +275,7 @@ def begin_manual_failover( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_iot_hub_resource_operations.py index fe0dbb79d65b..be199fe92250 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -30,12 +30,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +43,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +57,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +74,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -93,7 +89,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +110,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -129,7 +125,7 @@ def build_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -148,7 +144,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -162,7 +158,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -177,7 +173,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -186,7 +182,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -201,7 +197,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -214,7 +210,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -231,7 +227,7 @@ def build_get_stats_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -245,7 +241,7 @@ def build_get_stats_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -262,7 +258,7 @@ def build_get_valid_skus_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -276,7 +272,7 @@ def build_get_valid_skus_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -293,7 +289,7 @@ def build_list_event_hub_consumer_groups_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -308,7 +304,7 @@ def build_list_event_hub_consumer_groups_request( "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -330,7 +326,7 @@ def build_get_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -346,7 +342,7 @@ def build_get_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -368,7 +364,7 @@ def build_create_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -385,7 +381,7 @@ def build_create_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -409,7 +405,7 @@ def build_delete_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -425,7 +421,7 @@ def build_delete_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -442,7 +438,7 @@ def build_list_jobs_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -456,7 +452,7 @@ def build_list_jobs_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -473,7 +469,7 @@ def build_get_job_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -488,7 +484,7 @@ def build_get_job_request( "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -505,7 +501,7 @@ def build_get_quota_metrics_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -519,7 +515,7 @@ def build_get_quota_metrics_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -536,7 +532,7 @@ def build_get_endpoint_health_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -550,7 +546,7 @@ def build_get_endpoint_health_request( "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -565,7 +561,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -577,7 +573,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -596,7 +592,7 @@ def build_test_all_routes_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -611,7 +607,7 @@ def build_test_all_routes_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -630,7 +626,7 @@ def build_test_route_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -645,7 +641,7 @@ def build_test_route_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -664,7 +660,7 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -678,7 +674,7 @@ def build_list_keys_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -695,7 +691,7 @@ def build_get_keys_for_key_name_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -710,7 +706,7 @@ def build_get_keys_for_key_name_request( "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -727,7 +723,7 @@ def build_export_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -742,7 +738,7 @@ def build_export_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -761,7 +757,7 @@ def build_import_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -776,7 +772,7 @@ def build_import_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -807,6 +803,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -834,7 +831,7 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -891,14 +888,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -1082,7 +1079,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1142,14 +1139,14 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_tags, (IO, bytes)): + if isinstance(iot_hub_tags, (IOBase, bytes)): _content = iot_hub_tags else: _json = self._serialize.body(iot_hub_tags, "TagsResource") @@ -1299,7 +1296,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1358,7 +1355,7 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) request = build_delete_request( @@ -1433,7 +1430,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1489,7 +1486,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescrip _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1574,7 +1571,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1672,7 +1669,7 @@ def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) request = build_get_stats_request( @@ -1732,7 +1729,7 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1831,7 +1828,7 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) error_map = { @@ -1938,7 +1935,7 @@ def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_get_event_hub_consumer_group_request( @@ -2097,14 +2094,14 @@ def create_event_hub_consumer_group( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(consumer_group_body, (IO, bytes)): + if isinstance(consumer_group_body, (IOBase, bytes)): _content = consumer_group_body else: _json = self._serialize.body(consumer_group_body, "EventHubConsumerGroupBodyDescription") @@ -2182,7 +2179,7 @@ def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-stat _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_event_hub_consumer_group_request( @@ -2238,7 +2235,7 @@ def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) error_map = { @@ -2341,7 +2338,7 @@ def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **k _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) request = build_get_job_request( @@ -2402,7 +2399,7 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) error_map = { @@ -2495,7 +2492,7 @@ def get_endpoint_health( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) error_map = { @@ -2638,14 +2635,14 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -2778,14 +2775,14 @@ def test_all_routes( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestAllRoutesInput") @@ -2920,14 +2917,14 @@ def test_route( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestRouteInput") @@ -2994,7 +2991,7 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { @@ -3099,7 +3096,7 @@ def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) request = build_get_keys_for_key_name_request( @@ -3249,14 +3246,14 @@ def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -3410,14 +3407,14 @@ def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_operations.py index eb5e7f4cc4cf..8e59822bea42 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +40,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,6 +73,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: @@ -91,7 +87,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_private_endpoint_connections_operations.py index def772be4951..53bd5c820636 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_private_endpoint_connections_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -28,12 +28,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +43,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +57,7 @@ def build_list_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -82,7 +78,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -99,7 +95,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -120,7 +116,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -138,7 +134,7 @@ def build_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -161,7 +157,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -178,7 +174,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -207,6 +203,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -236,7 +233,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) request = build_list_request( @@ -304,7 +301,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) request = build_get_request( @@ -362,14 +359,14 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): + if isinstance(private_endpoint_connection, (IOBase, bytes)): _content = private_endpoint_connection else: _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") @@ -545,7 +542,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -605,7 +602,7 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) request = build_delete_request( @@ -680,7 +677,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_private_link_resources_operations.py index 159f4c94f056..2e0aa6fb6d6b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_private_link_resources_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -26,12 +25,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +40,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +54,7 @@ def build_list_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +71,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -91,7 +86,7 @@ def build_get_request( "groupId": _SERIALIZER.url("group_id", group_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -120,6 +115,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: @@ -147,7 +143,7 @@ def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.PrivateLinkResources] = kwargs.pop("cls", None) request = build_list_request( @@ -215,7 +211,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_resource_provider_common_operations.py index 42ab6273f39a..34465f867579 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_resource_provider_common_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -26,12 +25,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +38,7 @@ def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -52,7 +47,7 @@ def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -81,6 +76,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: @@ -104,7 +100,7 @@ def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuota _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) request = build_get_subscription_quota_request( diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_configuration.py index f648a2a2b80b..b506f9f41b4b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", "2021-07-02") + api_version: str = kwargs.pop("api_version", "2021-07-02") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_iot_hub_client.py index 71494c802314..3818a1ab6409 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_iot_hub_client.py @@ -77,18 +77,22 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2021-07-02") + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-07-02" + ) self.resource_provider_common = ResourceProviderCommonOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-07-02" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-07-02" ) - self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) + self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize, "2021-07-02") self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-07-02" ) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-07-02" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): if files: request.set_formdata_body(files) return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_version.py index 1d9186e2318f..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.4.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/_configuration.py index 82babdbe1b53..fb4f18f303d6 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", "2021-07-02") + api_version: str = kwargs.pop("api_version", "2021-07-02") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/_iot_hub_client.py index 3464dc83b52b..163bec6e4b39 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/_iot_hub_client.py @@ -78,18 +78,22 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2021-07-02") + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-07-02" + ) self.resource_provider_common = ResourceProviderCommonOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-07-02" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-07-02" ) - self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) + self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize, "2021-07-02") self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-07-02" ) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-07-02" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_certificates_operations.py index d69c6734b9f3..edc5a80a7a45 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_certificates_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -35,10 +35,6 @@ build_verify_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list_by_iot_hub( @@ -90,7 +87,7 @@ async def list_by_iot_hub( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) request = build_list_by_iot_hub_request( @@ -158,7 +155,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -315,14 +312,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_description, (IO, bytes)): + if isinstance(certificate_description, (IOBase, bytes)): _content = certificate_description else: _json = self._serialize.body(certificate_description, "CertificateDescription") @@ -403,7 +400,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -472,7 +469,7 @@ async def generate_verification_code( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) request = build_generate_verification_code_request( @@ -631,14 +628,14 @@ async def verify( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_verification_body, (IO, bytes)): + if isinstance(certificate_verification_body, (IOBase, bytes)): _content = certificate_verification_body else: _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_iot_hub_operations.py index 775a721da768..4da42bc474e0 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_iot_hub_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._iot_hub_operations import build_manual_failover_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") async def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, @@ -75,14 +72,14 @@ async def _manual_failover_initial( # pylint: disable=inconsistent-return-state _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(failover_input, (IO, bytes)): + if isinstance(failover_input, (IOBase, bytes)): _content = failover_input else: _json = self._serialize.body(failover_input, "FailoverInput") @@ -241,7 +238,7 @@ async def begin_manual_failover( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_iot_hub_resource_operations.py index c16cf9ac34e4..412f907ffc15 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -57,10 +57,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -83,6 +79,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -110,7 +107,7 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -167,14 +164,14 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -361,7 +358,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -421,14 +418,14 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_tags, (IO, bytes)): + if isinstance(iot_hub_tags, (IOBase, bytes)): _content = iot_hub_tags else: _json = self._serialize.body(iot_hub_tags, "TagsResource") @@ -581,7 +578,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -640,7 +637,7 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) request = build_delete_request( @@ -716,7 +713,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -773,7 +770,7 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDe _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -861,7 +858,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -961,7 +958,7 @@ async def get_stats( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) request = build_get_stats_request( @@ -1021,7 +1018,7 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1120,7 +1117,7 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) error_map = { @@ -1227,7 +1224,7 @@ async def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_get_event_hub_consumer_group_request( @@ -1386,14 +1383,14 @@ async def create_event_hub_consumer_group( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(consumer_group_body, (IO, bytes)): + if isinstance(consumer_group_body, (IOBase, bytes)): _content = consumer_group_body else: _json = self._serialize.body(consumer_group_body, "EventHubConsumerGroupBodyDescription") @@ -1471,7 +1468,7 @@ async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-retur _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_event_hub_consumer_group_request( @@ -1530,7 +1527,7 @@ def list_jobs( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) error_map = { @@ -1635,7 +1632,7 @@ async def get_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) request = build_get_job_request( @@ -1696,7 +1693,7 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) error_map = { @@ -1790,7 +1787,7 @@ def get_endpoint_health( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) error_map = { @@ -1933,14 +1930,14 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -2073,14 +2070,14 @@ async def test_all_routes( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestAllRoutesInput") @@ -2215,14 +2212,14 @@ async def test_route( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestRouteInput") @@ -2289,7 +2286,7 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { @@ -2394,7 +2391,7 @@ async def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) request = build_get_keys_for_key_name_request( @@ -2544,14 +2541,14 @@ async def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -2705,14 +2702,14 @@ async def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_operations.py index f11a880d852c..941a8adcc06c 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._operations import build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,6 +51,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: @@ -70,7 +66,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_private_endpoint_connections_operations.py index 24e9dbcd548c..ba7587ed3738 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_private_endpoint_connections_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -35,10 +35,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list( @@ -90,7 +87,7 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) request = build_list_request( @@ -158,7 +155,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) request = build_get_request( @@ -216,14 +213,14 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): + if isinstance(private_endpoint_connection, (IOBase, bytes)): _content = private_endpoint_connection else: _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") @@ -399,7 +396,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -459,7 +456,7 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) request = build_delete_request( @@ -534,7 +531,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_private_link_resources_operations.py index 81c7c16adc0b..b64e008fa0b2 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_private_link_resources_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -28,10 +27,6 @@ from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request, build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: @@ -81,7 +77,7 @@ async def list(self, resource_group_name: str, resource_name: str, **kwargs: Any _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.PrivateLinkResources] = kwargs.pop("cls", None) request = build_list_request( @@ -149,7 +145,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_resource_provider_common_operations.py index 4e24545ced9e..79569ba7fcaa 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/aio/operations/_resource_provider_common_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -28,10 +27,6 @@ from ..._vendor import _convert_request from ...operations._resource_provider_common_operations import build_get_subscription_quota_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: @@ -77,7 +73,7 @@ async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptio _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) request = build_get_subscription_quota_request( diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/models/_iot_hub_client_enums.py index 5d5a95accb2b..2d31d1e7ac49 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/models/_iot_hub_client_enums.py @@ -157,6 +157,7 @@ class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): REBOOT_DEVICE = "rebootDevice" FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" + IMPORT_ENUM = "import" class NetworkRuleIPAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/models/_models_py3.py index 9930b4d40fbc..99cdc2b590c6 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/models/_models_py3.py @@ -1961,7 +1961,7 @@ class JobResponse(_serialization.Model): :vartype end_time_utc: ~datetime.datetime :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", - "factoryResetDevice", and "firmwareUpdate". + "factoryResetDevice", "firmwareUpdate", and "import". :vartype type: str or ~azure.mgmt.iothub.v2021_07_02.models.JobType :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", "completed", "failed", and "cancelled". diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_certificates_operations.py index 5901a132a577..e7504ca8a218 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_certificates_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -26,12 +26,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +41,7 @@ def build_list_by_iot_hub_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +55,7 @@ def build_list_by_iot_hub_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +72,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -93,7 +89,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,7 +112,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -134,7 +130,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -161,7 +157,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -178,7 +174,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -202,7 +198,7 @@ def build_generate_verification_code_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -219,7 +215,7 @@ def build_generate_verification_code_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -243,7 +239,7 @@ def build_verify_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -261,7 +257,7 @@ def build_verify_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -293,6 +289,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_iot_hub( @@ -322,7 +319,7 @@ def list_by_iot_hub( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) request = build_list_by_iot_hub_request( @@ -390,7 +387,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -547,14 +544,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_description, (IO, bytes)): + if isinstance(certificate_description, (IOBase, bytes)): _content = certificate_description else: _json = self._serialize.body(certificate_description, "CertificateDescription") @@ -635,7 +632,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -704,7 +701,7 @@ def generate_verification_code( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) request = build_generate_verification_code_request( @@ -863,14 +860,14 @@ def verify( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_verification_body, (IO, bytes)): + if isinstance(certificate_verification_body, (IOBase, bytes)): _content = certificate_verification_body else: _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_iot_hub_operations.py index 2fd82f5f8e16..1cb67ee18521 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_iot_hub_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -28,12 +28,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +43,7 @@ def build_manual_failover_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -62,7 +58,7 @@ def build_manual_failover_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -93,6 +89,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, @@ -112,14 +109,14 @@ def _manual_failover_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(failover_input, (IO, bytes)): + if isinstance(failover_input, (IOBase, bytes)): _content = failover_input else: _json = self._serialize.body(failover_input, "FailoverInput") @@ -278,7 +275,7 @@ def begin_manual_failover( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_iot_hub_resource_operations.py index 1c4f40f56ebf..8b7d717dd335 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -30,12 +30,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +43,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +57,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +74,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -93,7 +89,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +110,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -129,7 +125,7 @@ def build_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -148,7 +144,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -162,7 +158,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -177,7 +173,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -186,7 +182,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -201,7 +197,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -214,7 +210,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -231,7 +227,7 @@ def build_get_stats_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -245,7 +241,7 @@ def build_get_stats_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -262,7 +258,7 @@ def build_get_valid_skus_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -276,7 +272,7 @@ def build_get_valid_skus_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -293,7 +289,7 @@ def build_list_event_hub_consumer_groups_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -308,7 +304,7 @@ def build_list_event_hub_consumer_groups_request( "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -330,7 +326,7 @@ def build_get_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -346,7 +342,7 @@ def build_get_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -368,7 +364,7 @@ def build_create_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -385,7 +381,7 @@ def build_create_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -409,7 +405,7 @@ def build_delete_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -425,7 +421,7 @@ def build_delete_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -442,7 +438,7 @@ def build_list_jobs_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -456,7 +452,7 @@ def build_list_jobs_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -473,7 +469,7 @@ def build_get_job_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -488,7 +484,7 @@ def build_get_job_request( "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -505,7 +501,7 @@ def build_get_quota_metrics_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -519,7 +515,7 @@ def build_get_quota_metrics_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -536,7 +532,7 @@ def build_get_endpoint_health_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -550,7 +546,7 @@ def build_get_endpoint_health_request( "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -565,7 +561,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -577,7 +573,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -596,7 +592,7 @@ def build_test_all_routes_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -611,7 +607,7 @@ def build_test_all_routes_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -630,7 +626,7 @@ def build_test_route_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -645,7 +641,7 @@ def build_test_route_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -664,7 +660,7 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -678,7 +674,7 @@ def build_list_keys_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -695,7 +691,7 @@ def build_get_keys_for_key_name_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -710,7 +706,7 @@ def build_get_keys_for_key_name_request( "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -727,7 +723,7 @@ def build_export_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -742,7 +738,7 @@ def build_export_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -761,7 +757,7 @@ def build_import_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -776,7 +772,7 @@ def build_import_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -807,6 +803,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -834,7 +831,7 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) request = build_get_request( @@ -891,14 +888,14 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -1082,7 +1079,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1142,14 +1139,14 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_tags, (IO, bytes)): + if isinstance(iot_hub_tags, (IOBase, bytes)): _content = iot_hub_tags else: _json = self._serialize.body(iot_hub_tags, "TagsResource") @@ -1299,7 +1296,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1358,7 +1355,7 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) request = build_delete_request( @@ -1433,7 +1430,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1489,7 +1486,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescrip _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1574,7 +1571,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1672,7 +1669,7 @@ def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) request = build_get_stats_request( @@ -1732,7 +1729,7 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) error_map = { @@ -1831,7 +1828,7 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) error_map = { @@ -1938,7 +1935,7 @@ def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) request = build_get_event_hub_consumer_group_request( @@ -2097,14 +2094,14 @@ def create_event_hub_consumer_group( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(consumer_group_body, (IO, bytes)): + if isinstance(consumer_group_body, (IOBase, bytes)): _content = consumer_group_body else: _json = self._serialize.body(consumer_group_body, "EventHubConsumerGroupBodyDescription") @@ -2182,7 +2179,7 @@ def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-stat _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_event_hub_consumer_group_request( @@ -2238,7 +2235,7 @@ def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) error_map = { @@ -2341,7 +2338,7 @@ def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **k _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) request = build_get_job_request( @@ -2402,7 +2399,7 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) error_map = { @@ -2495,7 +2492,7 @@ def get_endpoint_health( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) error_map = { @@ -2638,14 +2635,14 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -2778,14 +2775,14 @@ def test_all_routes( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestAllRoutesInput") @@ -2920,14 +2917,14 @@ def test_route( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestRouteInput") @@ -2994,7 +2991,7 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { @@ -3099,7 +3096,7 @@ def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) request = build_get_keys_for_key_name_request( @@ -3249,14 +3246,14 @@ def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -3410,14 +3407,14 @@ def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_operations.py index 19c412b63495..00f47f181c4e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +40,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,6 +73,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: @@ -91,7 +87,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_private_endpoint_connections_operations.py index 43e7a167abe2..336ed88920a0 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_private_endpoint_connections_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -28,12 +28,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +43,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +57,7 @@ def build_list_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -82,7 +78,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -99,7 +95,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -120,7 +116,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -138,7 +134,7 @@ def build_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -161,7 +157,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -178,7 +174,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -207,6 +203,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -236,7 +233,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) request = build_list_request( @@ -304,7 +301,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) request = build_get_request( @@ -362,14 +359,14 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): + if isinstance(private_endpoint_connection, (IOBase, bytes)): _content = private_endpoint_connection else: _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") @@ -545,7 +542,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -605,7 +602,7 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) request = build_delete_request( @@ -680,7 +677,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_private_link_resources_operations.py index e74a22a2564e..cd25a4917b2e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_private_link_resources_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -26,12 +25,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +40,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +54,7 @@ def build_list_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +71,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -91,7 +86,7 @@ def build_get_request( "groupId": _SERIALIZER.url("group_id", group_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -120,6 +115,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: @@ -147,7 +143,7 @@ def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.PrivateLinkResources] = kwargs.pop("cls", None) request = build_list_request( @@ -215,7 +211,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_resource_provider_common_operations.py index d99dfbb7d85b..3ce1a3040bbf 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_02/operations/_resource_provider_common_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -26,12 +25,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +38,7 @@ def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -52,7 +47,7 @@ def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -81,6 +76,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: @@ -104,7 +100,7 @@ def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuota _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-07-02"] = kwargs.pop("api_version", _params.pop("api-version", "2021-07-02")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-02")) cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) request = build_get_subscription_quota_request( diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_configuration.py index 782c0b0e6df4..fffe98c1f99f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2022-04-30-preview"] = kwargs.pop("api_version", "2022-04-30-preview") + api_version: str = kwargs.pop("api_version", "2022-04-30-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_iot_hub_client.py index 47230c84ab39..544fdfabd265 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_iot_hub_client.py @@ -78,18 +78,26 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize, "2022-04-30-preview" + ) + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-04-30-preview" + ) self.resource_provider_common = ResourceProviderCommonOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-04-30-preview" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-04-30-preview" + ) + self.iot_hub = IotHubOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-04-30-preview" ) - self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-04-30-preview" ) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-04-30-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): if files: request.set_formdata_body(files) return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_version.py index 1d9186e2318f..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.4.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/_configuration.py index f6b98771b263..9f21c65c1b0d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2022-04-30-preview"] = kwargs.pop("api_version", "2022-04-30-preview") + api_version: str = kwargs.pop("api_version", "2022-04-30-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/_iot_hub_client.py index 36518f26b287..cc273a1fab57 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/_iot_hub_client.py @@ -79,18 +79,26 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize, "2022-04-30-preview" + ) + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-04-30-preview" + ) self.resource_provider_common = ResourceProviderCommonOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-04-30-preview" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-04-30-preview" + ) + self.iot_hub = IotHubOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-04-30-preview" ) - self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-04-30-preview" ) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-04-30-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_certificates_operations.py index 410c8d48543d..1115e34dd1ee 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_certificates_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -35,10 +35,6 @@ build_verify_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list_by_iot_hub( @@ -90,8 +87,8 @@ async def list_by_iot_hub( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) @@ -160,8 +157,8 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) @@ -320,8 +317,8 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) @@ -329,7 +326,7 @@ async def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_description, (IO, bytes)): + if isinstance(certificate_description, (IOBase, bytes)): _content = certificate_description else: _json = self._serialize.body(certificate_description, "CertificateDescription") @@ -410,8 +407,8 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) @@ -481,8 +478,8 @@ async def generate_verification_code( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) @@ -642,8 +639,8 @@ async def verify( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) @@ -651,7 +648,7 @@ async def verify( content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_verification_body, (IO, bytes)): + if isinstance(certificate_verification_body, (IOBase, bytes)): _content = certificate_verification_body else: _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_iot_hub_operations.py index 9c480d56d286..599379248508 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_iot_hub_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._iot_hub_operations import build_manual_failover_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") async def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, @@ -75,8 +72,8 @@ async def _manual_failover_initial( # pylint: disable=inconsistent-return-state _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -84,7 +81,7 @@ async def _manual_failover_initial( # pylint: disable=inconsistent-return-state content_type = content_type or "application/json" _json = None _content = None - if isinstance(failover_input, (IO, bytes)): + if isinstance(failover_input, (IOBase, bytes)): _content = failover_input else: _json = self._serialize.body(failover_input, "FailoverInput") @@ -243,8 +240,8 @@ async def begin_manual_failover( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_iot_hub_resource_operations.py index 2b993427d3d9..d329e5a07a3b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -57,10 +57,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -83,6 +79,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -110,8 +107,8 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -169,8 +166,8 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -178,7 +175,7 @@ async def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -365,8 +362,8 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -427,8 +424,8 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -436,7 +433,7 @@ async def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_tags, (IO, bytes)): + if isinstance(iot_hub_tags, (IOBase, bytes)): _content = iot_hub_tags else: _json = self._serialize.body(iot_hub_tags, "TagsResource") @@ -594,8 +591,8 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -661,8 +658,8 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) @@ -745,8 +742,8 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -804,8 +801,8 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDe _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) @@ -894,8 +891,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) @@ -996,8 +993,8 @@ async def get_stats( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) @@ -1058,8 +1055,8 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) @@ -1159,8 +1156,8 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) @@ -1268,8 +1265,8 @@ async def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) @@ -1429,8 +1426,8 @@ async def create_event_hub_consumer_group( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) @@ -1438,7 +1435,7 @@ async def create_event_hub_consumer_group( content_type = content_type or "application/json" _json = None _content = None - if isinstance(consumer_group_body, (IO, bytes)): + if isinstance(consumer_group_body, (IOBase, bytes)): _content = consumer_group_body else: _json = self._serialize.body(consumer_group_body, "EventHubConsumerGroupBodyDescription") @@ -1516,8 +1513,8 @@ async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-retur _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) @@ -1577,8 +1574,8 @@ def list_jobs( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) @@ -1684,8 +1681,8 @@ async def get_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) @@ -1747,8 +1744,8 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) @@ -1843,8 +1840,8 @@ def get_endpoint_health( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) @@ -1988,8 +1985,8 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) @@ -1997,7 +1994,7 @@ async def check_name_availability( content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -2130,8 +2127,8 @@ async def test_all_routes( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) @@ -2139,7 +2136,7 @@ async def test_all_routes( content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestAllRoutesInput") @@ -2274,8 +2271,8 @@ async def test_route( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) @@ -2283,7 +2280,7 @@ async def test_route( content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestRouteInput") @@ -2350,8 +2347,8 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) @@ -2457,8 +2454,8 @@ async def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) @@ -2610,8 +2607,8 @@ async def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) @@ -2619,7 +2616,7 @@ async def export_devices( content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -2774,8 +2771,8 @@ async def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) @@ -2783,7 +2780,7 @@ async def import_devices( content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_operations.py index fbcd166ee4a3..ea3f98181749 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._operations import build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,6 +51,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: @@ -70,8 +66,8 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_private_endpoint_connections_operations.py index 8554807e3a68..9bc4a4cf0739 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_private_endpoint_connections_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -35,10 +35,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list( @@ -90,8 +87,8 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) @@ -160,8 +157,8 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) @@ -220,8 +217,8 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) @@ -229,7 +226,7 @@ async def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): + if isinstance(private_endpoint_connection, (IOBase, bytes)): _content = private_endpoint_connection else: _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") @@ -410,8 +407,8 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) @@ -472,8 +469,8 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) @@ -554,8 +551,8 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_private_link_resources_operations.py index 245360d0aab4..137e98913442 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_private_link_resources_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -28,10 +27,6 @@ from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request, build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: @@ -81,8 +77,8 @@ async def list(self, resource_group_name: str, resource_name: str, **kwargs: Any _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.PrivateLinkResources] = kwargs.pop("cls", None) @@ -151,8 +147,8 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_resource_provider_common_operations.py index 1946e14b3916..b585409ab4d0 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/aio/operations/_resource_provider_common_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -28,10 +27,6 @@ from ..._vendor import _convert_request from ...operations._resource_provider_common_operations import build_get_subscription_quota_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: @@ -77,8 +73,8 @@ async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptio _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/models/_iot_hub_client_enums.py index 2562e239f8a9..ee0dc88b1223 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/models/_iot_hub_client_enums.py @@ -157,6 +157,7 @@ class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): REBOOT_DEVICE = "rebootDevice" FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" + IMPORT_ENUM = "import" class NetworkRuleIPAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/models/_models_py3.py index 00a1e91a26c7..76e73704a1de 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/models/_models_py3.py @@ -2058,7 +2058,7 @@ class JobResponse(_serialization.Model): :vartype end_time_utc: ~datetime.datetime :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", - "factoryResetDevice", and "firmwareUpdate". + "factoryResetDevice", "firmwareUpdate", and "import". :vartype type: str or ~azure.mgmt.iothub.v2022_04_30_preview.models.JobType :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", "completed", "failed", and "cancelled". diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_certificates_operations.py index 50175e1d0bb5..47cc0ffb25ad 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_certificates_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -26,12 +26,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,9 +41,7 @@ def build_list_by_iot_hub_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +55,7 @@ def build_list_by_iot_hub_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,9 +72,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -97,7 +89,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -120,9 +112,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -140,7 +130,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -167,9 +157,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -186,7 +174,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -210,9 +198,7 @@ def build_generate_verification_code_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -229,7 +215,7 @@ def build_generate_verification_code_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -253,9 +239,7 @@ def build_verify_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -273,7 +257,7 @@ def build_verify_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -305,6 +289,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_iot_hub( @@ -334,8 +319,8 @@ def list_by_iot_hub( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) @@ -404,8 +389,8 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) @@ -564,8 +549,8 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) @@ -573,7 +558,7 @@ def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_description, (IO, bytes)): + if isinstance(certificate_description, (IOBase, bytes)): _content = certificate_description else: _json = self._serialize.body(certificate_description, "CertificateDescription") @@ -654,8 +639,8 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) @@ -725,8 +710,8 @@ def generate_verification_code( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) @@ -886,8 +871,8 @@ def verify( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) @@ -895,7 +880,7 @@ def verify( content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_verification_body, (IO, bytes)): + if isinstance(certificate_verification_body, (IOBase, bytes)): _content = certificate_verification_body else: _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_iot_hub_operations.py index af83b6046a7d..5cbc22662e25 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_iot_hub_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -28,12 +28,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,9 +43,7 @@ def build_manual_failover_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -64,7 +58,7 @@ def build_manual_failover_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -95,6 +89,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, @@ -114,8 +109,8 @@ def _manual_failover_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -123,7 +118,7 @@ def _manual_failover_initial( # pylint: disable=inconsistent-return-statements content_type = content_type or "application/json" _json = None _content = None - if isinstance(failover_input, (IO, bytes)): + if isinstance(failover_input, (IOBase, bytes)): _content = failover_input else: _json = self._serialize.body(failover_input, "FailoverInput") @@ -282,8 +277,8 @@ def begin_manual_failover( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_iot_hub_resource_operations.py index 0a650b0c6be6..ff622dec44c0 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -30,12 +30,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,9 +43,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +57,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,9 +74,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -97,7 +89,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -118,9 +110,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -135,7 +125,7 @@ def build_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,9 +144,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -170,7 +158,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -185,9 +173,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -196,7 +182,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -211,9 +197,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -226,7 +210,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -243,9 +227,7 @@ def build_get_stats_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -259,7 +241,7 @@ def build_get_stats_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -276,9 +258,7 @@ def build_get_valid_skus_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -292,7 +272,7 @@ def build_get_valid_skus_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -309,9 +289,7 @@ def build_list_event_hub_consumer_groups_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -326,7 +304,7 @@ def build_list_event_hub_consumer_groups_request( "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -348,9 +326,7 @@ def build_get_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -366,7 +342,7 @@ def build_get_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -388,9 +364,7 @@ def build_create_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -407,7 +381,7 @@ def build_create_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -431,9 +405,7 @@ def build_delete_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -449,7 +421,7 @@ def build_delete_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -466,9 +438,7 @@ def build_list_jobs_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -482,7 +452,7 @@ def build_list_jobs_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -499,9 +469,7 @@ def build_get_job_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -516,7 +484,7 @@ def build_get_job_request( "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -533,9 +501,7 @@ def build_get_quota_metrics_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -549,7 +515,7 @@ def build_get_quota_metrics_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -566,9 +532,7 @@ def build_get_endpoint_health_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -582,7 +546,7 @@ def build_get_endpoint_health_request( "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -597,9 +561,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -611,7 +573,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -630,9 +592,7 @@ def build_test_all_routes_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -647,7 +607,7 @@ def build_test_all_routes_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -666,9 +626,7 @@ def build_test_route_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -683,7 +641,7 @@ def build_test_route_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -702,9 +660,7 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -718,7 +674,7 @@ def build_list_keys_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -735,9 +691,7 @@ def build_get_keys_for_key_name_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -752,7 +706,7 @@ def build_get_keys_for_key_name_request( "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -769,9 +723,7 @@ def build_export_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -786,7 +738,7 @@ def build_export_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -805,9 +757,7 @@ def build_import_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -822,7 +772,7 @@ def build_import_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -853,6 +803,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -880,8 +831,8 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -939,8 +890,8 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -948,7 +899,7 @@ def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -1135,8 +1086,8 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -1197,8 +1148,8 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -1206,7 +1157,7 @@ def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_tags, (IO, bytes)): + if isinstance(iot_hub_tags, (IOBase, bytes)): _content = iot_hub_tags else: _json = self._serialize.body(iot_hub_tags, "TagsResource") @@ -1364,8 +1315,8 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -1431,8 +1382,8 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) @@ -1514,8 +1465,8 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1573,8 +1524,8 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescrip _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) @@ -1661,8 +1612,8 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) @@ -1761,8 +1712,8 @@ def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) @@ -1823,8 +1774,8 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) @@ -1924,8 +1875,8 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) @@ -2033,8 +1984,8 @@ def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) @@ -2194,8 +2145,8 @@ def create_event_hub_consumer_group( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) @@ -2203,7 +2154,7 @@ def create_event_hub_consumer_group( content_type = content_type or "application/json" _json = None _content = None - if isinstance(consumer_group_body, (IO, bytes)): + if isinstance(consumer_group_body, (IOBase, bytes)): _content = consumer_group_body else: _json = self._serialize.body(consumer_group_body, "EventHubConsumerGroupBodyDescription") @@ -2281,8 +2232,8 @@ def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-stat _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) @@ -2339,8 +2290,8 @@ def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) @@ -2444,8 +2395,8 @@ def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **k _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) @@ -2507,8 +2458,8 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) @@ -2603,8 +2554,8 @@ def get_endpoint_health( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) @@ -2748,8 +2699,8 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) @@ -2757,7 +2708,7 @@ def check_name_availability( content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -2890,8 +2841,8 @@ def test_all_routes( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) @@ -2899,7 +2850,7 @@ def test_all_routes( content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestAllRoutesInput") @@ -3034,8 +2985,8 @@ def test_route( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) @@ -3043,7 +2994,7 @@ def test_route( content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestRouteInput") @@ -3110,8 +3061,8 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) @@ -3217,8 +3168,8 @@ def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) @@ -3370,8 +3321,8 @@ def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) @@ -3379,7 +3330,7 @@ def export_devices( content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -3534,8 +3485,8 @@ def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) @@ -3543,7 +3494,7 @@ def import_devices( content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_operations.py index e456e04dabe3..4743e73e9087 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,9 +40,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -80,6 +73,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: @@ -93,8 +87,8 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_private_endpoint_connections_operations.py index 0189733563ef..a21d8a7d812b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_private_endpoint_connections_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -28,12 +28,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,9 +43,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +57,7 @@ def build_list_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -84,9 +78,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -103,7 +95,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -124,9 +116,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -144,7 +134,7 @@ def build_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -167,9 +157,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -186,7 +174,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -215,6 +203,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -244,8 +233,8 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) @@ -314,8 +303,8 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) @@ -374,8 +363,8 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) @@ -383,7 +372,7 @@ def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): + if isinstance(private_endpoint_connection, (IOBase, bytes)): _content = private_endpoint_connection else: _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") @@ -564,8 +553,8 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) @@ -626,8 +615,8 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) @@ -708,8 +697,8 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_private_link_resources_operations.py index 95585d4554d7..1fb3070fd220 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_private_link_resources_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -26,12 +25,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,9 +40,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +54,7 @@ def build_list_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,9 +71,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -95,7 +86,7 @@ def build_get_request( "groupId": _SERIALIZER.url("group_id", group_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -124,6 +115,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: @@ -151,8 +143,8 @@ def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.PrivateLinkResources] = kwargs.pop("cls", None) @@ -221,8 +213,8 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_resource_provider_common_operations.py index 656aae9b80c5..8dc50894e754 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_04_30_preview/operations/_resource_provider_common_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -26,12 +25,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,9 +38,7 @@ def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-04-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -54,7 +47,7 @@ def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,6 +76,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: @@ -106,8 +100,8 @@ def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuota _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-30-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-04-30-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-04-30-preview") ) cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/_configuration.py index 5906e1d9efa8..a2df4dc00cd0 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2022-11-15-preview"] = kwargs.pop("api_version", "2022-11-15-preview") + api_version: str = kwargs.pop("api_version", "2022-11-15-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/_iot_hub_client.py index b0d894205995..9bd8c4d66755 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/_iot_hub_client.py @@ -78,18 +78,26 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize, "2022-11-15-preview" + ) + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-11-15-preview" + ) self.resource_provider_common = ResourceProviderCommonOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-11-15-preview" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-11-15-preview" + ) + self.iot_hub = IotHubOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-11-15-preview" ) - self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-11-15-preview" ) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-11-15-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): if files: request.set_formdata_body(files) return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/_version.py index 1d9186e2318f..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.4.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/_configuration.py index 424a07e8c5fd..b4b74e6e4896 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,11 +14,6 @@ from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -42,7 +36,7 @@ class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-inst def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotHubClientConfiguration, self).__init__(**kwargs) - api_version: Literal["2022-11-15-preview"] = kwargs.pop("api_version", "2022-11-15-preview") + api_version: str = kwargs.pop("api_version", "2022-11-15-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/_iot_hub_client.py index 887319bebe8d..c4bff0c4297c 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/_iot_hub_client.py @@ -79,18 +79,26 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize, "2022-11-15-preview" + ) + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-11-15-preview" + ) self.resource_provider_common = ResourceProviderCommonOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-11-15-preview" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-11-15-preview" + ) + self.iot_hub = IotHubOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-11-15-preview" ) - self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize) self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-11-15-preview" ) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-11-15-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_certificates_operations.py index 812e0824575f..d1a05b4324d3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_certificates_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -35,10 +35,6 @@ build_verify_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list_by_iot_hub( @@ -90,8 +87,8 @@ async def list_by_iot_hub( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) @@ -160,8 +157,8 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) @@ -320,8 +317,8 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) @@ -329,7 +326,7 @@ async def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_description, (IO, bytes)): + if isinstance(certificate_description, (IOBase, bytes)): _content = certificate_description else: _json = self._serialize.body(certificate_description, "CertificateDescription") @@ -410,8 +407,8 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) @@ -481,8 +478,8 @@ async def generate_verification_code( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) @@ -642,8 +639,8 @@ async def verify( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) @@ -651,7 +648,7 @@ async def verify( content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_verification_body, (IO, bytes)): + if isinstance(certificate_verification_body, (IOBase, bytes)): _content = certificate_verification_body else: _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_iot_hub_operations.py index a869cb8964a9..17ba8747c709 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_iot_hub_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -30,10 +30,6 @@ from ..._vendor import _convert_request from ...operations._iot_hub_operations import build_manual_failover_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") async def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, @@ -75,8 +72,8 @@ async def _manual_failover_initial( # pylint: disable=inconsistent-return-state _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -84,7 +81,7 @@ async def _manual_failover_initial( # pylint: disable=inconsistent-return-state content_type = content_type or "application/json" _json = None _content = None - if isinstance(failover_input, (IO, bytes)): + if isinstance(failover_input, (IOBase, bytes)): _content = failover_input else: _json = self._serialize.body(failover_input, "FailoverInput") @@ -250,8 +247,8 @@ async def begin_manual_failover( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_iot_hub_resource_operations.py index 39176bdf4d81..6688f7ad80cb 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -57,10 +57,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -83,6 +79,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -110,8 +107,8 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -169,8 +166,8 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -178,7 +175,7 @@ async def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -365,8 +362,8 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -427,8 +424,8 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -436,7 +433,7 @@ async def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_tags, (IO, bytes)): + if isinstance(iot_hub_tags, (IOBase, bytes)): _content = iot_hub_tags else: _json = self._serialize.body(iot_hub_tags, "TagsResource") @@ -594,8 +591,8 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -661,8 +658,8 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) @@ -745,8 +742,8 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -804,8 +801,8 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDe _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) @@ -894,8 +891,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) @@ -996,8 +993,8 @@ async def get_stats( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) @@ -1058,8 +1055,8 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) @@ -1159,8 +1156,8 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) @@ -1268,8 +1265,8 @@ async def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) @@ -1429,8 +1426,8 @@ async def create_event_hub_consumer_group( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) @@ -1438,7 +1435,7 @@ async def create_event_hub_consumer_group( content_type = content_type or "application/json" _json = None _content = None - if isinstance(consumer_group_body, (IO, bytes)): + if isinstance(consumer_group_body, (IOBase, bytes)): _content = consumer_group_body else: _json = self._serialize.body(consumer_group_body, "EventHubConsumerGroupBodyDescription") @@ -1516,8 +1513,8 @@ async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-retur _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) @@ -1577,8 +1574,8 @@ def list_jobs( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) @@ -1684,8 +1681,8 @@ async def get_job( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) @@ -1747,8 +1744,8 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) @@ -1843,8 +1840,8 @@ def get_endpoint_health( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) @@ -1988,8 +1985,8 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) @@ -1997,7 +1994,7 @@ async def check_name_availability( content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -2130,8 +2127,8 @@ async def test_all_routes( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) @@ -2139,7 +2136,7 @@ async def test_all_routes( content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestAllRoutesInput") @@ -2274,8 +2271,8 @@ async def test_route( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) @@ -2283,7 +2280,7 @@ async def test_route( content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestRouteInput") @@ -2350,8 +2347,8 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) @@ -2457,8 +2454,8 @@ async def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) @@ -2610,8 +2607,8 @@ async def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) @@ -2619,7 +2616,7 @@ async def export_devices( content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -2774,8 +2771,8 @@ async def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) @@ -2783,7 +2780,7 @@ async def import_devices( content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_operations.py index d58800706708..c99e6d8e50f5 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._operations import build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,6 +51,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: @@ -70,8 +66,8 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_private_endpoint_connections_operations.py index 64931e95c17c..61a0f6f007ed 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_private_endpoint_connections_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -35,10 +35,6 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list( @@ -90,8 +87,8 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) @@ -160,8 +157,8 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) @@ -220,8 +217,8 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) @@ -229,7 +226,7 @@ async def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): + if isinstance(private_endpoint_connection, (IOBase, bytes)): _content = private_endpoint_connection else: _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") @@ -410,8 +407,8 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) @@ -472,8 +469,8 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) @@ -554,8 +551,8 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_private_link_resources_operations.py index 49017be5825a..fbac3975abc4 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_private_link_resources_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -28,10 +27,6 @@ from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request, build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: @@ -81,8 +77,8 @@ async def list(self, resource_group_name: str, resource_name: str, **kwargs: Any _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.PrivateLinkResources] = kwargs.pop("cls", None) @@ -151,8 +147,8 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_resource_provider_common_operations.py index abff905b81cd..5058d8c9f0d9 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/aio/operations/_resource_provider_common_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -28,10 +27,6 @@ from ..._vendor import _convert_request from ...operations._resource_provider_common_operations import build_get_subscription_quota_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: @@ -77,8 +73,8 @@ async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptio _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/models/_iot_hub_client_enums.py index faf4c32c1f5c..8e8bf07cccb6 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/models/_iot_hub_client_enums.py @@ -165,6 +165,7 @@ class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): REBOOT_DEVICE = "rebootDevice" FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" + IMPORT_ENUM = "import" class NetworkRuleIPAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/models/_models_py3.py index 7a589416a3b4..ee2b42a2a43c 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/models/_models_py3.py @@ -2067,7 +2067,7 @@ class JobResponse(_serialization.Model): :vartype end_time_utc: ~datetime.datetime :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", - "factoryResetDevice", and "firmwareUpdate". + "factoryResetDevice", "firmwareUpdate", and "import". :vartype type: str or ~azure.mgmt.iothub.v2022_11_15_preview.models.JobType :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", "completed", "failed", and "cancelled". diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_certificates_operations.py index cde4d9858aa5..c202a3741653 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_certificates_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -26,12 +26,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,9 +41,7 @@ def build_list_by_iot_hub_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +55,7 @@ def build_list_by_iot_hub_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,9 +72,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -97,7 +89,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -120,9 +112,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -140,7 +130,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -167,9 +157,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -186,7 +174,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -210,9 +198,7 @@ def build_generate_verification_code_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -229,7 +215,7 @@ def build_generate_verification_code_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -253,9 +239,7 @@ def build_verify_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -273,7 +257,7 @@ def build_verify_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -305,6 +289,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_iot_hub( @@ -334,8 +319,8 @@ def list_by_iot_hub( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) @@ -404,8 +389,8 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) @@ -564,8 +549,8 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) @@ -573,7 +558,7 @@ def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_description, (IO, bytes)): + if isinstance(certificate_description, (IOBase, bytes)): _content = certificate_description else: _json = self._serialize.body(certificate_description, "CertificateDescription") @@ -654,8 +639,8 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) @@ -725,8 +710,8 @@ def generate_verification_code( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) @@ -886,8 +871,8 @@ def verify( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) @@ -895,7 +880,7 @@ def verify( content_type = content_type or "application/json" _json = None _content = None - if isinstance(certificate_verification_body, (IO, bytes)): + if isinstance(certificate_verification_body, (IOBase, bytes)): _content = certificate_verification_body else: _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_iot_hub_operations.py index 23abf318752f..6a3a98ea9200 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_iot_hub_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -28,12 +28,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,9 +43,7 @@ def build_manual_failover_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -64,7 +58,7 @@ def build_manual_failover_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -95,6 +89,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") def _manual_failover_initial( # pylint: disable=inconsistent-return-statements self, @@ -114,8 +109,8 @@ def _manual_failover_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) @@ -123,7 +118,7 @@ def _manual_failover_initial( # pylint: disable=inconsistent-return-statements content_type = content_type or "application/json" _json = None _content = None - if isinstance(failover_input, (IO, bytes)): + if isinstance(failover_input, (IOBase, bytes)): _content = failover_input else: _json = self._serialize.body(failover_input, "FailoverInput") @@ -289,8 +284,8 @@ def begin_manual_failover( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_iot_hub_resource_operations.py index 72fa1b637cff..e0e417990fbf 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_iot_hub_resource_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -30,12 +30,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,9 +43,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +57,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,9 +74,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -97,7 +89,7 @@ def build_create_or_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -118,9 +110,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -135,7 +125,7 @@ def build_update_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,9 +144,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -170,7 +158,7 @@ def build_delete_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -185,9 +173,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -196,7 +182,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -211,9 +197,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -226,7 +210,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -243,9 +227,7 @@ def build_get_stats_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -259,7 +241,7 @@ def build_get_stats_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -276,9 +258,7 @@ def build_get_valid_skus_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -292,7 +272,7 @@ def build_get_valid_skus_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -309,9 +289,7 @@ def build_list_event_hub_consumer_groups_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -326,7 +304,7 @@ def build_list_event_hub_consumer_groups_request( "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -348,9 +326,7 @@ def build_get_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -366,7 +342,7 @@ def build_get_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -388,9 +364,7 @@ def build_create_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -407,7 +381,7 @@ def build_create_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -431,9 +405,7 @@ def build_delete_event_hub_consumer_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -449,7 +421,7 @@ def build_delete_event_hub_consumer_group_request( "name": _SERIALIZER.url("name", name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -466,9 +438,7 @@ def build_list_jobs_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -482,7 +452,7 @@ def build_list_jobs_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -499,9 +469,7 @@ def build_get_job_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -516,7 +484,7 @@ def build_get_job_request( "jobId": _SERIALIZER.url("job_id", job_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -533,9 +501,7 @@ def build_get_quota_metrics_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -549,7 +515,7 @@ def build_get_quota_metrics_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -566,9 +532,7 @@ def build_get_endpoint_health_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -582,7 +546,7 @@ def build_get_endpoint_health_request( "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -597,9 +561,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -611,7 +573,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -630,9 +592,7 @@ def build_test_all_routes_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -647,7 +607,7 @@ def build_test_all_routes_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -666,9 +626,7 @@ def build_test_route_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -683,7 +641,7 @@ def build_test_route_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -702,9 +660,7 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -718,7 +674,7 @@ def build_list_keys_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -735,9 +691,7 @@ def build_get_keys_for_key_name_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -752,7 +706,7 @@ def build_get_keys_for_key_name_request( "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -769,9 +723,7 @@ def build_export_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -786,7 +738,7 @@ def build_export_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -805,9 +757,7 @@ def build_import_devices_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -822,7 +772,7 @@ def build_import_devices_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -853,6 +803,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -880,8 +831,8 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -939,8 +890,8 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -948,7 +899,7 @@ def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_description, (IO, bytes)): + if isinstance(iot_hub_description, (IOBase, bytes)): _content = iot_hub_description else: _json = self._serialize.body(iot_hub_description, "IotHubDescription") @@ -1135,8 +1086,8 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -1197,8 +1148,8 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -1206,7 +1157,7 @@ def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_hub_tags, (IO, bytes)): + if isinstance(iot_hub_tags, (IOBase, bytes)): _content = iot_hub_tags else: _json = self._serialize.body(iot_hub_tags, "TagsResource") @@ -1364,8 +1315,8 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) @@ -1431,8 +1382,8 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) @@ -1514,8 +1465,8 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1573,8 +1524,8 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescrip _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) @@ -1661,8 +1612,8 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) @@ -1761,8 +1712,8 @@ def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) @@ -1823,8 +1774,8 @@ def get_valid_skus( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) @@ -1924,8 +1875,8 @@ def list_event_hub_consumer_groups( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) @@ -2033,8 +1984,8 @@ def get_event_hub_consumer_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) @@ -2194,8 +2145,8 @@ def create_event_hub_consumer_group( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) @@ -2203,7 +2154,7 @@ def create_event_hub_consumer_group( content_type = content_type or "application/json" _json = None _content = None - if isinstance(consumer_group_body, (IO, bytes)): + if isinstance(consumer_group_body, (IOBase, bytes)): _content = consumer_group_body else: _json = self._serialize.body(consumer_group_body, "EventHubConsumerGroupBodyDescription") @@ -2281,8 +2232,8 @@ def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-stat _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) @@ -2339,8 +2290,8 @@ def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) @@ -2444,8 +2395,8 @@ def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **k _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) @@ -2507,8 +2458,8 @@ def get_quota_metrics( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) @@ -2603,8 +2554,8 @@ def get_endpoint_health( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) @@ -2748,8 +2699,8 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) @@ -2757,7 +2708,7 @@ def check_name_availability( content_type = content_type or "application/json" _json = None _content = None - if isinstance(operation_inputs, (IO, bytes)): + if isinstance(operation_inputs, (IOBase, bytes)): _content = operation_inputs else: _json = self._serialize.body(operation_inputs, "OperationInputs") @@ -2890,8 +2841,8 @@ def test_all_routes( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) @@ -2899,7 +2850,7 @@ def test_all_routes( content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestAllRoutesInput") @@ -3034,8 +2985,8 @@ def test_route( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) @@ -3043,7 +2994,7 @@ def test_route( content_type = content_type or "application/json" _json = None _content = None - if isinstance(input, (IO, bytes)): + if isinstance(input, (IOBase, bytes)): _content = input else: _json = self._serialize.body(input, "TestRouteInput") @@ -3110,8 +3061,8 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) @@ -3217,8 +3168,8 @@ def get_keys_for_key_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) @@ -3370,8 +3321,8 @@ def export_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) @@ -3379,7 +3330,7 @@ def export_devices( content_type = content_type or "application/json" _json = None _content = None - if isinstance(export_devices_parameters, (IO, bytes)): + if isinstance(export_devices_parameters, (IOBase, bytes)): _content = export_devices_parameters else: _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") @@ -3534,8 +3485,8 @@ def import_devices( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) @@ -3543,7 +3494,7 @@ def import_devices( content_type = content_type or "application/json" _json = None _content = None - if isinstance(import_devices_parameters, (IO, bytes)): + if isinstance(import_devices_parameters, (IOBase, bytes)): _content = import_devices_parameters else: _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_operations.py index e4d6427b261b..b5bd2bc80ad3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,9 +40,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -80,6 +73,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: @@ -93,8 +87,8 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_private_endpoint_connections_operations.py index a983c9dc1d69..3c3bce277fa4 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_private_endpoint_connections_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -28,12 +28,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,9 +43,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +57,7 @@ def build_list_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -84,9 +78,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -103,7 +95,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -124,9 +116,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -144,7 +134,7 @@ def build_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -167,9 +157,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -186,7 +174,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -215,6 +203,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -244,8 +233,8 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) @@ -314,8 +303,8 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) @@ -374,8 +363,8 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) @@ -383,7 +372,7 @@ def _update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_endpoint_connection, (IO, bytes)): + if isinstance(private_endpoint_connection, (IOBase, bytes)): _content = private_endpoint_connection else: _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") @@ -564,8 +553,8 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) @@ -626,8 +615,8 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) @@ -708,8 +697,8 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_private_link_resources_operations.py index e42d4f2a3d8a..6b38e9ff0243 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_private_link_resources_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -26,12 +25,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,9 +40,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +54,7 @@ def build_list_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,9 +71,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -95,7 +86,7 @@ def build_get_request( "groupId": _SERIALIZER.url("group_id", group_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -124,6 +115,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: @@ -151,8 +143,8 @@ def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.PrivateLinkResources] = kwargs.pop("cls", None) @@ -221,8 +213,8 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_resource_provider_common_operations.py index 796b7b45ae0d..a9315139fd16 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2022_11_15_preview/operations/_resource_provider_common_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -26,12 +25,8 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,9 +38,7 @@ def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-15-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -54,7 +47,7 @@ def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,6 +76,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: @@ -106,8 +100,8 @@ def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuota _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-11-15-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2022-11-15-preview") + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-15-preview") ) cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/__init__.py new file mode 100644 index 000000000000..c6c8f9fc0a14 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/__init__.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._iot_hub_client import IotHubClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "IotHubClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/_configuration.py new file mode 100644 index 000000000000..ed35a4aebf91 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/_configuration.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for IotHubClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The subscription identifier. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2023-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-06-30") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/_iot_hub_client.py new file mode 100644 index 000000000000..1a7fb9d228eb --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/_iot_hub_client.py @@ -0,0 +1,128 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import IotHubClientConfiguration +from .operations import ( + CertificatesOperations, + IotHubOperations, + IotHubResourceOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + ResourceProviderCommonOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """Use this API to manage the IoT hubs in your Azure subscription. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.iothub.v2023_06_30.operations.Operations + :ivar iot_hub_resource: IotHubResourceOperations operations + :vartype iot_hub_resource: azure.mgmt.iothub.v2023_06_30.operations.IotHubResourceOperations + :ivar resource_provider_common: ResourceProviderCommonOperations operations + :vartype resource_provider_common: + azure.mgmt.iothub.v2023_06_30.operations.ResourceProviderCommonOperations + :ivar certificates: CertificatesOperations operations + :vartype certificates: azure.mgmt.iothub.v2023_06_30.operations.CertificatesOperations + :ivar iot_hub: IotHubOperations operations + :vartype iot_hub: azure.mgmt.iothub.v2023_06_30.operations.IotHubOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.iothub.v2023_06_30.operations.PrivateLinkResourcesOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.iothub.v2023_06_30.operations.PrivateEndpointConnectionsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The subscription identifier. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2023-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2023-06-30") + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-06-30" + ) + self.resource_provider_common = ResourceProviderCommonOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-06-30" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-06-30" + ) + self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize, "2023-06-30") + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-06-30" + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-06-30" + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> "IotHubClient": + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/_metadata.json new file mode 100644 index 000000000000..b3c6d23b665d --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/_metadata.json @@ -0,0 +1,116 @@ +{ + "chosen_version": "2023-06-30", + "total_api_version_list": ["2023-06-30"], + "client": { + "name": "IotHubClient", + "filename": "_iot_hub_client", + "description": "Use this API to manage the IoT hubs in your Azure subscription.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true, + "method_location": "positional" + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The subscription identifier. Required.", + "docstring_type": "str", + "required": true, + "method_location": "positional" + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The subscription identifier. Required.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version: Optional[str]=None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles=KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "operations": "Operations", + "iot_hub_resource": "IotHubResourceOperations", + "resource_provider_common": "ResourceProviderCommonOperations", + "certificates": "CertificatesOperations", + "iot_hub": "IotHubOperations", + "private_link_resources": "PrivateLinkResourcesOperations", + "private_endpoint_connections": "PrivateEndpointConnectionsOperations" + } +} diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/_vendor.py new file mode 100644 index 000000000000..0dafe0e287ff --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/__init__.py new file mode 100644 index 000000000000..63c7f30f2936 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._iot_hub_client import IotHubClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "IotHubClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/_configuration.py new file mode 100644 index 000000000000..e40cb45ac117 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/_configuration.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for IotHubClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The subscription identifier. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2023-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-06-30") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/_iot_hub_client.py new file mode 100644 index 000000000000..49be55fa0125 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/_iot_hub_client.py @@ -0,0 +1,129 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models as _models +from ..._serialization import Deserializer, Serializer +from ._configuration import IotHubClientConfiguration +from .operations import ( + CertificatesOperations, + IotHubOperations, + IotHubResourceOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + ResourceProviderCommonOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """Use this API to manage the IoT hubs in your Azure subscription. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.iothub.v2023_06_30.aio.operations.Operations + :ivar iot_hub_resource: IotHubResourceOperations operations + :vartype iot_hub_resource: + azure.mgmt.iothub.v2023_06_30.aio.operations.IotHubResourceOperations + :ivar resource_provider_common: ResourceProviderCommonOperations operations + :vartype resource_provider_common: + azure.mgmt.iothub.v2023_06_30.aio.operations.ResourceProviderCommonOperations + :ivar certificates: CertificatesOperations operations + :vartype certificates: azure.mgmt.iothub.v2023_06_30.aio.operations.CertificatesOperations + :ivar iot_hub: IotHubOperations operations + :vartype iot_hub: azure.mgmt.iothub.v2023_06_30.aio.operations.IotHubOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.iothub.v2023_06_30.aio.operations.PrivateLinkResourcesOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.iothub.v2023_06_30.aio.operations.PrivateEndpointConnectionsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The subscription identifier. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2023-06-30". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2023-06-30") + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-06-30" + ) + self.resource_provider_common = ResourceProviderCommonOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-06-30" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-06-30" + ) + self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize, "2023-06-30") + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-06-30" + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-06-30" + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "IotHubClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/__init__.py new file mode 100644 index 000000000000..96fcc782e2e1 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/__init__.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations import Operations +from ._iot_hub_resource_operations import IotHubResourceOperations +from ._resource_provider_common_operations import ResourceProviderCommonOperations +from ._certificates_operations import CertificatesOperations +from ._iot_hub_operations import IotHubOperations +from ._private_link_resources_operations import PrivateLinkResourcesOperations +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "Operations", + "IotHubResourceOperations", + "ResourceProviderCommonOperations", + "CertificatesOperations", + "IotHubOperations", + "PrivateLinkResourcesOperations", + "PrivateEndpointConnectionsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_certificates_operations.py new file mode 100644 index 000000000000..321151ea3cc4 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_certificates_operations.py @@ -0,0 +1,681 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._certificates_operations import ( + build_create_or_update_request, + build_delete_request, + build_generate_verification_code_request, + build_get_request, + build_list_by_iot_hub_request, + build_verify_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30.aio.IotHubClient`'s + :attr:`certificates` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def list_by_iot_hub( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: + """Get the certificate list. + + Returns the list of certificates. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateListDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateListDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) + + request = build_list_by_iot_hub_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateListDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_iot_hub.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: + """Get the certificate. + + Returns the certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: Union[_models.CertificateDescription, IO], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Is either a CertificateDescription type + or a IO type. Required. + :type certificate_description: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription or + IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IOBase, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateDescription") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CertificateDescription", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("CertificateDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}" + } + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> None: + """Delete an X509 certificate. + + Deletes an existing X509 certificate or does nothing if it does not exist. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}" + } + + @distributed_trace_async + async def generate_verification_code( + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: + """Generate verification code for proof of possession flow. + + Generates verification code for proof of possession flow. The verification code will be used to + generate a leaf certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateWithNonceDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateWithNonceDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) + + request = build_generate_verification_code_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + generate_verification_code.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode" + } + + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2023_06_30.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Is either a + CertificateVerificationDescription type or a IO type. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2023_06_30.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IOBase, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") + + request = build_verify_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + verify.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify" + } diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_iot_hub_operations.py new file mode 100644 index 000000000000..9086774b4390 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_iot_hub_operations.py @@ -0,0 +1,289 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._iot_hub_operations import build_manual_failover_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class IotHubOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30.aio.IotHubClient`'s + :attr:`iot_hub` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + async def _manual_failover_initial( # pylint: disable=inconsistent-return-statements + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: Union[_models.FailoverInput, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(failover_input, (IOBase, bytes)): + _content = failover_input + else: + _json = self._serialize.body(failover_input, "FailoverInput") + + request = build_manual_failover_request( + iot_hub_name=iot_hub_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._manual_failover_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _manual_failover_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover" + } + + @overload + async def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: _models.FailoverInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: ~azure.mgmt.iothub.v2023_06_30.models.FailoverInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: Union[_models.FailoverInput, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Is either a FailoverInput type or a IO type. Required. + :type failover_input: ~azure.mgmt.iothub.v2023_06_30.models.FailoverInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._manual_failover_initial( # type: ignore + iot_hub_name=iot_hub_name, + resource_group_name=resource_group_name, + failover_input=failover_input, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_manual_failover.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover" + } diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_iot_hub_resource_operations.py new file mode 100644 index 000000000000..27434b633e8a --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_iot_hub_resource_operations.py @@ -0,0 +1,2759 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._iot_hub_resource_operations import ( + build_check_name_availability_request, + build_create_event_hub_consumer_group_request, + build_create_or_update_request, + build_delete_event_hub_consumer_group_request, + build_delete_request, + build_export_devices_request, + build_get_endpoint_health_request, + build_get_event_hub_consumer_group_request, + build_get_job_request, + build_get_keys_for_key_name_request, + build_get_quota_metrics_request, + build_get_request, + build_get_stats_request, + build_get_valid_skus_request, + build_import_devices_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_list_event_hub_consumer_groups_request, + build_list_jobs_request, + build_list_keys_request, + build_test_all_routes_request, + build_test_route_request, + build_update_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30.aio.IotHubClient`'s + :attr:`iot_hub_resource` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: + """Get the non-security related metadata of an IoT hub. + + Get the non-security related metadata of an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + async def _create_or_update_initial( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: Union[_models.IotHubDescription, IO], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.IotHubDescription: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IOBase, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: _models.IotHubDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: Union[_models.IotHubDescription, IO], + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a + IotHubDescription type or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription or IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + iot_hub_description=iot_hub_description, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("IotHubDescription", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + async def _update_initial( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.IotHubDescription: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_tags, (IOBase, bytes)): + _content = iot_hub_tags + else: + _json = self._serialize.body(iot_hub_tags, "TagsResource") + + request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: _models.TagsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2023_06_30.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Is either a + TagsResource type or a IO type. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2023_06_30.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + iot_hub_tags=iot_hub_tags, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("IotHubDescription", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + async def _delete_initial( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if response.status_code == 404: + deserialized = self._deserialize("ErrorDetails", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Delete an IoT hub. + + Delete an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or An instance of + AsyncLROPoller that returns either ErrorDetails or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription] or + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2023_06_30.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("IotHubDescription", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDescription"]: + """Get all the IoT hubs in a subscription. + + Get all the IoT hubs in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubDescription"]: + """Get all the IoT hubs in a resource group. + + Get all the IoT hubs in a resource group. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs" + } + + @distributed_trace_async + async def get_stats( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.RegistryStatistics: + """Get the statistics from an IoT hub. + + Get the statistics from an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RegistryStatistics or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.RegistryStatistics + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) + + request = build_get_stats_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegistryStatistics", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_stats.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats" + } + + @distributed_trace + def get_valid_skus( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubSkuDescription"]: + """Get the list of valid SKUs for an IoT hub. + + Get the list of valid SKUs for an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IotHubSkuDescription or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2023_06_30.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_get_valid_skus_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + get_valid_skus.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus" + } + + @distributed_trace + def list_event_hub_consumer_groups( + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EventHubConsumerGroupInfo"]: + """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an + IoT hub. + + Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an + IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. + :type event_hub_endpoint_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_event_hub_consumer_groups_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_event_hub_consumer_groups.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups" + } + + @distributed_trace_async + async def get_event_hub_consumer_group( + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. + + Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to retrieve. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) + + request = build_get_event_hub_consumer_group_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_event_hub_consumer_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}" + } + + @overload + async def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: _models.EventHubConsumerGroupBodyDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Required. + :type consumer_group_body: + ~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupBodyDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Required. + :type consumer_group_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: Union[_models.EventHubConsumerGroupBodyDescription, IO], + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Is either a + EventHubConsumerGroupBodyDescription type or a IO type. Required. + :type consumer_group_body: + ~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupBodyDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(consumer_group_body, (IOBase, bytes)): + _content = consumer_group_body + else: + _json = self._serialize.body(consumer_group_body, "EventHubConsumerGroupBodyDescription") + + request = build_create_event_hub_consumer_group_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_event_hub_consumer_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}" + } + + @distributed_trace_async + async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> None: + """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + + Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to delete. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_event_hub_consumer_group_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_event_hub_consumer_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}" + } + + @distributed_trace + def list_jobs( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.JobResponse"]: + """Get a list of all the jobs in an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + + Get a list of all the jobs in an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either JobResponse or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2023_06_30.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_jobs_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("JobResponseListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_jobs.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs" + } + + @distributed_trace_async + async def get_job( + self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any + ) -> _models.JobResponse: + """Get the details of a job from an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + + Get the details of a job from an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param job_id: The job identifier. Required. + :type job_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) + + request = build_get_job_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("JobResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_job.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}" + } + + @distributed_trace + def get_quota_metrics( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubQuotaMetricInfo"]: + """Get the quota metrics for an IoT hub. + + Get the quota metrics for an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2023_06_30.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_get_quota_metrics_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + get_quota_metrics.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics" + } + + @distributed_trace + def get_endpoint_health( + self, resource_group_name: str, iot_hub_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EndpointHealthData"]: + """Get the health for routing endpoints. + + Get the health for routing endpoints. + + :param resource_group_name: Required. + :type resource_group_name: str + :param iot_hub_name: Required. + :type iot_hub_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EndpointHealthData or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2023_06_30.models.EndpointHealthData] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_get_endpoint_health_request( + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_endpoint_health.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("EndpointHealthDataListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + get_endpoint_health.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth" + } + + @overload + async def check_name_availability( + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2023_06_30.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a OperationInputs type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2023_06_30.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IOBase, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability" + } + + @overload + async def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: _models.TestAllRoutesInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: ~azure.mgmt.iothub.v2023_06_30.models.TestAllRoutesInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def test_all_routes( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestAllRoutesInput, IO], **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Is either a TestAllRoutesInput type or a IO type. + Required. + :type input: ~azure.mgmt.iothub.v2023_06_30.models.TestAllRoutesInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IOBase, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestAllRoutesInput") + + request = build_test_all_routes_request( + iot_hub_name=iot_hub_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.test_all_routes.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestAllRoutesResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + test_all_routes.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall" + } + + @overload + async def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: _models.TestRouteInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: ~azure.mgmt.iothub.v2023_06_30.models.TestRouteInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def test_route( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestRouteInput, IO], **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Is either a TestRouteInput type or a IO type. + Required. + :type input: ~azure.mgmt.iothub.v2023_06_30.models.TestRouteInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IOBase, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestRouteInput") + + request = build_test_route_request( + iot_hub_name=iot_hub_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.test_route.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestRouteResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + test_route.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew" + } + + @distributed_trace + def list_keys( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRule"]: + """Get the security metadata for an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + + Get the security metadata for an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2023_06_30.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_keys_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys" + } + + @distributed_trace_async + async def get_keys_for_key_name( + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: + """Get a shared access policy by name from an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + + Get a shared access policy by name from an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param key_name: The name of the shared access policy. Required. + :type key_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.SharedAccessSignatureAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) + + request = build_get_keys_for_key_name_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_keys_for_key_name.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys" + } + + @overload + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: ~azure.mgmt.iothub.v2023_06_30.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a ExportDevicesRequest type or a IO type. Required. + :type export_devices_parameters: ~azure.mgmt.iothub.v2023_06_30.models.ExportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IOBase, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") + + request = build_export_devices_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("JobResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + export_devices.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices" + } + + @overload + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: ~azure.mgmt.iothub.v2023_06_30.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a ImportDevicesRequest type or a IO type. Required. + :type import_devices_parameters: ~azure.mgmt.iothub.v2023_06_30.models.ImportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IOBase, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") + + request = build_import_devices_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("JobResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + import_devices.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices" + } diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_operations.py new file mode 100644 index 000000000000..ce3890a636ff --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_operations.py @@ -0,0 +1,135 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30.aio.IotHubClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: + """Lists all of the available IoT Hub REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2023_06_30.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..7e8669ddb649 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,581 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._private_endpoint_connections_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30.aio.IotHubClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> List[_models.PrivateEndpointConnection]: + """List private endpoint connections. + + List private endpoint connection properties. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of PrivateEndpointConnection or the result of cls(response) + :rtype: list[~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + + request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("[PrivateEndpointConnection]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Get private endpoint connection. + + Get private endpoint connection properties. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + async def _update_initial( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IOBase, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. + :type private_endpoint_connection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. Is + either a PrivateEndpointConnection type or a IO type. Required. + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpointConnection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + private_endpoint_connection=private_endpoint_connection, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + async def _delete_initial( + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Optional[_models.PrivateEndpointConnection]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Delete private endpoint connection. + + Delete private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..a5f67ab5f1b4 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_private_link_resources_operations.py @@ -0,0 +1,185 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._private_link_resources_operations import build_get_request, build_list_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30.aio.IotHubClient`'s + :attr:`private_link_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: + """List private link resources. + + List private link resources for the given IotHub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkResources or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.PrivateLinkResources + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.PrivateLinkResources] = kwargs.pop("cls", None) + + request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResources", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, group_id: str, **kwargs: Any + ) -> _models.GroupIdInformation: + """Get the specified private link resource. + + Get the specified private link resource for the given IotHub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param group_id: The name of the private link resource. Required. + :type group_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GroupIdInformation or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.GroupIdInformation + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + group_id=group_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GroupIdInformation", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}" + } diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_resource_provider_common_operations.py new file mode 100644 index 000000000000..91dec65d1002 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_resource_provider_common_operations.py @@ -0,0 +1,108 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._resource_provider_common_operations import build_get_subscription_quota_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ResourceProviderCommonOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30.aio.IotHubClient`'s + :attr:`resource_provider_common` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: + """Get the number of iot hubs in the subscription. + + Get the number of free and paid iot hubs in the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UserSubscriptionQuotaListResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.UserSubscriptionQuotaListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) + + request = build_get_subscription_quota_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_subscription_quota.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UserSubscriptionQuotaListResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_subscription_quota.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages"} diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/models/__init__.py new file mode 100644 index 000000000000..cfb6d26a7ff8 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/models/__init__.py @@ -0,0 +1,227 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import ArmIdentity +from ._models_py3 import ArmUserIdentity +from ._models_py3 import CertificateBodyDescription +from ._models_py3 import CertificateDescription +from ._models_py3 import CertificateListDescription +from ._models_py3 import CertificateProperties +from ._models_py3 import CertificatePropertiesWithNonce +from ._models_py3 import CertificateVerificationDescription +from ._models_py3 import CertificateWithNonceDescription +from ._models_py3 import CloudToDeviceProperties +from ._models_py3 import EndpointHealthData +from ._models_py3 import EndpointHealthDataListResult +from ._models_py3 import EnrichmentProperties +from ._models_py3 import ErrorDetails +from ._models_py3 import EventHubConsumerGroupBodyDescription +from ._models_py3 import EventHubConsumerGroupInfo +from ._models_py3 import EventHubConsumerGroupName +from ._models_py3 import EventHubConsumerGroupsListResult +from ._models_py3 import EventHubProperties +from ._models_py3 import ExportDevicesRequest +from ._models_py3 import FailoverInput +from ._models_py3 import FallbackRouteProperties +from ._models_py3 import FeedbackProperties +from ._models_py3 import GroupIdInformation +from ._models_py3 import GroupIdInformationProperties +from ._models_py3 import ImportDevicesRequest +from ._models_py3 import IotHubCapacity +from ._models_py3 import IotHubDescription +from ._models_py3 import IotHubDescriptionListResult +from ._models_py3 import IotHubLocationDescription +from ._models_py3 import IotHubNameAvailabilityInfo +from ._models_py3 import IotHubProperties +from ._models_py3 import IotHubQuotaMetricInfo +from ._models_py3 import IotHubQuotaMetricInfoListResult +from ._models_py3 import IotHubSkuDescription +from ._models_py3 import IotHubSkuDescriptionListResult +from ._models_py3 import IotHubSkuInfo +from ._models_py3 import IpFilterRule +from ._models_py3 import JobResponse +from ._models_py3 import JobResponseListResult +from ._models_py3 import ManagedIdentity +from ._models_py3 import MatchedRoute +from ._models_py3 import MessagingEndpointProperties +from ._models_py3 import Name +from ._models_py3 import NetworkRuleSetIpRule +from ._models_py3 import NetworkRuleSetProperties +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationInputs +from ._models_py3 import OperationListResult +from ._models_py3 import PrivateEndpoint +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionProperties +from ._models_py3 import PrivateLinkResources +from ._models_py3 import PrivateLinkServiceConnectionState +from ._models_py3 import RegistryStatistics +from ._models_py3 import Resource +from ._models_py3 import RouteCompilationError +from ._models_py3 import RouteErrorPosition +from ._models_py3 import RouteErrorRange +from ._models_py3 import RouteProperties +from ._models_py3 import RoutingCosmosDBSqlApiProperties +from ._models_py3 import RoutingEndpoints +from ._models_py3 import RoutingEventHubProperties +from ._models_py3 import RoutingMessage +from ._models_py3 import RoutingProperties +from ._models_py3 import RoutingServiceBusQueueEndpointProperties +from ._models_py3 import RoutingServiceBusTopicEndpointProperties +from ._models_py3 import RoutingStorageContainerProperties +from ._models_py3 import RoutingTwin +from ._models_py3 import RoutingTwinProperties +from ._models_py3 import SharedAccessSignatureAuthorizationRule +from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult +from ._models_py3 import StorageEndpointProperties +from ._models_py3 import SystemData +from ._models_py3 import TagsResource +from ._models_py3 import TestAllRoutesInput +from ._models_py3 import TestAllRoutesResult +from ._models_py3 import TestRouteInput +from ._models_py3 import TestRouteResult +from ._models_py3 import TestRouteResultDetails +from ._models_py3 import UserSubscriptionQuota +from ._models_py3 import UserSubscriptionQuotaListResult + +from ._iot_hub_client_enums import AccessRights +from ._iot_hub_client_enums import AuthenticationType +from ._iot_hub_client_enums import Capabilities +from ._iot_hub_client_enums import CreatedByType +from ._iot_hub_client_enums import DefaultAction +from ._iot_hub_client_enums import EndpointHealthStatus +from ._iot_hub_client_enums import IotHubNameUnavailabilityReason +from ._iot_hub_client_enums import IotHubReplicaRoleType +from ._iot_hub_client_enums import IotHubScaleType +from ._iot_hub_client_enums import IotHubSku +from ._iot_hub_client_enums import IotHubSkuTier +from ._iot_hub_client_enums import IpFilterActionType +from ._iot_hub_client_enums import JobStatus +from ._iot_hub_client_enums import JobType +from ._iot_hub_client_enums import NetworkRuleIPAction +from ._iot_hub_client_enums import PrivateLinkServiceConnectionStatus +from ._iot_hub_client_enums import PublicNetworkAccess +from ._iot_hub_client_enums import ResourceIdentityType +from ._iot_hub_client_enums import RouteErrorSeverity +from ._iot_hub_client_enums import RoutingSource +from ._iot_hub_client_enums import RoutingStorageContainerPropertiesEncoding +from ._iot_hub_client_enums import TestResultStatus +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ArmIdentity", + "ArmUserIdentity", + "CertificateBodyDescription", + "CertificateDescription", + "CertificateListDescription", + "CertificateProperties", + "CertificatePropertiesWithNonce", + "CertificateVerificationDescription", + "CertificateWithNonceDescription", + "CloudToDeviceProperties", + "EndpointHealthData", + "EndpointHealthDataListResult", + "EnrichmentProperties", + "ErrorDetails", + "EventHubConsumerGroupBodyDescription", + "EventHubConsumerGroupInfo", + "EventHubConsumerGroupName", + "EventHubConsumerGroupsListResult", + "EventHubProperties", + "ExportDevicesRequest", + "FailoverInput", + "FallbackRouteProperties", + "FeedbackProperties", + "GroupIdInformation", + "GroupIdInformationProperties", + "ImportDevicesRequest", + "IotHubCapacity", + "IotHubDescription", + "IotHubDescriptionListResult", + "IotHubLocationDescription", + "IotHubNameAvailabilityInfo", + "IotHubProperties", + "IotHubQuotaMetricInfo", + "IotHubQuotaMetricInfoListResult", + "IotHubSkuDescription", + "IotHubSkuDescriptionListResult", + "IotHubSkuInfo", + "IpFilterRule", + "JobResponse", + "JobResponseListResult", + "ManagedIdentity", + "MatchedRoute", + "MessagingEndpointProperties", + "Name", + "NetworkRuleSetIpRule", + "NetworkRuleSetProperties", + "Operation", + "OperationDisplay", + "OperationInputs", + "OperationListResult", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionProperties", + "PrivateLinkResources", + "PrivateLinkServiceConnectionState", + "RegistryStatistics", + "Resource", + "RouteCompilationError", + "RouteErrorPosition", + "RouteErrorRange", + "RouteProperties", + "RoutingCosmosDBSqlApiProperties", + "RoutingEndpoints", + "RoutingEventHubProperties", + "RoutingMessage", + "RoutingProperties", + "RoutingServiceBusQueueEndpointProperties", + "RoutingServiceBusTopicEndpointProperties", + "RoutingStorageContainerProperties", + "RoutingTwin", + "RoutingTwinProperties", + "SharedAccessSignatureAuthorizationRule", + "SharedAccessSignatureAuthorizationRuleListResult", + "StorageEndpointProperties", + "SystemData", + "TagsResource", + "TestAllRoutesInput", + "TestAllRoutesResult", + "TestRouteInput", + "TestRouteResult", + "TestRouteResultDetails", + "UserSubscriptionQuota", + "UserSubscriptionQuotaListResult", + "AccessRights", + "AuthenticationType", + "Capabilities", + "CreatedByType", + "DefaultAction", + "EndpointHealthStatus", + "IotHubNameUnavailabilityReason", + "IotHubReplicaRoleType", + "IotHubScaleType", + "IotHubSku", + "IotHubSkuTier", + "IpFilterActionType", + "JobStatus", + "JobType", + "NetworkRuleIPAction", + "PrivateLinkServiceConnectionStatus", + "PublicNetworkAccess", + "ResourceIdentityType", + "RouteErrorSeverity", + "RoutingSource", + "RoutingStorageContainerPropertiesEncoding", + "TestResultStatus", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/models/_iot_hub_client_enums.py new file mode 100644 index 000000000000..2d31d1e7ac49 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/models/_iot_hub_client_enums.py @@ -0,0 +1,230 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The permissions assigned to the shared access policy.""" + + REGISTRY_READ = "RegistryRead" + REGISTRY_WRITE = "RegistryWrite" + SERVICE_CONNECT = "ServiceConnect" + DEVICE_CONNECT = "DeviceConnect" + REGISTRY_READ_REGISTRY_WRITE = "RegistryRead, RegistryWrite" + REGISTRY_READ_SERVICE_CONNECT = "RegistryRead, ServiceConnect" + REGISTRY_READ_DEVICE_CONNECT = "RegistryRead, DeviceConnect" + REGISTRY_WRITE_SERVICE_CONNECT = "RegistryWrite, ServiceConnect" + REGISTRY_WRITE_DEVICE_CONNECT = "RegistryWrite, DeviceConnect" + SERVICE_CONNECT_DEVICE_CONNECT = "ServiceConnect, DeviceConnect" + REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect" + REGISTRY_READ_REGISTRY_WRITE_DEVICE_CONNECT = "RegistryRead, RegistryWrite, DeviceConnect" + REGISTRY_READ_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, ServiceConnect, DeviceConnect" + REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" + REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = ( + "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + ) + + +class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies authentication type being used for connecting to the storage account.""" + + KEY_BASED = "keyBased" + IDENTITY_BASED = "identityBased" + + +class Capabilities(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The capabilities and features enabled for the IoT hub.""" + + NONE = "None" + DEVICE_MANAGEMENT = "DeviceManagement" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Default Action for Network Rule Set.""" + + DENY = "Deny" + ALLOW = "Allow" + + +class EndpointHealthStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Health statuses have following meanings. The 'healthy' status shows that the endpoint is + accepting messages as expected. The 'unhealthy' status shows that the endpoint is not accepting + messages as expected and IoT Hub is retrying to send data to this endpoint. The status of an + unhealthy endpoint will be updated to healthy when IoT Hub has established an eventually + consistent state of health. The 'dead' status shows that the endpoint is not accepting + messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub metrics to + identify errors and monitor issues with endpoints. The 'unknown' status shows that the IoT Hub + has not established a connection with the endpoint. No messages have been delivered to or + rejected from this endpoint. + """ + + UNKNOWN = "unknown" + HEALTHY = "healthy" + DEGRADED = "degraded" + UNHEALTHY = "unhealthy" + DEAD = "dead" + + +class IotHubNameUnavailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The reason for unavailability.""" + + INVALID = "Invalid" + ALREADY_EXISTS = "AlreadyExists" + + +class IotHubReplicaRoleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The role of the region, can be either primary or secondary. The primary region is where the IoT + hub is currently provisioned. The secondary region is the Azure disaster recovery (DR) paired + region and also the region where the IoT hub can failover to. + """ + + PRIMARY = "primary" + SECONDARY = "secondary" + + +class IotHubScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the scaling enabled.""" + + AUTOMATIC = "Automatic" + MANUAL = "Manual" + NONE = "None" + + +class IotHubSku(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The name of the SKU.""" + + F1 = "F1" + S1 = "S1" + S2 = "S2" + S3 = "S3" + B1 = "B1" + B2 = "B2" + B3 = "B3" + + +class IotHubSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The billing tier for the IoT hub.""" + + FREE = "Free" + STANDARD = "Standard" + BASIC = "Basic" + + +class IpFilterActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The desired action for requests captured by this rule.""" + + ACCEPT = "Accept" + REJECT = "Reject" + + +class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the job.""" + + UNKNOWN = "unknown" + ENQUEUED = "enqueued" + RUNNING = "running" + COMPLETED = "completed" + FAILED = "failed" + CANCELLED = "cancelled" + + +class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the job.""" + + UNKNOWN = "unknown" + EXPORT = "export" + IMPORT = "import" + BACKUP = "backup" + READ_DEVICE_PROPERTIES = "readDeviceProperties" + WRITE_DEVICE_PROPERTIES = "writeDeviceProperties" + UPDATE_DEVICE_CONFIGURATION = "updateDeviceConfiguration" + REBOOT_DEVICE = "rebootDevice" + FACTORY_RESET_DEVICE = "factoryResetDevice" + FIRMWARE_UPDATE = "firmwareUpdate" + IMPORT_ENUM = "import" + + +class NetworkRuleIPAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """IP Filter Action.""" + + ALLOW = "Allow" + + +class PrivateLinkServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of a private endpoint connection.""" + + PENDING = "Pending" + APPROVED = "Approved" + REJECTED = "Rejected" + DISCONNECTED = "Disconnected" + + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether requests from Public Network are allowed.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity used for the resource. The type 'SystemAssigned, UserAssigned' includes + both an implicitly created identity and a set of user assigned identities. The type 'None' will + remove any identities from the service. + """ + + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + NONE = "None" + + +class RouteErrorSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Severity of the route error.""" + + ERROR = "error" + WARNING = "warning" + + +class RoutingSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The source that the routing rule is to be applied to, such as DeviceMessages.""" + + INVALID = "Invalid" + DEVICE_MESSAGES = "DeviceMessages" + TWIN_CHANGE_EVENTS = "TwinChangeEvents" + DEVICE_LIFECYCLE_EVENTS = "DeviceLifecycleEvents" + DEVICE_JOB_LIFECYCLE_EVENTS = "DeviceJobLifecycleEvents" + DEVICE_CONNECTION_STATE_EVENTS = "DeviceConnectionStateEvents" + + +class RoutingStorageContainerPropertiesEncoding(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Encoding that is used to serialize messages to blobs. Supported values are 'avro', + 'avrodeflate', and 'JSON'. Default value is 'avro'. + """ + + AVRO = "Avro" + AVRO_DEFLATE = "AvroDeflate" + JSON = "JSON" + + +class TestResultStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Result of testing route.""" + + UNDEFINED = "undefined" + FALSE = "false" + TRUE = "true" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/models/_models_py3.py new file mode 100644 index 000000000000..767e66657496 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/models/_models_py3.py @@ -0,0 +1,4079 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import datetime +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union + +from ... import _serialization + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object + + +class ArmIdentity(_serialization.Model): + """ArmIdentity. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: Principal Id. + :vartype principal_id: str + :ivar tenant_id: Tenant Id. + :vartype tenant_id: str + :ivar type: The type of identity used for the resource. The type 'SystemAssigned, UserAssigned' + includes both an implicitly created identity and a set of user assigned identities. The type + 'None' will remove any identities from the service. Known values are: "SystemAssigned", + "UserAssigned", "SystemAssigned, UserAssigned", and "None". + :vartype type: str or ~azure.mgmt.iothub.v2023_06_30.models.ResourceIdentityType + :ivar user_assigned_identities: Dictionary of :code:``. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.iothub.v2023_06_30.models.ArmUserIdentity] + """ + + _validation = { + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{ArmUserIdentity}"}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.ArmUserIdentity"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword type: The type of identity used for the resource. The type 'SystemAssigned, + UserAssigned' includes both an implicitly created identity and a set of user assigned + identities. The type 'None' will remove any identities from the service. Known values are: + "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and "None". + :paramtype type: str or ~azure.mgmt.iothub.v2023_06_30.models.ResourceIdentityType + :keyword user_assigned_identities: Dictionary of :code:``. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.iothub.v2023_06_30.models.ArmUserIdentity] + """ + super().__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + self.user_assigned_identities = user_assigned_identities + + +class ArmUserIdentity(_serialization.Model): + """ArmUserIdentity. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: + :vartype principal_id: str + :ivar client_id: + :vartype client_id: str + """ + + _validation = { + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.principal_id = None + self.client_id = None + + +class CertificateBodyDescription(_serialization.Model): + """The JSON-serialized X509 Certificate. + + :ivar certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem + file content. + :vartype certificate: str + :ivar is_verified: True indicates that the certificate will be created in verified state and + proof of possession will not be required. + :vartype is_verified: bool + """ + + _attribute_map = { + "certificate": {"key": "certificate", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + } + + def __init__(self, *, certificate: Optional[str] = None, is_verified: Optional[bool] = None, **kwargs: Any) -> None: + """ + :keyword certificate: base-64 representation of the X509 leaf certificate .cer file or just + .pem file content. + :paramtype certificate: str + :keyword is_verified: True indicates that the certificate will be created in verified state and + proof of possession will not be required. + :paramtype is_verified: bool + """ + super().__init__(**kwargs) + self.certificate = certificate + self.is_verified = is_verified + + +class CertificateDescription(_serialization.Model): + """The X509 Certificate. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar properties: The description of an X509 CA Certificate. + :vartype properties: ~azure.mgmt.iothub.v2023_06_30.models.CertificateProperties + :ivar id: The resource identifier. + :vartype id: str + :ivar name: The name of the certificate. + :vartype name: str + :ivar etag: The entity tag. + :vartype etag: str + :ivar type: The resource type. + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "properties": {"key": "properties", "type": "CertificateProperties"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, properties: Optional["_models.CertificateProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: The description of an X509 CA Certificate. + :paramtype properties: ~azure.mgmt.iothub.v2023_06_30.models.CertificateProperties + """ + super().__init__(**kwargs) + self.properties = properties + self.id = None + self.name = None + self.etag = None + self.type = None + + +class CertificateListDescription(_serialization.Model): + """The JSON-serialized array of Certificate objects. + + :ivar value: The array of Certificate objects. + :vartype value: list[~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[CertificateDescription]"}, + } + + def __init__(self, *, value: Optional[List["_models.CertificateDescription"]] = None, **kwargs: Any) -> None: + """ + :keyword value: The array of Certificate objects. + :paramtype value: list[~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription] + """ + super().__init__(**kwargs) + self.value = value + + +class CertificateProperties(_serialization.Model): + """The description of an X509 CA Certificate. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar subject: The certificate's subject name. + :vartype subject: str + :ivar expiry: The certificate's expiration date and time. + :vartype expiry: ~datetime.datetime + :ivar thumbprint: The certificate's thumbprint. + :vartype thumbprint: str + :ivar is_verified: Determines whether certificate has been verified. + :vartype is_verified: bool + :ivar created: The certificate's create date and time. + :vartype created: ~datetime.datetime + :ivar updated: The certificate's last update date and time. + :vartype updated: ~datetime.datetime + :ivar certificate: The certificate content. + :vartype certificate: str + """ + + _validation = { + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, + } + + _attribute_map = { + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, + "certificate": {"key": "certificate", "type": "str"}, + } + + def __init__(self, *, is_verified: Optional[bool] = None, certificate: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword is_verified: Determines whether certificate has been verified. + :paramtype is_verified: bool + :keyword certificate: The certificate content. + :paramtype certificate: str + """ + super().__init__(**kwargs) + self.subject = None + self.expiry = None + self.thumbprint = None + self.is_verified = is_verified + self.created = None + self.updated = None + self.certificate = certificate + + +class CertificatePropertiesWithNonce(_serialization.Model): + """The description of an X509 CA Certificate including the challenge nonce issued for the + Proof-Of-Possession flow. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar subject: The certificate's subject name. + :vartype subject: str + :ivar expiry: The certificate's expiration date and time. + :vartype expiry: ~datetime.datetime + :ivar thumbprint: The certificate's thumbprint. + :vartype thumbprint: str + :ivar is_verified: Determines whether certificate has been verified. + :vartype is_verified: bool + :ivar created: The certificate's create date and time. + :vartype created: ~datetime.datetime + :ivar updated: The certificate's last update date and time. + :vartype updated: ~datetime.datetime + :ivar verification_code: The certificate's verification code that will be used for proof of + possession. + :vartype verification_code: str + :ivar certificate: The certificate content. + :vartype certificate: str + """ + + _validation = { + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "is_verified": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, + "verification_code": {"readonly": True}, + "certificate": {"readonly": True}, + } + + _attribute_map = { + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, + "verification_code": {"key": "verificationCode", "type": "str"}, + "certificate": {"key": "certificate", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.subject = None + self.expiry = None + self.thumbprint = None + self.is_verified = None + self.created = None + self.updated = None + self.verification_code = None + self.certificate = None + + +class CertificateVerificationDescription(_serialization.Model): + """The JSON-serialized leaf certificate. + + :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file + content. + :vartype certificate: str + """ + + _attribute_map = { + "certificate": {"key": "certificate", "type": "str"}, + } + + def __init__(self, *, certificate: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file + content. + :paramtype certificate: str + """ + super().__init__(**kwargs) + self.certificate = certificate + + +class CertificateWithNonceDescription(_serialization.Model): + """The X509 Certificate. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar properties: The description of an X509 CA Certificate including the challenge nonce + issued for the Proof-Of-Possession flow. + :vartype properties: ~azure.mgmt.iothub.v2023_06_30.models.CertificatePropertiesWithNonce + :ivar id: The resource identifier. + :vartype id: str + :ivar name: The name of the certificate. + :vartype name: str + :ivar etag: The entity tag. + :vartype etag: str + :ivar type: The resource type. + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "properties": {"key": "properties", "type": "CertificatePropertiesWithNonce"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, properties: Optional["_models.CertificatePropertiesWithNonce"] = None, **kwargs: Any) -> None: + """ + :keyword properties: The description of an X509 CA Certificate including the challenge nonce + issued for the Proof-Of-Possession flow. + :paramtype properties: ~azure.mgmt.iothub.v2023_06_30.models.CertificatePropertiesWithNonce + """ + super().__init__(**kwargs) + self.properties = properties + self.id = None + self.name = None + self.etag = None + self.type = None + + +class CloudToDeviceProperties(_serialization.Model): + """The IoT hub cloud-to-device messaging properties. + + :ivar max_delivery_count: The max delivery count for cloud-to-device messages in the device + queue. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :vartype max_delivery_count: int + :ivar default_ttl_as_iso8601: The default time to live for cloud-to-device messages in the + device queue. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :vartype default_ttl_as_iso8601: ~datetime.timedelta + :ivar feedback: The properties of the feedback queue for cloud-to-device messages. + :vartype feedback: ~azure.mgmt.iothub.v2023_06_30.models.FeedbackProperties + """ + + _validation = { + "max_delivery_count": {"maximum": 100, "minimum": 1}, + } + + _attribute_map = { + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, + "default_ttl_as_iso8601": {"key": "defaultTtlAsIso8601", "type": "duration"}, + "feedback": {"key": "feedback", "type": "FeedbackProperties"}, + } + + def __init__( + self, + *, + max_delivery_count: Optional[int] = None, + default_ttl_as_iso8601: Optional[datetime.timedelta] = None, + feedback: Optional["_models.FeedbackProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword max_delivery_count: The max delivery count for cloud-to-device messages in the device + queue. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :paramtype max_delivery_count: int + :keyword default_ttl_as_iso8601: The default time to live for cloud-to-device messages in the + device queue. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :paramtype default_ttl_as_iso8601: ~datetime.timedelta + :keyword feedback: The properties of the feedback queue for cloud-to-device messages. + :paramtype feedback: ~azure.mgmt.iothub.v2023_06_30.models.FeedbackProperties + """ + super().__init__(**kwargs) + self.max_delivery_count = max_delivery_count + self.default_ttl_as_iso8601 = default_ttl_as_iso8601 + self.feedback = feedback + + +class EndpointHealthData(_serialization.Model): + """The health data for an endpoint. + + :ivar endpoint_id: Id of the endpoint. + :vartype endpoint_id: str + :ivar health_status: Health statuses have following meanings. The 'healthy' status shows that + the endpoint is accepting messages as expected. The 'unhealthy' status shows that the endpoint + is not accepting messages as expected and IoT Hub is retrying to send data to this endpoint. + The status of an unhealthy endpoint will be updated to healthy when IoT Hub has established an + eventually consistent state of health. The 'dead' status shows that the endpoint is not + accepting messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub + metrics to identify errors and monitor issues with endpoints. The 'unknown' status shows that + the IoT Hub has not established a connection with the endpoint. No messages have been delivered + to or rejected from this endpoint. Known values are: "unknown", "healthy", "degraded", + "unhealthy", and "dead". + :vartype health_status: str or ~azure.mgmt.iothub.v2023_06_30.models.EndpointHealthStatus + :ivar last_known_error: Last error obtained when a message failed to be delivered to iot hub. + :vartype last_known_error: str + :ivar last_known_error_time: Time at which the last known error occurred. + :vartype last_known_error_time: ~datetime.datetime + :ivar last_successful_send_attempt_time: Last time iot hub successfully sent a message to the + endpoint. + :vartype last_successful_send_attempt_time: ~datetime.datetime + :ivar last_send_attempt_time: Last time iot hub tried to send a message to the endpoint. + :vartype last_send_attempt_time: ~datetime.datetime + """ + + _attribute_map = { + "endpoint_id": {"key": "endpointId", "type": "str"}, + "health_status": {"key": "healthStatus", "type": "str"}, + "last_known_error": {"key": "lastKnownError", "type": "str"}, + "last_known_error_time": {"key": "lastKnownErrorTime", "type": "rfc-1123"}, + "last_successful_send_attempt_time": {"key": "lastSuccessfulSendAttemptTime", "type": "rfc-1123"}, + "last_send_attempt_time": {"key": "lastSendAttemptTime", "type": "rfc-1123"}, + } + + def __init__( + self, + *, + endpoint_id: Optional[str] = None, + health_status: Optional[Union[str, "_models.EndpointHealthStatus"]] = None, + last_known_error: Optional[str] = None, + last_known_error_time: Optional[datetime.datetime] = None, + last_successful_send_attempt_time: Optional[datetime.datetime] = None, + last_send_attempt_time: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword endpoint_id: Id of the endpoint. + :paramtype endpoint_id: str + :keyword health_status: Health statuses have following meanings. The 'healthy' status shows + that the endpoint is accepting messages as expected. The 'unhealthy' status shows that the + endpoint is not accepting messages as expected and IoT Hub is retrying to send data to this + endpoint. The status of an unhealthy endpoint will be updated to healthy when IoT Hub has + established an eventually consistent state of health. The 'dead' status shows that the endpoint + is not accepting messages, after IoT Hub retried sending messages for the retrial period. See + IoT Hub metrics to identify errors and monitor issues with endpoints. The 'unknown' status + shows that the IoT Hub has not established a connection with the endpoint. No messages have + been delivered to or rejected from this endpoint. Known values are: "unknown", "healthy", + "degraded", "unhealthy", and "dead". + :paramtype health_status: str or ~azure.mgmt.iothub.v2023_06_30.models.EndpointHealthStatus + :keyword last_known_error: Last error obtained when a message failed to be delivered to iot + hub. + :paramtype last_known_error: str + :keyword last_known_error_time: Time at which the last known error occurred. + :paramtype last_known_error_time: ~datetime.datetime + :keyword last_successful_send_attempt_time: Last time iot hub successfully sent a message to + the endpoint. + :paramtype last_successful_send_attempt_time: ~datetime.datetime + :keyword last_send_attempt_time: Last time iot hub tried to send a message to the endpoint. + :paramtype last_send_attempt_time: ~datetime.datetime + """ + super().__init__(**kwargs) + self.endpoint_id = endpoint_id + self.health_status = health_status + self.last_known_error = last_known_error + self.last_known_error_time = last_known_error_time + self.last_successful_send_attempt_time = last_successful_send_attempt_time + self.last_send_attempt_time = last_send_attempt_time + + +class EndpointHealthDataListResult(_serialization.Model): + """The JSON-serialized array of EndpointHealthData objects with a next link. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: JSON-serialized array of Endpoint health data. + :vartype value: list[~azure.mgmt.iothub.v2023_06_30.models.EndpointHealthData] + :ivar next_link: Link to more results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[EndpointHealthData]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.EndpointHealthData"]] = None, **kwargs: Any) -> None: + """ + :keyword value: JSON-serialized array of Endpoint health data. + :paramtype value: list[~azure.mgmt.iothub.v2023_06_30.models.EndpointHealthData] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class EnrichmentProperties(_serialization.Model): + """The properties of an enrichment that your IoT hub applies to messages delivered to endpoints. + + All required parameters must be populated in order to send to Azure. + + :ivar key: The key or name for the enrichment property. Required. + :vartype key: str + :ivar value: The value for the enrichment property. Required. + :vartype value: str + :ivar endpoint_names: The list of endpoints for which the enrichment is applied to the message. + Required. + :vartype endpoint_names: list[str] + """ + + _validation = { + "key": {"required": True}, + "value": {"required": True}, + "endpoint_names": {"required": True, "min_items": 1}, + } + + _attribute_map = { + "key": {"key": "key", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + } + + def __init__(self, *, key: str, value: str, endpoint_names: List[str], **kwargs: Any) -> None: + """ + :keyword key: The key or name for the enrichment property. Required. + :paramtype key: str + :keyword value: The value for the enrichment property. Required. + :paramtype value: str + :keyword endpoint_names: The list of endpoints for which the enrichment is applied to the + message. Required. + :paramtype endpoint_names: list[str] + """ + super().__init__(**kwargs) + self.key = key + self.value = value + self.endpoint_names = endpoint_names + + +class ErrorDetails(_serialization.Model): + """Error details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar http_status_code: The HTTP status code. + :vartype http_status_code: str + :ivar message: The error message. + :vartype message: str + :ivar details: The error details. + :vartype details: str + """ + + _validation = { + "code": {"readonly": True}, + "http_status_code": {"readonly": True}, + "message": {"readonly": True}, + "details": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "http_status_code": {"key": "httpStatusCode", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.http_status_code = None + self.message = None + self.details = None + + +class EventHubConsumerGroupBodyDescription(_serialization.Model): + """The EventHub consumer group. + + All required parameters must be populated in order to send to Azure. + + :ivar properties: The EventHub consumer group name. Required. + :vartype properties: ~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupName + """ + + _validation = { + "properties": {"required": True}, + } + + _attribute_map = { + "properties": {"key": "properties", "type": "EventHubConsumerGroupName"}, + } + + def __init__(self, *, properties: "_models.EventHubConsumerGroupName", **kwargs: Any) -> None: + """ + :keyword properties: The EventHub consumer group name. Required. + :paramtype properties: ~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupName + """ + super().__init__(**kwargs) + self.properties = properties + + +class EventHubConsumerGroupInfo(_serialization.Model): + """The properties of the EventHubConsumerGroupInfo object. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar properties: The tags. + :vartype properties: dict[str, any] + :ivar id: The Event Hub-compatible consumer group identifier. + :vartype id: str + :ivar name: The Event Hub-compatible consumer group name. + :vartype name: str + :ivar type: the resource type. + :vartype type: str + :ivar etag: The etag. + :vartype etag: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + } + + _attribute_map = { + "properties": {"key": "properties", "type": "{object}"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + } + + def __init__(self, *, properties: Optional[Dict[str, Any]] = None, **kwargs: Any) -> None: + """ + :keyword properties: The tags. + :paramtype properties: dict[str, any] + """ + super().__init__(**kwargs) + self.properties = properties + self.id = None + self.name = None + self.type = None + self.etag = None + + +class EventHubConsumerGroupName(_serialization.Model): + """The EventHub consumer group name. + + All required parameters must be populated in order to send to Azure. + + :ivar name: EventHub consumer group name. Required. + :vartype name: str + """ + + _validation = { + "name": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + } + + def __init__(self, *, name: str, **kwargs: Any) -> None: + """ + :keyword name: EventHub consumer group name. Required. + :paramtype name: str + """ + super().__init__(**kwargs) + self.name = name + + +class EventHubConsumerGroupsListResult(_serialization.Model): + """The JSON-serialized array of Event Hub-compatible consumer group names with a next link. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of consumer groups objects. + :vartype value: list[~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupInfo] + :ivar next_link: The next link. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[EventHubConsumerGroupInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.EventHubConsumerGroupInfo"]] = None, **kwargs: Any) -> None: + """ + :keyword value: List of consumer groups objects. + :paramtype value: list[~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupInfo] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class EventHubProperties(_serialization.Model): + """The properties of the provisioned Event Hub-compatible endpoint used by the IoT hub. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar retention_time_in_days: The retention time for device-to-cloud messages in days. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. + :vartype retention_time_in_days: int + :ivar partition_count: The number of partitions for receiving device-to-cloud messages in the + Event Hub-compatible endpoint. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. + :vartype partition_count: int + :ivar partition_ids: The partition ids in the Event Hub-compatible endpoint. + :vartype partition_ids: list[str] + :ivar path: The Event Hub-compatible name. + :vartype path: str + :ivar endpoint: The Event Hub-compatible endpoint. + :vartype endpoint: str + """ + + _validation = { + "partition_ids": {"readonly": True}, + "path": {"readonly": True}, + "endpoint": {"readonly": True}, + } + + _attribute_map = { + "retention_time_in_days": {"key": "retentionTimeInDays", "type": "int"}, + "partition_count": {"key": "partitionCount", "type": "int"}, + "partition_ids": {"key": "partitionIds", "type": "[str]"}, + "path": {"key": "path", "type": "str"}, + "endpoint": {"key": "endpoint", "type": "str"}, + } + + def __init__( + self, *, retention_time_in_days: Optional[int] = None, partition_count: Optional[int] = None, **kwargs: Any + ) -> None: + """ + :keyword retention_time_in_days: The retention time for device-to-cloud messages in days. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. + :paramtype retention_time_in_days: int + :keyword partition_count: The number of partitions for receiving device-to-cloud messages in + the Event Hub-compatible endpoint. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. + :paramtype partition_count: int + """ + super().__init__(**kwargs) + self.retention_time_in_days = retention_time_in_days + self.partition_count = partition_count + self.partition_ids = None + self.path = None + self.endpoint = None + + +class ExportDevicesRequest(_serialization.Model): + """Use to provide parameters when requesting an export of all devices in the IoT hub. + + All required parameters must be populated in order to send to Azure. + + :ivar export_blob_container_uri: The export blob container URI. Required. + :vartype export_blob_container_uri: str + :ivar exclude_keys: The value indicating whether keys should be excluded during export. + Required. + :vartype exclude_keys: bool + :ivar export_blob_name: The name of the blob that will be created in the provided output blob + container. This blob will contain the exported device registry information for the IoT Hub. + :vartype export_blob_name: str + :ivar authentication_type: Specifies authentication type being used for connecting to the + storage account. Known values are: "keyBased" and "identityBased". + :vartype authentication_type: str or ~azure.mgmt.iothub.v2023_06_30.models.AuthenticationType + :ivar identity: Managed identity properties of storage endpoint for export devices. + :vartype identity: ~azure.mgmt.iothub.v2023_06_30.models.ManagedIdentity + :ivar include_configurations: The value indicating whether configurations should be exported. + :vartype include_configurations: bool + :ivar configurations_blob_name: The name of the blob that will be created in the provided + output blob container. This blob will contain the exported configurations for the Iot Hub. + :vartype configurations_blob_name: str + """ + + _validation = { + "export_blob_container_uri": {"required": True}, + "exclude_keys": {"required": True}, + } + + _attribute_map = { + "export_blob_container_uri": {"key": "exportBlobContainerUri", "type": "str"}, + "exclude_keys": {"key": "excludeKeys", "type": "bool"}, + "export_blob_name": {"key": "exportBlobName", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "include_configurations": {"key": "includeConfigurations", "type": "bool"}, + "configurations_blob_name": {"key": "configurationsBlobName", "type": "str"}, + } + + def __init__( + self, + *, + export_blob_container_uri: str, + exclude_keys: bool, + export_blob_name: Optional[str] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, + include_configurations: Optional[bool] = None, + configurations_blob_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword export_blob_container_uri: The export blob container URI. Required. + :paramtype export_blob_container_uri: str + :keyword exclude_keys: The value indicating whether keys should be excluded during export. + Required. + :paramtype exclude_keys: bool + :keyword export_blob_name: The name of the blob that will be created in the provided output + blob container. This blob will contain the exported device registry information for the IoT + Hub. + :paramtype export_blob_name: str + :keyword authentication_type: Specifies authentication type being used for connecting to the + storage account. Known values are: "keyBased" and "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2023_06_30.models.AuthenticationType + :keyword identity: Managed identity properties of storage endpoint for export devices. + :paramtype identity: ~azure.mgmt.iothub.v2023_06_30.models.ManagedIdentity + :keyword include_configurations: The value indicating whether configurations should be + exported. + :paramtype include_configurations: bool + :keyword configurations_blob_name: The name of the blob that will be created in the provided + output blob container. This blob will contain the exported configurations for the Iot Hub. + :paramtype configurations_blob_name: str + """ + super().__init__(**kwargs) + self.export_blob_container_uri = export_blob_container_uri + self.exclude_keys = exclude_keys + self.export_blob_name = export_blob_name + self.authentication_type = authentication_type + self.identity = identity + self.include_configurations = include_configurations + self.configurations_blob_name = configurations_blob_name + + +class FailoverInput(_serialization.Model): + """Use to provide failover region when requesting manual Failover for a hub. + + All required parameters must be populated in order to send to Azure. + + :ivar failover_region: Region the hub will be failed over to. Required. + :vartype failover_region: str + """ + + _validation = { + "failover_region": {"required": True}, + } + + _attribute_map = { + "failover_region": {"key": "failoverRegion", "type": "str"}, + } + + def __init__(self, *, failover_region: str, **kwargs: Any) -> None: + """ + :keyword failover_region: Region the hub will be failed over to. Required. + :paramtype failover_region: str + """ + super().__init__(**kwargs) + self.failover_region = failover_region + + +class FallbackRouteProperties(_serialization.Model): + """The properties of the fallback route. IoT Hub uses these properties when it routes messages to + the fallback endpoint. + + All required parameters must be populated in order to send to Azure. + + :ivar name: The name of the route. The name can only include alphanumeric characters, periods, + underscores, hyphens, has a maximum length of 64 characters, and must be unique. + :vartype name: str + :ivar source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DeviceConnectionStateEvents". + :vartype source: str or ~azure.mgmt.iothub.v2023_06_30.models.RoutingSource + :ivar condition: The condition which is evaluated in order to apply the fallback route. If the + condition is not provided it will evaluate to true by default. For grammar, See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. + :vartype condition: str + :ivar endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. + :vartype endpoint_names: list[str] + :ivar is_enabled: Used to specify whether the fallback route is enabled. Required. + :vartype is_enabled: bool + """ + + _validation = { + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + } + + def __init__( + self, + *, + source: Union[str, "_models.RoutingSource"], + endpoint_names: List[str], + is_enabled: bool, + name: Optional[str] = None, + condition: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the route. The name can only include alphanumeric characters, + periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + :paramtype name: str + :keyword source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DeviceConnectionStateEvents". + :paramtype source: str or ~azure.mgmt.iothub.v2023_06_30.models.RoutingSource + :keyword condition: The condition which is evaluated in order to apply the fallback route. If + the condition is not provided it will evaluate to true by default. For grammar, See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. + :paramtype condition: str + :keyword endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Used to specify whether the fallback route is enabled. Required. + :paramtype is_enabled: bool + """ + super().__init__(**kwargs) + self.name = name + self.source = source + self.condition = condition + self.endpoint_names = endpoint_names + self.is_enabled = is_enabled + + +class FeedbackProperties(_serialization.Model): + """The properties of the feedback queue for cloud-to-device messages. + + :ivar lock_duration_as_iso8601: The lock duration for the feedback queue. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :vartype lock_duration_as_iso8601: ~datetime.timedelta + :ivar ttl_as_iso8601: The period of time for which a message is available to consume before it + is expired by the IoT hub. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :vartype ttl_as_iso8601: ~datetime.timedelta + :ivar max_delivery_count: The number of times the IoT hub attempts to deliver a message on the + feedback queue. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :vartype max_delivery_count: int + """ + + _validation = { + "max_delivery_count": {"maximum": 100, "minimum": 1}, + } + + _attribute_map = { + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, + } + + def __init__( + self, + *, + lock_duration_as_iso8601: Optional[datetime.timedelta] = None, + ttl_as_iso8601: Optional[datetime.timedelta] = None, + max_delivery_count: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword lock_duration_as_iso8601: The lock duration for the feedback queue. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :paramtype lock_duration_as_iso8601: ~datetime.timedelta + :keyword ttl_as_iso8601: The period of time for which a message is available to consume before + it is expired by the IoT hub. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :paramtype ttl_as_iso8601: ~datetime.timedelta + :keyword max_delivery_count: The number of times the IoT hub attempts to deliver a message on + the feedback queue. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :paramtype max_delivery_count: int + """ + super().__init__(**kwargs) + self.lock_duration_as_iso8601 = lock_duration_as_iso8601 + self.ttl_as_iso8601 = ttl_as_iso8601 + self.max_delivery_count = max_delivery_count + + +class GroupIdInformation(_serialization.Model): + """The group information for creating a private endpoint on an IotHub. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The resource identifier. + :vartype id: str + :ivar name: The resource name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :ivar properties: The properties for a group information object. Required. + :vartype properties: ~azure.mgmt.iothub.v2023_06_30.models.GroupIdInformationProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "properties": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "GroupIdInformationProperties"}, + } + + def __init__(self, *, properties: "_models.GroupIdInformationProperties", **kwargs: Any) -> None: + """ + :keyword properties: The properties for a group information object. Required. + :paramtype properties: ~azure.mgmt.iothub.v2023_06_30.models.GroupIdInformationProperties + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.properties = properties + + +class GroupIdInformationProperties(_serialization.Model): + """The properties for a group information object. + + :ivar group_id: The group id. + :vartype group_id: str + :ivar required_members: The required members for a specific group id. + :vartype required_members: list[str] + :ivar required_zone_names: The required DNS zones for a specific group id. + :vartype required_zone_names: list[str] + """ + + _attribute_map = { + "group_id": {"key": "groupId", "type": "str"}, + "required_members": {"key": "requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "requiredZoneNames", "type": "[str]"}, + } + + def __init__( + self, + *, + group_id: Optional[str] = None, + required_members: Optional[List[str]] = None, + required_zone_names: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword group_id: The group id. + :paramtype group_id: str + :keyword required_members: The required members for a specific group id. + :paramtype required_members: list[str] + :keyword required_zone_names: The required DNS zones for a specific group id. + :paramtype required_zone_names: list[str] + """ + super().__init__(**kwargs) + self.group_id = group_id + self.required_members = required_members + self.required_zone_names = required_zone_names + + +class ImportDevicesRequest(_serialization.Model): + """Use to provide parameters when requesting an import of all devices in the hub. + + All required parameters must be populated in order to send to Azure. + + :ivar input_blob_container_uri: The input blob container URI. Required. + :vartype input_blob_container_uri: str + :ivar output_blob_container_uri: The output blob container URI. Required. + :vartype output_blob_container_uri: str + :ivar input_blob_name: The blob name to be used when importing from the provided input blob + container. + :vartype input_blob_name: str + :ivar output_blob_name: The blob name to use for storing the status of the import job. + :vartype output_blob_name: str + :ivar authentication_type: Specifies authentication type being used for connecting to the + storage account. Known values are: "keyBased" and "identityBased". + :vartype authentication_type: str or ~azure.mgmt.iothub.v2023_06_30.models.AuthenticationType + :ivar identity: Managed identity properties of storage endpoint for import devices. + :vartype identity: ~azure.mgmt.iothub.v2023_06_30.models.ManagedIdentity + :ivar include_configurations: The value indicating whether configurations should be imported. + :vartype include_configurations: bool + :ivar configurations_blob_name: The blob name to be used when importing configurations from the + provided input blob container. + :vartype configurations_blob_name: str + """ + + _validation = { + "input_blob_container_uri": {"required": True}, + "output_blob_container_uri": {"required": True}, + } + + _attribute_map = { + "input_blob_container_uri": {"key": "inputBlobContainerUri", "type": "str"}, + "output_blob_container_uri": {"key": "outputBlobContainerUri", "type": "str"}, + "input_blob_name": {"key": "inputBlobName", "type": "str"}, + "output_blob_name": {"key": "outputBlobName", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "include_configurations": {"key": "includeConfigurations", "type": "bool"}, + "configurations_blob_name": {"key": "configurationsBlobName", "type": "str"}, + } + + def __init__( + self, + *, + input_blob_container_uri: str, + output_blob_container_uri: str, + input_blob_name: Optional[str] = None, + output_blob_name: Optional[str] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, + include_configurations: Optional[bool] = None, + configurations_blob_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword input_blob_container_uri: The input blob container URI. Required. + :paramtype input_blob_container_uri: str + :keyword output_blob_container_uri: The output blob container URI. Required. + :paramtype output_blob_container_uri: str + :keyword input_blob_name: The blob name to be used when importing from the provided input blob + container. + :paramtype input_blob_name: str + :keyword output_blob_name: The blob name to use for storing the status of the import job. + :paramtype output_blob_name: str + :keyword authentication_type: Specifies authentication type being used for connecting to the + storage account. Known values are: "keyBased" and "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2023_06_30.models.AuthenticationType + :keyword identity: Managed identity properties of storage endpoint for import devices. + :paramtype identity: ~azure.mgmt.iothub.v2023_06_30.models.ManagedIdentity + :keyword include_configurations: The value indicating whether configurations should be + imported. + :paramtype include_configurations: bool + :keyword configurations_blob_name: The blob name to be used when importing configurations from + the provided input blob container. + :paramtype configurations_blob_name: str + """ + super().__init__(**kwargs) + self.input_blob_container_uri = input_blob_container_uri + self.output_blob_container_uri = output_blob_container_uri + self.input_blob_name = input_blob_name + self.output_blob_name = output_blob_name + self.authentication_type = authentication_type + self.identity = identity + self.include_configurations = include_configurations + self.configurations_blob_name = configurations_blob_name + + +class IotHubCapacity(_serialization.Model): + """IoT Hub capacity information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar minimum: The minimum number of units. + :vartype minimum: int + :ivar maximum: The maximum number of units. + :vartype maximum: int + :ivar default: The default number of units. + :vartype default: int + :ivar scale_type: The type of the scaling enabled. Known values are: "Automatic", "Manual", and + "None". + :vartype scale_type: str or ~azure.mgmt.iothub.v2023_06_30.models.IotHubScaleType + """ + + _validation = { + "minimum": {"readonly": True, "maximum": 1, "minimum": 1}, + "maximum": {"readonly": True}, + "default": {"readonly": True}, + "scale_type": {"readonly": True}, + } + + _attribute_map = { + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.minimum = None + self.maximum = None + self.default = None + self.scale_type = None + + +class Resource(_serialization.Model): + """The common properties of an Azure resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The resource identifier. + :vartype id: str + :ivar name: The resource name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :ivar location: The resource location. Required. + :vartype location: str + :ivar tags: The resource tags. + :vartype tags: dict[str, str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword location: The resource location. Required. + :paramtype location: str + :keyword tags: The resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + + +class IotHubDescription(Resource): + """The description of the IoT hub. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The resource identifier. + :vartype id: str + :ivar name: The resource name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :ivar location: The resource location. Required. + :vartype location: str + :ivar tags: The resource tags. + :vartype tags: dict[str, str] + :ivar etag: The Etag field is *not* required. If it is provided in the response body, it must + also be provided as a header per the normal ETag convention. + :vartype etag: str + :ivar properties: IotHub properties. + :vartype properties: ~azure.mgmt.iothub.v2023_06_30.models.IotHubProperties + :ivar sku: IotHub SKU info. Required. + :vartype sku: ~azure.mgmt.iothub.v2023_06_30.models.IotHubSkuInfo + :ivar identity: The managed identities for the IotHub. + :vartype identity: ~azure.mgmt.iothub.v2023_06_30.models.ArmIdentity + :ivar system_data: The system meta data relating to this resource. + :vartype system_data: ~azure.mgmt.iothub.v2023_06_30.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"required": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "etag": {"key": "etag", "type": "str"}, + "properties": {"key": "properties", "type": "IotHubProperties"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, + "identity": {"key": "identity", "type": "ArmIdentity"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__( + self, + *, + location: str, + sku: "_models.IotHubSkuInfo", + tags: Optional[Dict[str, str]] = None, + etag: Optional[str] = None, + properties: Optional["_models.IotHubProperties"] = None, + identity: Optional["_models.ArmIdentity"] = None, + **kwargs: Any + ) -> None: + """ + :keyword location: The resource location. Required. + :paramtype location: str + :keyword tags: The resource tags. + :paramtype tags: dict[str, str] + :keyword etag: The Etag field is *not* required. If it is provided in the response body, it + must also be provided as a header per the normal ETag convention. + :paramtype etag: str + :keyword properties: IotHub properties. + :paramtype properties: ~azure.mgmt.iothub.v2023_06_30.models.IotHubProperties + :keyword sku: IotHub SKU info. Required. + :paramtype sku: ~azure.mgmt.iothub.v2023_06_30.models.IotHubSkuInfo + :keyword identity: The managed identities for the IotHub. + :paramtype identity: ~azure.mgmt.iothub.v2023_06_30.models.ArmIdentity + """ + super().__init__(location=location, tags=tags, **kwargs) + self.etag = etag + self.properties = properties + self.sku = sku + self.identity = identity + self.system_data = None + + +class IotHubDescriptionListResult(_serialization.Model): + """The JSON-serialized array of IotHubDescription objects with a next link. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The array of IotHubDescription objects. + :vartype value: list[~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription] + :ivar next_link: The next link. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[IotHubDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.IotHubDescription"]] = None, **kwargs: Any) -> None: + """ + :keyword value: The array of IotHubDescription objects. + :paramtype value: list[~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class IotHubLocationDescription(_serialization.Model): + """Public representation of one of the locations where a resource is provisioned. + + :ivar location: The name of the Azure region. + :vartype location: str + :ivar role: The role of the region, can be either primary or secondary. The primary region is + where the IoT hub is currently provisioned. The secondary region is the Azure disaster recovery + (DR) paired region and also the region where the IoT hub can failover to. Known values are: + "primary" and "secondary". + :vartype role: str or ~azure.mgmt.iothub.v2023_06_30.models.IotHubReplicaRoleType + """ + + _attribute_map = { + "location": {"key": "location", "type": "str"}, + "role": {"key": "role", "type": "str"}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + role: Optional[Union[str, "_models.IotHubReplicaRoleType"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword location: The name of the Azure region. + :paramtype location: str + :keyword role: The role of the region, can be either primary or secondary. The primary region + is where the IoT hub is currently provisioned. The secondary region is the Azure disaster + recovery (DR) paired region and also the region where the IoT hub can failover to. Known values + are: "primary" and "secondary". + :paramtype role: str or ~azure.mgmt.iothub.v2023_06_30.models.IotHubReplicaRoleType + """ + super().__init__(**kwargs) + self.location = location + self.role = role + + +class IotHubNameAvailabilityInfo(_serialization.Model): + """The properties indicating whether a given IoT hub name is available. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name_available: The value which indicates whether the provided name is available. + :vartype name_available: bool + :ivar reason: The reason for unavailability. Known values are: "Invalid" and "AlreadyExists". + :vartype reason: str or ~azure.mgmt.iothub.v2023_06_30.models.IotHubNameUnavailabilityReason + :ivar message: The detailed reason message. + :vartype message: str + """ + + _validation = { + "name_available": {"readonly": True}, + "reason": {"readonly": True}, + } + + _attribute_map = { + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, *, message: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword message: The detailed reason message. + :paramtype message: str + """ + super().__init__(**kwargs) + self.name_available = None + self.reason = None + self.message = message + + +class IotHubProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes + """The properties of an IoT hub. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar authorization_policies: The shared access policies you can use to secure a connection to + the IoT hub. + :vartype authorization_policies: + list[~azure.mgmt.iothub.v2023_06_30.models.SharedAccessSignatureAuthorizationRule] + :ivar disable_local_auth: If true, SAS tokens with Iot hub scoped SAS keys cannot be used for + authentication. + :vartype disable_local_auth: bool + :ivar disable_device_sas: If true, all device(including Edge devices but excluding modules) + scoped SAS keys cannot be used for authentication. + :vartype disable_device_sas: bool + :ivar disable_module_sas: If true, all module scoped SAS keys cannot be used for + authentication. + :vartype disable_module_sas: bool + :ivar restrict_outbound_network_access: If true, egress from IotHub will be restricted to only + the allowed FQDNs that are configured via allowedFqdnList. + :vartype restrict_outbound_network_access: bool + :ivar allowed_fqdn_list: List of allowed FQDNs(Fully Qualified Domain Name) for egress from Iot + Hub. + :vartype allowed_fqdn_list: list[str] + :ivar public_network_access: Whether requests from Public Network are allowed. Known values + are: "Enabled" and "Disabled". + :vartype public_network_access: str or + ~azure.mgmt.iothub.v2023_06_30.models.PublicNetworkAccess + :ivar ip_filter_rules: The IP filter rules. + :vartype ip_filter_rules: list[~azure.mgmt.iothub.v2023_06_30.models.IpFilterRule] + :ivar network_rule_sets: Network Rule Set Properties of IotHub. + :vartype network_rule_sets: ~azure.mgmt.iothub.v2023_06_30.models.NetworkRuleSetProperties + :ivar min_tls_version: Specifies the minimum TLS version to support for this hub. Can be set to + "1.2" to have clients that use a TLS version below 1.2 to be rejected. + :vartype min_tls_version: str + :ivar private_endpoint_connections: Private endpoint connections created on this IotHub. + :vartype private_endpoint_connections: + list[~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpointConnection] + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str + :ivar state: The hub state. + :vartype state: str + :ivar host_name: The name of the host. + :vartype host_name: str + :ivar event_hub_endpoints: The Event Hub-compatible endpoint properties. The only possible keys + to this dictionary is events. This key has to be present in the dictionary while making create + or update calls for the IoT hub. + :vartype event_hub_endpoints: dict[str, + ~azure.mgmt.iothub.v2023_06_30.models.EventHubProperties] + :ivar routing: The routing related properties of the IoT hub. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. + :vartype routing: ~azure.mgmt.iothub.v2023_06_30.models.RoutingProperties + :ivar storage_endpoints: The list of Azure Storage endpoints where you can upload files. + Currently you can configure only one Azure Storage account and that MUST have its key as + $default. Specifying more than one storage account causes an error to be thrown. Not specifying + a value for this property when the enableFileUploadNotifications property is set to True, + causes an error to be thrown. + :vartype storage_endpoints: dict[str, + ~azure.mgmt.iothub.v2023_06_30.models.StorageEndpointProperties] + :ivar messaging_endpoints: The messaging endpoint properties for the file upload notification + queue. + :vartype messaging_endpoints: dict[str, + ~azure.mgmt.iothub.v2023_06_30.models.MessagingEndpointProperties] + :ivar enable_file_upload_notifications: If True, file upload notifications are enabled. + :vartype enable_file_upload_notifications: bool + :ivar cloud_to_device: The IoT hub cloud-to-device messaging properties. + :vartype cloud_to_device: ~azure.mgmt.iothub.v2023_06_30.models.CloudToDeviceProperties + :ivar comments: IoT hub comments. + :vartype comments: str + :ivar features: The capabilities and features enabled for the IoT hub. Known values are: "None" + and "DeviceManagement". + :vartype features: str or ~azure.mgmt.iothub.v2023_06_30.models.Capabilities + :ivar locations: Primary and secondary location for iot hub. + :vartype locations: list[~azure.mgmt.iothub.v2023_06_30.models.IotHubLocationDescription] + :ivar enable_data_residency: This property when set to true, will enable data residency, thus, + disabling disaster recovery. + :vartype enable_data_residency: bool + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "state": {"readonly": True}, + "host_name": {"readonly": True}, + "locations": {"readonly": True}, + } + + _attribute_map = { + "authorization_policies": {"key": "authorizationPolicies", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "disable_local_auth": {"key": "disableLocalAuth", "type": "bool"}, + "disable_device_sas": {"key": "disableDeviceSAS", "type": "bool"}, + "disable_module_sas": {"key": "disableModuleSAS", "type": "bool"}, + "restrict_outbound_network_access": {"key": "restrictOutboundNetworkAccess", "type": "bool"}, + "allowed_fqdn_list": {"key": "allowedFqdnList", "type": "[str]"}, + "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, + "ip_filter_rules": {"key": "ipFilterRules", "type": "[IpFilterRule]"}, + "network_rule_sets": {"key": "networkRuleSets", "type": "NetworkRuleSetProperties"}, + "min_tls_version": {"key": "minTlsVersion", "type": "str"}, + "private_endpoint_connections": {"key": "privateEndpointConnections", "type": "[PrivateEndpointConnection]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "host_name": {"key": "hostName", "type": "str"}, + "event_hub_endpoints": {"key": "eventHubEndpoints", "type": "{EventHubProperties}"}, + "routing": {"key": "routing", "type": "RoutingProperties"}, + "storage_endpoints": {"key": "storageEndpoints", "type": "{StorageEndpointProperties}"}, + "messaging_endpoints": {"key": "messagingEndpoints", "type": "{MessagingEndpointProperties}"}, + "enable_file_upload_notifications": {"key": "enableFileUploadNotifications", "type": "bool"}, + "cloud_to_device": {"key": "cloudToDevice", "type": "CloudToDeviceProperties"}, + "comments": {"key": "comments", "type": "str"}, + "features": {"key": "features", "type": "str"}, + "locations": {"key": "locations", "type": "[IotHubLocationDescription]"}, + "enable_data_residency": {"key": "enableDataResidency", "type": "bool"}, + } + + def __init__( # pylint: disable=too-many-locals + self, + *, + authorization_policies: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, + disable_local_auth: Optional[bool] = None, + disable_device_sas: Optional[bool] = None, + disable_module_sas: Optional[bool] = None, + restrict_outbound_network_access: Optional[bool] = None, + allowed_fqdn_list: Optional[List[str]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + ip_filter_rules: Optional[List["_models.IpFilterRule"]] = None, + network_rule_sets: Optional["_models.NetworkRuleSetProperties"] = None, + min_tls_version: Optional[str] = None, + private_endpoint_connections: Optional[List["_models.PrivateEndpointConnection"]] = None, + event_hub_endpoints: Optional[Dict[str, "_models.EventHubProperties"]] = None, + routing: Optional["_models.RoutingProperties"] = None, + storage_endpoints: Optional[Dict[str, "_models.StorageEndpointProperties"]] = None, + messaging_endpoints: Optional[Dict[str, "_models.MessagingEndpointProperties"]] = None, + enable_file_upload_notifications: Optional[bool] = None, + cloud_to_device: Optional["_models.CloudToDeviceProperties"] = None, + comments: Optional[str] = None, + features: Optional[Union[str, "_models.Capabilities"]] = None, + enable_data_residency: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword authorization_policies: The shared access policies you can use to secure a connection + to the IoT hub. + :paramtype authorization_policies: + list[~azure.mgmt.iothub.v2023_06_30.models.SharedAccessSignatureAuthorizationRule] + :keyword disable_local_auth: If true, SAS tokens with Iot hub scoped SAS keys cannot be used + for authentication. + :paramtype disable_local_auth: bool + :keyword disable_device_sas: If true, all device(including Edge devices but excluding modules) + scoped SAS keys cannot be used for authentication. + :paramtype disable_device_sas: bool + :keyword disable_module_sas: If true, all module scoped SAS keys cannot be used for + authentication. + :paramtype disable_module_sas: bool + :keyword restrict_outbound_network_access: If true, egress from IotHub will be restricted to + only the allowed FQDNs that are configured via allowedFqdnList. + :paramtype restrict_outbound_network_access: bool + :keyword allowed_fqdn_list: List of allowed FQDNs(Fully Qualified Domain Name) for egress from + Iot Hub. + :paramtype allowed_fqdn_list: list[str] + :keyword public_network_access: Whether requests from Public Network are allowed. Known values + are: "Enabled" and "Disabled". + :paramtype public_network_access: str or + ~azure.mgmt.iothub.v2023_06_30.models.PublicNetworkAccess + :keyword ip_filter_rules: The IP filter rules. + :paramtype ip_filter_rules: list[~azure.mgmt.iothub.v2023_06_30.models.IpFilterRule] + :keyword network_rule_sets: Network Rule Set Properties of IotHub. + :paramtype network_rule_sets: ~azure.mgmt.iothub.v2023_06_30.models.NetworkRuleSetProperties + :keyword min_tls_version: Specifies the minimum TLS version to support for this hub. Can be set + to "1.2" to have clients that use a TLS version below 1.2 to be rejected. + :paramtype min_tls_version: str + :keyword private_endpoint_connections: Private endpoint connections created on this IotHub. + :paramtype private_endpoint_connections: + list[~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpointConnection] + :keyword event_hub_endpoints: The Event Hub-compatible endpoint properties. The only possible + keys to this dictionary is events. This key has to be present in the dictionary while making + create or update calls for the IoT hub. + :paramtype event_hub_endpoints: dict[str, + ~azure.mgmt.iothub.v2023_06_30.models.EventHubProperties] + :keyword routing: The routing related properties of the IoT hub. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. + :paramtype routing: ~azure.mgmt.iothub.v2023_06_30.models.RoutingProperties + :keyword storage_endpoints: The list of Azure Storage endpoints where you can upload files. + Currently you can configure only one Azure Storage account and that MUST have its key as + $default. Specifying more than one storage account causes an error to be thrown. Not specifying + a value for this property when the enableFileUploadNotifications property is set to True, + causes an error to be thrown. + :paramtype storage_endpoints: dict[str, + ~azure.mgmt.iothub.v2023_06_30.models.StorageEndpointProperties] + :keyword messaging_endpoints: The messaging endpoint properties for the file upload + notification queue. + :paramtype messaging_endpoints: dict[str, + ~azure.mgmt.iothub.v2023_06_30.models.MessagingEndpointProperties] + :keyword enable_file_upload_notifications: If True, file upload notifications are enabled. + :paramtype enable_file_upload_notifications: bool + :keyword cloud_to_device: The IoT hub cloud-to-device messaging properties. + :paramtype cloud_to_device: ~azure.mgmt.iothub.v2023_06_30.models.CloudToDeviceProperties + :keyword comments: IoT hub comments. + :paramtype comments: str + :keyword features: The capabilities and features enabled for the IoT hub. Known values are: + "None" and "DeviceManagement". + :paramtype features: str or ~azure.mgmt.iothub.v2023_06_30.models.Capabilities + :keyword enable_data_residency: This property when set to true, will enable data residency, + thus, disabling disaster recovery. + :paramtype enable_data_residency: bool + """ + super().__init__(**kwargs) + self.authorization_policies = authorization_policies + self.disable_local_auth = disable_local_auth + self.disable_device_sas = disable_device_sas + self.disable_module_sas = disable_module_sas + self.restrict_outbound_network_access = restrict_outbound_network_access + self.allowed_fqdn_list = allowed_fqdn_list + self.public_network_access = public_network_access + self.ip_filter_rules = ip_filter_rules + self.network_rule_sets = network_rule_sets + self.min_tls_version = min_tls_version + self.private_endpoint_connections = private_endpoint_connections + self.provisioning_state = None + self.state = None + self.host_name = None + self.event_hub_endpoints = event_hub_endpoints + self.routing = routing + self.storage_endpoints = storage_endpoints + self.messaging_endpoints = messaging_endpoints + self.enable_file_upload_notifications = enable_file_upload_notifications + self.cloud_to_device = cloud_to_device + self.comments = comments + self.features = features + self.locations = None + self.enable_data_residency = enable_data_residency + + +class IotHubQuotaMetricInfo(_serialization.Model): + """Quota metrics properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the quota metric. + :vartype name: str + :ivar current_value: The current value for the quota metric. + :vartype current_value: int + :ivar max_value: The maximum value of the quota metric. + :vartype max_value: int + """ + + _validation = { + "name": {"readonly": True}, + "current_value": {"readonly": True}, + "max_value": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "max_value": {"key": "maxValue", "type": "int"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.name = None + self.current_value = None + self.max_value = None + + +class IotHubQuotaMetricInfoListResult(_serialization.Model): + """The JSON-serialized array of IotHubQuotaMetricInfo objects with a next link. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The array of quota metrics objects. + :vartype value: list[~azure.mgmt.iothub.v2023_06_30.models.IotHubQuotaMetricInfo] + :ivar next_link: The next link. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[IotHubQuotaMetricInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.IotHubQuotaMetricInfo"]] = None, **kwargs: Any) -> None: + """ + :keyword value: The array of quota metrics objects. + :paramtype value: list[~azure.mgmt.iothub.v2023_06_30.models.IotHubQuotaMetricInfo] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class IotHubSkuDescription(_serialization.Model): + """SKU properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar resource_type: The type of the resource. + :vartype resource_type: str + :ivar sku: The type of the resource. Required. + :vartype sku: ~azure.mgmt.iothub.v2023_06_30.models.IotHubSkuInfo + :ivar capacity: IotHub capacity. Required. + :vartype capacity: ~azure.mgmt.iothub.v2023_06_30.models.IotHubCapacity + """ + + _validation = { + "resource_type": {"readonly": True}, + "sku": {"required": True}, + "capacity": {"required": True}, + } + + _attribute_map = { + "resource_type": {"key": "resourceType", "type": "str"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, + "capacity": {"key": "capacity", "type": "IotHubCapacity"}, + } + + def __init__(self, *, sku: "_models.IotHubSkuInfo", capacity: "_models.IotHubCapacity", **kwargs: Any) -> None: + """ + :keyword sku: The type of the resource. Required. + :paramtype sku: ~azure.mgmt.iothub.v2023_06_30.models.IotHubSkuInfo + :keyword capacity: IotHub capacity. Required. + :paramtype capacity: ~azure.mgmt.iothub.v2023_06_30.models.IotHubCapacity + """ + super().__init__(**kwargs) + self.resource_type = None + self.sku = sku + self.capacity = capacity + + +class IotHubSkuDescriptionListResult(_serialization.Model): + """The JSON-serialized array of IotHubSkuDescription objects with a next link. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The array of IotHubSkuDescription. + :vartype value: list[~azure.mgmt.iothub.v2023_06_30.models.IotHubSkuDescription] + :ivar next_link: The next link. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[IotHubSkuDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.IotHubSkuDescription"]] = None, **kwargs: Any) -> None: + """ + :keyword value: The array of IotHubSkuDescription. + :paramtype value: list[~azure.mgmt.iothub.v2023_06_30.models.IotHubSkuDescription] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class IotHubSkuInfo(_serialization.Model): + """Information about the SKU of the IoT hub. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", "S3", "B1", + "B2", and "B3". + :vartype name: str or ~azure.mgmt.iothub.v2023_06_30.models.IotHubSku + :ivar tier: The billing tier for the IoT hub. Known values are: "Free", "Standard", and + "Basic". + :vartype tier: str or ~azure.mgmt.iothub.v2023_06_30.models.IotHubSkuTier + :ivar capacity: The number of provisioned IoT Hub units. See: + https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. + :vartype capacity: int + """ + + _validation = { + "name": {"required": True}, + "tier": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, + } + + def __init__(self, *, name: Union[str, "_models.IotHubSku"], capacity: Optional[int] = None, **kwargs: Any) -> None: + """ + :keyword name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", "S3", "B1", + "B2", and "B3". + :paramtype name: str or ~azure.mgmt.iothub.v2023_06_30.models.IotHubSku + :keyword capacity: The number of provisioned IoT Hub units. See: + https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. + :paramtype capacity: int + """ + super().__init__(**kwargs) + self.name = name + self.tier = None + self.capacity = capacity + + +class IpFilterRule(_serialization.Model): + """The IP filter rules for the IoT hub. + + All required parameters must be populated in order to send to Azure. + + :ivar filter_name: The name of the IP filter rule. Required. + :vartype filter_name: str + :ivar action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". + :vartype action: str or ~azure.mgmt.iothub.v2023_06_30.models.IpFilterActionType + :ivar ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. + :vartype ip_mask: str + """ + + _validation = { + "filter_name": {"required": True}, + "action": {"required": True}, + "ip_mask": {"required": True}, + } + + _attribute_map = { + "filter_name": {"key": "filterName", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "ip_mask": {"key": "ipMask", "type": "str"}, + } + + def __init__( + self, *, filter_name: str, action: Union[str, "_models.IpFilterActionType"], ip_mask: str, **kwargs: Any + ) -> None: + """ + :keyword filter_name: The name of the IP filter rule. Required. + :paramtype filter_name: str + :keyword action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". + :paramtype action: str or ~azure.mgmt.iothub.v2023_06_30.models.IpFilterActionType + :keyword ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. + :paramtype ip_mask: str + """ + super().__init__(**kwargs) + self.filter_name = filter_name + self.action = action + self.ip_mask = ip_mask + + +class JobResponse(_serialization.Model): + """The properties of the Job Response object. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar job_id: The job identifier. + :vartype job_id: str + :ivar start_time_utc: The start time of the job. + :vartype start_time_utc: ~datetime.datetime + :ivar end_time_utc: The time the job stopped processing. + :vartype end_time_utc: ~datetime.datetime + :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", + "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", + "factoryResetDevice", "firmwareUpdate", and "import". + :vartype type: str or ~azure.mgmt.iothub.v2023_06_30.models.JobType + :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", + "completed", "failed", and "cancelled". + :vartype status: str or ~azure.mgmt.iothub.v2023_06_30.models.JobStatus + :ivar failure_reason: If status == failed, this string containing the reason for the failure. + :vartype failure_reason: str + :ivar status_message: The status message for the job. + :vartype status_message: str + :ivar parent_job_id: The job identifier of the parent job, if any. + :vartype parent_job_id: str + """ + + _validation = { + "job_id": {"readonly": True}, + "start_time_utc": {"readonly": True}, + "end_time_utc": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "failure_reason": {"readonly": True}, + "status_message": {"readonly": True}, + "parent_job_id": {"readonly": True}, + } + + _attribute_map = { + "job_id": {"key": "jobId", "type": "str"}, + "start_time_utc": {"key": "startTimeUtc", "type": "rfc-1123"}, + "end_time_utc": {"key": "endTimeUtc", "type": "rfc-1123"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "str"}, + "parent_job_id": {"key": "parentJobId", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.job_id = None + self.start_time_utc = None + self.end_time_utc = None + self.type = None + self.status = None + self.failure_reason = None + self.status_message = None + self.parent_job_id = None + + +class JobResponseListResult(_serialization.Model): + """The JSON-serialized array of JobResponse objects with a next link. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The array of JobResponse objects. + :vartype value: list[~azure.mgmt.iothub.v2023_06_30.models.JobResponse] + :ivar next_link: The next link. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[JobResponse]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.JobResponse"]] = None, **kwargs: Any) -> None: + """ + :keyword value: The array of JobResponse objects. + :paramtype value: list[~azure.mgmt.iothub.v2023_06_30.models.JobResponse] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class ManagedIdentity(_serialization.Model): + """The properties of the Managed identity. + + :ivar user_assigned_identity: The user assigned identity. + :vartype user_assigned_identity: str + """ + + _attribute_map = { + "user_assigned_identity": {"key": "userAssignedIdentity", "type": "str"}, + } + + def __init__(self, *, user_assigned_identity: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword user_assigned_identity: The user assigned identity. + :paramtype user_assigned_identity: str + """ + super().__init__(**kwargs) + self.user_assigned_identity = user_assigned_identity + + +class MatchedRoute(_serialization.Model): + """Routes that matched. + + :ivar properties: Properties of routes that matched. + :vartype properties: ~azure.mgmt.iothub.v2023_06_30.models.RouteProperties + """ + + _attribute_map = { + "properties": {"key": "properties", "type": "RouteProperties"}, + } + + def __init__(self, *, properties: Optional["_models.RouteProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: Properties of routes that matched. + :paramtype properties: ~azure.mgmt.iothub.v2023_06_30.models.RouteProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class MessagingEndpointProperties(_serialization.Model): + """The properties of the messaging endpoints used by this IoT hub. + + :ivar lock_duration_as_iso8601: The lock duration. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. + :vartype lock_duration_as_iso8601: ~datetime.timedelta + :ivar ttl_as_iso8601: The period of time for which a message is available to consume before it + is expired by the IoT hub. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. + :vartype ttl_as_iso8601: ~datetime.timedelta + :ivar max_delivery_count: The number of times the IoT hub attempts to deliver a message. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. + :vartype max_delivery_count: int + """ + + _validation = { + "max_delivery_count": {"maximum": 100, "minimum": 1}, + } + + _attribute_map = { + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, + } + + def __init__( + self, + *, + lock_duration_as_iso8601: Optional[datetime.timedelta] = None, + ttl_as_iso8601: Optional[datetime.timedelta] = None, + max_delivery_count: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword lock_duration_as_iso8601: The lock duration. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. + :paramtype lock_duration_as_iso8601: ~datetime.timedelta + :keyword ttl_as_iso8601: The period of time for which a message is available to consume before + it is expired by the IoT hub. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. + :paramtype ttl_as_iso8601: ~datetime.timedelta + :keyword max_delivery_count: The number of times the IoT hub attempts to deliver a message. + See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. + :paramtype max_delivery_count: int + """ + super().__init__(**kwargs) + self.lock_duration_as_iso8601 = lock_duration_as_iso8601 + self.ttl_as_iso8601 = ttl_as_iso8601 + self.max_delivery_count = max_delivery_count + + +class Name(_serialization.Model): + """Name of Iot Hub type. + + :ivar value: IotHub type. + :vartype value: str + :ivar localized_value: Localized value of name. + :vartype localized_value: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, + } + + def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: IotHub type. + :paramtype value: str + :keyword localized_value: Localized value of name. + :paramtype localized_value: str + """ + super().__init__(**kwargs) + self.value = value + self.localized_value = localized_value + + +class NetworkRuleSetIpRule(_serialization.Model): + """IP Rule to be applied as part of Network Rule Set. + + All required parameters must be populated in order to send to Azure. + + :ivar filter_name: Name of the IP filter rule. Required. + :vartype filter_name: str + :ivar action: IP Filter Action. "Allow" + :vartype action: str or ~azure.mgmt.iothub.v2023_06_30.models.NetworkRuleIPAction + :ivar ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. + :vartype ip_mask: str + """ + + _validation = { + "filter_name": {"required": True}, + "ip_mask": {"required": True}, + } + + _attribute_map = { + "filter_name": {"key": "filterName", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "ip_mask": {"key": "ipMask", "type": "str"}, + } + + def __init__( + self, + *, + filter_name: str, + ip_mask: str, + action: Union[str, "_models.NetworkRuleIPAction"] = "Allow", + **kwargs: Any + ) -> None: + """ + :keyword filter_name: Name of the IP filter rule. Required. + :paramtype filter_name: str + :keyword action: IP Filter Action. "Allow" + :paramtype action: str or ~azure.mgmt.iothub.v2023_06_30.models.NetworkRuleIPAction + :keyword ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. + :paramtype ip_mask: str + """ + super().__init__(**kwargs) + self.filter_name = filter_name + self.action = action + self.ip_mask = ip_mask + + +class NetworkRuleSetProperties(_serialization.Model): + """Network Rule Set Properties of IotHub. + + All required parameters must be populated in order to send to Azure. + + :ivar default_action: Default Action for Network Rule Set. Known values are: "Deny" and + "Allow". + :vartype default_action: str or ~azure.mgmt.iothub.v2023_06_30.models.DefaultAction + :ivar apply_to_built_in_event_hub_endpoint: If True, then Network Rule Set is also applied to + BuiltIn EventHub EndPoint of IotHub. Required. + :vartype apply_to_built_in_event_hub_endpoint: bool + :ivar ip_rules: List of IP Rules. Required. + :vartype ip_rules: list[~azure.mgmt.iothub.v2023_06_30.models.NetworkRuleSetIpRule] + """ + + _validation = { + "apply_to_built_in_event_hub_endpoint": {"required": True}, + "ip_rules": {"required": True}, + } + + _attribute_map = { + "default_action": {"key": "defaultAction", "type": "str"}, + "apply_to_built_in_event_hub_endpoint": {"key": "applyToBuiltInEventHubEndpoint", "type": "bool"}, + "ip_rules": {"key": "ipRules", "type": "[NetworkRuleSetIpRule]"}, + } + + def __init__( + self, + *, + apply_to_built_in_event_hub_endpoint: bool, + ip_rules: List["_models.NetworkRuleSetIpRule"], + default_action: Union[str, "_models.DefaultAction"] = "Deny", + **kwargs: Any + ) -> None: + """ + :keyword default_action: Default Action for Network Rule Set. Known values are: "Deny" and + "Allow". + :paramtype default_action: str or ~azure.mgmt.iothub.v2023_06_30.models.DefaultAction + :keyword apply_to_built_in_event_hub_endpoint: If True, then Network Rule Set is also applied + to BuiltIn EventHub EndPoint of IotHub. Required. + :paramtype apply_to_built_in_event_hub_endpoint: bool + :keyword ip_rules: List of IP Rules. Required. + :paramtype ip_rules: list[~azure.mgmt.iothub.v2023_06_30.models.NetworkRuleSetIpRule] + """ + super().__init__(**kwargs) + self.default_action = default_action + self.apply_to_built_in_event_hub_endpoint = apply_to_built_in_event_hub_endpoint + self.ip_rules = ip_rules + + +class Operation(_serialization.Model): + """IoT Hub REST API operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Operation name: {provider}/{resource}/{read | write | action | delete}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.iothub.v2023_06_30.models.OperationDisplay + """ + + _validation = { + "name": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + } + + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any) -> None: + """ + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.iothub.v2023_06_30.models.OperationDisplay + """ + super().__init__(**kwargs) + self.name = None + self.display = display + + +class OperationDisplay(_serialization.Model): + """The object that represents the operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: Service provider: Microsoft Devices. + :vartype provider: str + :ivar resource: Resource Type: IotHubs. + :vartype resource: str + :ivar operation: Name of the operation. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str + """ + + _validation = { + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None + + +class OperationInputs(_serialization.Model): + """Input values. + + All required parameters must be populated in order to send to Azure. + + :ivar name: The name of the IoT hub to check. Required. + :vartype name: str + """ + + _validation = { + "name": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + } + + def __init__(self, *, name: str, **kwargs: Any) -> None: + """ + :keyword name: The name of the IoT hub to check. Required. + :paramtype name: str + """ + super().__init__(**kwargs) + self.name = name + + +class OperationListResult(_serialization.Model): + """Result of the request to list IoT Hub operations. It contains a list of operations and a URL + link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of IoT Hub operations supported by the Microsoft.Devices resource provider. + :vartype value: list[~azure.mgmt.iothub.v2023_06_30.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class PrivateEndpoint(_serialization.Model): + """The private endpoint property of a private endpoint connection. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource identifier. + :vartype id: str + """ + + _validation = { + "id": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + + +class PrivateEndpointConnection(_serialization.Model): + """The private endpoint connection of an IotHub. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The resource identifier. + :vartype id: str + :ivar name: The resource name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :ivar properties: The properties of a private endpoint connection. Required. + :vartype properties: ~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpointConnectionProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "properties": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "PrivateEndpointConnectionProperties"}, + } + + def __init__(self, *, properties: "_models.PrivateEndpointConnectionProperties", **kwargs: Any) -> None: + """ + :keyword properties: The properties of a private endpoint connection. Required. + :paramtype properties: + ~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpointConnectionProperties + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.properties = properties + + +class PrivateEndpointConnectionProperties(_serialization.Model): + """The properties of a private endpoint connection. + + All required parameters must be populated in order to send to Azure. + + :ivar private_endpoint: The private endpoint property of a private endpoint connection. + :vartype private_endpoint: ~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpoint + :ivar private_link_service_connection_state: The current state of a private endpoint + connection. Required. + :vartype private_link_service_connection_state: + ~azure.mgmt.iothub.v2023_06_30.models.PrivateLinkServiceConnectionState + """ + + _validation = { + "private_link_service_connection_state": {"required": True}, + } + + _attribute_map = { + "private_endpoint": {"key": "privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + } + + def __init__( + self, + *, + private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState", + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + **kwargs: Any + ) -> None: + """ + :keyword private_endpoint: The private endpoint property of a private endpoint connection. + :paramtype private_endpoint: ~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpoint + :keyword private_link_service_connection_state: The current state of a private endpoint + connection. Required. + :paramtype private_link_service_connection_state: + ~azure.mgmt.iothub.v2023_06_30.models.PrivateLinkServiceConnectionState + """ + super().__init__(**kwargs) + self.private_endpoint = private_endpoint + self.private_link_service_connection_state = private_link_service_connection_state + + +class PrivateLinkResources(_serialization.Model): + """The available private link resources for an IotHub. + + :ivar value: The list of available private link resources for an IotHub. + :vartype value: list[~azure.mgmt.iothub.v2023_06_30.models.GroupIdInformation] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[GroupIdInformation]"}, + } + + def __init__(self, *, value: Optional[List["_models.GroupIdInformation"]] = None, **kwargs: Any) -> None: + """ + :keyword value: The list of available private link resources for an IotHub. + :paramtype value: list[~azure.mgmt.iothub.v2023_06_30.models.GroupIdInformation] + """ + super().__init__(**kwargs) + self.value = value + + +class PrivateLinkServiceConnectionState(_serialization.Model): + """The current state of a private endpoint connection. + + All required parameters must be populated in order to send to Azure. + + :ivar status: The status of a private endpoint connection. Required. Known values are: + "Pending", "Approved", "Rejected", and "Disconnected". + :vartype status: str or + ~azure.mgmt.iothub.v2023_06_30.models.PrivateLinkServiceConnectionStatus + :ivar description: The description for the current state of a private endpoint connection. + Required. + :vartype description: str + :ivar actions_required: Actions required for a private endpoint connection. + :vartype actions_required: str + """ + + _validation = { + "status": {"required": True}, + "description": {"required": True}, + } + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, + } + + def __init__( + self, + *, + status: Union[str, "_models.PrivateLinkServiceConnectionStatus"], + description: str, + actions_required: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword status: The status of a private endpoint connection. Required. Known values are: + "Pending", "Approved", "Rejected", and "Disconnected". + :paramtype status: str or + ~azure.mgmt.iothub.v2023_06_30.models.PrivateLinkServiceConnectionStatus + :keyword description: The description for the current state of a private endpoint connection. + Required. + :paramtype description: str + :keyword actions_required: Actions required for a private endpoint connection. + :paramtype actions_required: str + """ + super().__init__(**kwargs) + self.status = status + self.description = description + self.actions_required = actions_required + + +class RegistryStatistics(_serialization.Model): + """Identity registry statistics. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar total_device_count: The total count of devices in the identity registry. + :vartype total_device_count: int + :ivar enabled_device_count: The count of enabled devices in the identity registry. + :vartype enabled_device_count: int + :ivar disabled_device_count: The count of disabled devices in the identity registry. + :vartype disabled_device_count: int + """ + + _validation = { + "total_device_count": {"readonly": True}, + "enabled_device_count": {"readonly": True}, + "disabled_device_count": {"readonly": True}, + } + + _attribute_map = { + "total_device_count": {"key": "totalDeviceCount", "type": "int"}, + "enabled_device_count": {"key": "enabledDeviceCount", "type": "int"}, + "disabled_device_count": {"key": "disabledDeviceCount", "type": "int"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.total_device_count = None + self.enabled_device_count = None + self.disabled_device_count = None + + +class RouteCompilationError(_serialization.Model): + """Compilation error when evaluating route. + + :ivar message: Route error message. + :vartype message: str + :ivar severity: Severity of the route error. Known values are: "error" and "warning". + :vartype severity: str or ~azure.mgmt.iothub.v2023_06_30.models.RouteErrorSeverity + :ivar location: Location where the route error happened. + :vartype location: ~azure.mgmt.iothub.v2023_06_30.models.RouteErrorRange + """ + + _attribute_map = { + "message": {"key": "message", "type": "str"}, + "severity": {"key": "severity", "type": "str"}, + "location": {"key": "location", "type": "RouteErrorRange"}, + } + + def __init__( + self, + *, + message: Optional[str] = None, + severity: Optional[Union[str, "_models.RouteErrorSeverity"]] = None, + location: Optional["_models.RouteErrorRange"] = None, + **kwargs: Any + ) -> None: + """ + :keyword message: Route error message. + :paramtype message: str + :keyword severity: Severity of the route error. Known values are: "error" and "warning". + :paramtype severity: str or ~azure.mgmt.iothub.v2023_06_30.models.RouteErrorSeverity + :keyword location: Location where the route error happened. + :paramtype location: ~azure.mgmt.iothub.v2023_06_30.models.RouteErrorRange + """ + super().__init__(**kwargs) + self.message = message + self.severity = severity + self.location = location + + +class RouteErrorPosition(_serialization.Model): + """Position where the route error happened. + + :ivar line: Line where the route error happened. + :vartype line: int + :ivar column: Column where the route error happened. + :vartype column: int + """ + + _attribute_map = { + "line": {"key": "line", "type": "int"}, + "column": {"key": "column", "type": "int"}, + } + + def __init__(self, *, line: Optional[int] = None, column: Optional[int] = None, **kwargs: Any) -> None: + """ + :keyword line: Line where the route error happened. + :paramtype line: int + :keyword column: Column where the route error happened. + :paramtype column: int + """ + super().__init__(**kwargs) + self.line = line + self.column = column + + +class RouteErrorRange(_serialization.Model): + """Range of route errors. + + :ivar start: Start where the route error happened. + :vartype start: ~azure.mgmt.iothub.v2023_06_30.models.RouteErrorPosition + :ivar end: End where the route error happened. + :vartype end: ~azure.mgmt.iothub.v2023_06_30.models.RouteErrorPosition + """ + + _attribute_map = { + "start": {"key": "start", "type": "RouteErrorPosition"}, + "end": {"key": "end", "type": "RouteErrorPosition"}, + } + + def __init__( + self, + *, + start: Optional["_models.RouteErrorPosition"] = None, + end: Optional["_models.RouteErrorPosition"] = None, + **kwargs: Any + ) -> None: + """ + :keyword start: Start where the route error happened. + :paramtype start: ~azure.mgmt.iothub.v2023_06_30.models.RouteErrorPosition + :keyword end: End where the route error happened. + :paramtype end: ~azure.mgmt.iothub.v2023_06_30.models.RouteErrorPosition + """ + super().__init__(**kwargs) + self.start = start + self.end = end + + +class RouteProperties(_serialization.Model): + """The properties of a routing rule that your IoT hub uses to route messages to endpoints. + + All required parameters must be populated in order to send to Azure. + + :ivar name: The name of the route. The name can only include alphanumeric characters, periods, + underscores, hyphens, has a maximum length of 64 characters, and must be unique. Required. + :vartype name: str + :ivar source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DeviceConnectionStateEvents". + :vartype source: str or ~azure.mgmt.iothub.v2023_06_30.models.RoutingSource + :ivar condition: The condition that is evaluated to apply the routing rule. If no condition is + provided, it evaluates to true by default. For grammar, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. + :vartype condition: str + :ivar endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. + :vartype endpoint_names: list[str] + :ivar is_enabled: Used to specify whether a route is enabled. Required. + :vartype is_enabled: bool + """ + + _validation = { + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + } + + def __init__( + self, + *, + name: str, + source: Union[str, "_models.RoutingSource"], + endpoint_names: List[str], + is_enabled: bool, + condition: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the route. The name can only include alphanumeric characters, + periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + Required. + :paramtype name: str + :keyword source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and "DeviceConnectionStateEvents". + :paramtype source: str or ~azure.mgmt.iothub.v2023_06_30.models.RoutingSource + :keyword condition: The condition that is evaluated to apply the routing rule. If no condition + is provided, it evaluates to true by default. For grammar, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. + :paramtype condition: str + :keyword endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Used to specify whether a route is enabled. Required. + :paramtype is_enabled: bool + """ + super().__init__(**kwargs) + self.name = name + self.source = source + self.condition = condition + self.endpoint_names = endpoint_names + self.is_enabled = is_enabled + + +class RoutingCosmosDBSqlApiProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes + """The properties related to a cosmos DB sql container endpoint. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. + :vartype name: str + :ivar id: Id of the cosmos DB sql container endpoint. + :vartype id: str + :ivar subscription_id: The subscription identifier of the cosmos DB account. + :vartype subscription_id: str + :ivar resource_group: The name of the resource group of the cosmos DB account. + :vartype resource_group: str + :ivar endpoint_uri: The url of the cosmos DB account. It must include the protocol https://. + Required. + :vartype endpoint_uri: str + :ivar authentication_type: Method used to authenticate against the cosmos DB sql container + endpoint. Known values are: "keyBased" and "identityBased". + :vartype authentication_type: str or ~azure.mgmt.iothub.v2023_06_30.models.AuthenticationType + :ivar identity: Managed identity properties of routing cosmos DB container endpoint. + :vartype identity: ~azure.mgmt.iothub.v2023_06_30.models.ManagedIdentity + :ivar primary_key: The primary key of the cosmos DB account. + :vartype primary_key: str + :ivar secondary_key: The secondary key of the cosmos DB account. + :vartype secondary_key: str + :ivar database_name: The name of the cosmos DB database in the cosmos DB account. Required. + :vartype database_name: str + :ivar container_name: The name of the cosmos DB sql container in the cosmos DB database. + Required. + :vartype container_name: str + :ivar partition_key_name: The name of the partition key associated with this cosmos DB sql + container if one exists. This is an optional parameter. + :vartype partition_key_name: str + :ivar partition_key_template: The template for generating a synthetic partition key value for + use with this cosmos DB sql container. The template must include at least one of the following + placeholders: {iothub}, {deviceid}, {DD}, {MM}, and {YYYY}. Any one placeholder may be + specified at most once, but order and non-placeholder components are arbitrary. This parameter + is only required if PartitionKeyName is specified. + :vartype partition_key_template: str + """ + + _validation = { + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "id": {"readonly": True}, + "endpoint_uri": {"required": True}, + "database_name": {"required": True}, + "container_name": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "database_name": {"key": "databaseName", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "partition_key_name": {"key": "partitionKeyName", "type": "str"}, + "partition_key_template": {"key": "partitionKeyTemplate", "type": "str"}, + } + + def __init__( + self, + *, + name: str, + endpoint_uri: str, + database_name: str, + container_name: str, + subscription_id: Optional[str] = None, + resource_group: Optional[str] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, + primary_key: Optional[str] = None, + secondary_key: Optional[str] = None, + partition_key_name: Optional[str] = None, + partition_key_template: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. + :paramtype name: str + :keyword subscription_id: The subscription identifier of the cosmos DB account. + :paramtype subscription_id: str + :keyword resource_group: The name of the resource group of the cosmos DB account. + :paramtype resource_group: str + :keyword endpoint_uri: The url of the cosmos DB account. It must include the protocol https://. + Required. + :paramtype endpoint_uri: str + :keyword authentication_type: Method used to authenticate against the cosmos DB sql container + endpoint. Known values are: "keyBased" and "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2023_06_30.models.AuthenticationType + :keyword identity: Managed identity properties of routing cosmos DB container endpoint. + :paramtype identity: ~azure.mgmt.iothub.v2023_06_30.models.ManagedIdentity + :keyword primary_key: The primary key of the cosmos DB account. + :paramtype primary_key: str + :keyword secondary_key: The secondary key of the cosmos DB account. + :paramtype secondary_key: str + :keyword database_name: The name of the cosmos DB database in the cosmos DB account. Required. + :paramtype database_name: str + :keyword container_name: The name of the cosmos DB sql container in the cosmos DB database. + Required. + :paramtype container_name: str + :keyword partition_key_name: The name of the partition key associated with this cosmos DB sql + container if one exists. This is an optional parameter. + :paramtype partition_key_name: str + :keyword partition_key_template: The template for generating a synthetic partition key value + for use with this cosmos DB sql container. The template must include at least one of the + following placeholders: {iothub}, {deviceid}, {DD}, {MM}, and {YYYY}. Any one placeholder may + be specified at most once, but order and non-placeholder components are arbitrary. This + parameter is only required if PartitionKeyName is specified. + :paramtype partition_key_template: str + """ + super().__init__(**kwargs) + self.name = name + self.id = None + self.subscription_id = subscription_id + self.resource_group = resource_group + self.endpoint_uri = endpoint_uri + self.authentication_type = authentication_type + self.identity = identity + self.primary_key = primary_key + self.secondary_key = secondary_key + self.database_name = database_name + self.container_name = container_name + self.partition_key_name = partition_key_name + self.partition_key_template = partition_key_template + + +class RoutingEndpoints(_serialization.Model): + """The properties related to the custom endpoints to which your IoT hub routes messages based on + the routing rules. A maximum of 10 custom endpoints are allowed across all endpoint types for + paid hubs and only 1 custom endpoint is allowed across all endpoint types for free hubs. + + :ivar service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the + messages to, based on the routing rules. + :vartype service_bus_queues: + list[~azure.mgmt.iothub.v2023_06_30.models.RoutingServiceBusQueueEndpointProperties] + :ivar service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the + messages to, based on the routing rules. + :vartype service_bus_topics: + list[~azure.mgmt.iothub.v2023_06_30.models.RoutingServiceBusTopicEndpointProperties] + :ivar event_hubs: The list of Event Hubs endpoints that IoT hub routes messages to, based on + the routing rules. This list does not include the built-in Event Hubs endpoint. + :vartype event_hubs: list[~azure.mgmt.iothub.v2023_06_30.models.RoutingEventHubProperties] + :ivar storage_containers: The list of storage container endpoints that IoT hub routes messages + to, based on the routing rules. + :vartype storage_containers: + list[~azure.mgmt.iothub.v2023_06_30.models.RoutingStorageContainerProperties] + :ivar cosmos_db_sql_containers: The list of Cosmos DB container endpoints that IoT hub routes + messages to, based on the routing rules. + :vartype cosmos_db_sql_containers: + list[~azure.mgmt.iothub.v2023_06_30.models.RoutingCosmosDBSqlApiProperties] + """ + + _attribute_map = { + "service_bus_queues": {"key": "serviceBusQueues", "type": "[RoutingServiceBusQueueEndpointProperties]"}, + "service_bus_topics": {"key": "serviceBusTopics", "type": "[RoutingServiceBusTopicEndpointProperties]"}, + "event_hubs": {"key": "eventHubs", "type": "[RoutingEventHubProperties]"}, + "storage_containers": {"key": "storageContainers", "type": "[RoutingStorageContainerProperties]"}, + "cosmos_db_sql_containers": {"key": "cosmosDBSqlContainers", "type": "[RoutingCosmosDBSqlApiProperties]"}, + } + + def __init__( + self, + *, + service_bus_queues: Optional[List["_models.RoutingServiceBusQueueEndpointProperties"]] = None, + service_bus_topics: Optional[List["_models.RoutingServiceBusTopicEndpointProperties"]] = None, + event_hubs: Optional[List["_models.RoutingEventHubProperties"]] = None, + storage_containers: Optional[List["_models.RoutingStorageContainerProperties"]] = None, + cosmos_db_sql_containers: Optional[List["_models.RoutingCosmosDBSqlApiProperties"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the + messages to, based on the routing rules. + :paramtype service_bus_queues: + list[~azure.mgmt.iothub.v2023_06_30.models.RoutingServiceBusQueueEndpointProperties] + :keyword service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes + the messages to, based on the routing rules. + :paramtype service_bus_topics: + list[~azure.mgmt.iothub.v2023_06_30.models.RoutingServiceBusTopicEndpointProperties] + :keyword event_hubs: The list of Event Hubs endpoints that IoT hub routes messages to, based on + the routing rules. This list does not include the built-in Event Hubs endpoint. + :paramtype event_hubs: list[~azure.mgmt.iothub.v2023_06_30.models.RoutingEventHubProperties] + :keyword storage_containers: The list of storage container endpoints that IoT hub routes + messages to, based on the routing rules. + :paramtype storage_containers: + list[~azure.mgmt.iothub.v2023_06_30.models.RoutingStorageContainerProperties] + :keyword cosmos_db_sql_containers: The list of Cosmos DB container endpoints that IoT hub + routes messages to, based on the routing rules. + :paramtype cosmos_db_sql_containers: + list[~azure.mgmt.iothub.v2023_06_30.models.RoutingCosmosDBSqlApiProperties] + """ + super().__init__(**kwargs) + self.service_bus_queues = service_bus_queues + self.service_bus_topics = service_bus_topics + self.event_hubs = event_hubs + self.storage_containers = storage_containers + self.cosmos_db_sql_containers = cosmos_db_sql_containers + + +class RoutingEventHubProperties(_serialization.Model): + """The properties related to an event hub endpoint. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Id of the event hub endpoint. + :vartype id: str + :ivar connection_string: The connection string of the event hub endpoint. + :vartype connection_string: str + :ivar endpoint_uri: The url of the event hub endpoint. It must include the protocol sb://. + :vartype endpoint_uri: str + :ivar entity_path: Event hub name on the event hub namespace. + :vartype entity_path: str + :ivar authentication_type: Method used to authenticate against the event hub endpoint. Known + values are: "keyBased" and "identityBased". + :vartype authentication_type: str or ~azure.mgmt.iothub.v2023_06_30.models.AuthenticationType + :ivar identity: Managed identity properties of routing event hub endpoint. + :vartype identity: ~azure.mgmt.iothub.v2023_06_30.models.ManagedIdentity + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. + :vartype name: str + :ivar subscription_id: The subscription identifier of the event hub endpoint. + :vartype subscription_id: str + :ivar resource_group: The name of the resource group of the event hub endpoint. + :vartype resource_group: str + """ + + _validation = { + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "entity_path": {"key": "entityPath", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + } + + def __init__( + self, + *, + name: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + connection_string: Optional[str] = None, + endpoint_uri: Optional[str] = None, + entity_path: Optional[str] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, + subscription_id: Optional[str] = None, + resource_group: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Id of the event hub endpoint. + :paramtype id: str + :keyword connection_string: The connection string of the event hub endpoint. + :paramtype connection_string: str + :keyword endpoint_uri: The url of the event hub endpoint. It must include the protocol sb://. + :paramtype endpoint_uri: str + :keyword entity_path: Event hub name on the event hub namespace. + :paramtype entity_path: str + :keyword authentication_type: Method used to authenticate against the event hub endpoint. Known + values are: "keyBased" and "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2023_06_30.models.AuthenticationType + :keyword identity: Managed identity properties of routing event hub endpoint. + :paramtype identity: ~azure.mgmt.iothub.v2023_06_30.models.ManagedIdentity + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. + :paramtype name: str + :keyword subscription_id: The subscription identifier of the event hub endpoint. + :paramtype subscription_id: str + :keyword resource_group: The name of the resource group of the event hub endpoint. + :paramtype resource_group: str + """ + super().__init__(**kwargs) + self.id = id + self.connection_string = connection_string + self.endpoint_uri = endpoint_uri + self.entity_path = entity_path + self.authentication_type = authentication_type + self.identity = identity + self.name = name + self.subscription_id = subscription_id + self.resource_group = resource_group + + +class RoutingMessage(_serialization.Model): + """Routing message. + + :ivar body: Body of routing message. + :vartype body: str + :ivar app_properties: App properties. + :vartype app_properties: dict[str, str] + :ivar system_properties: System properties. + :vartype system_properties: dict[str, str] + """ + + _attribute_map = { + "body": {"key": "body", "type": "str"}, + "app_properties": {"key": "appProperties", "type": "{str}"}, + "system_properties": {"key": "systemProperties", "type": "{str}"}, + } + + def __init__( + self, + *, + body: Optional[str] = None, + app_properties: Optional[Dict[str, str]] = None, + system_properties: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword body: Body of routing message. + :paramtype body: str + :keyword app_properties: App properties. + :paramtype app_properties: dict[str, str] + :keyword system_properties: System properties. + :paramtype system_properties: dict[str, str] + """ + super().__init__(**kwargs) + self.body = body + self.app_properties = app_properties + self.system_properties = system_properties + + +class RoutingProperties(_serialization.Model): + """The routing related properties of the IoT hub. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. + + :ivar endpoints: The properties related to the custom endpoints to which your IoT hub routes + messages based on the routing rules. A maximum of 10 custom endpoints are allowed across all + endpoint types for paid hubs and only 1 custom endpoint is allowed across all endpoint types + for free hubs. + :vartype endpoints: ~azure.mgmt.iothub.v2023_06_30.models.RoutingEndpoints + :ivar routes: The list of user-provided routing rules that the IoT hub uses to route messages + to built-in and custom endpoints. A maximum of 100 routing rules are allowed for paid hubs and + a maximum of 5 routing rules are allowed for free hubs. + :vartype routes: list[~azure.mgmt.iothub.v2023_06_30.models.RouteProperties] + :ivar fallback_route: The properties of the route that is used as a fall-back route when none + of the conditions specified in the 'routes' section are met. This is an optional parameter. + When this property is not present in the template, the fallback route is disabled by default. + :vartype fallback_route: ~azure.mgmt.iothub.v2023_06_30.models.FallbackRouteProperties + :ivar enrichments: The list of user-provided enrichments that the IoT hub applies to messages + to be delivered to built-in and custom endpoints. See: https://aka.ms/telemetryoneventgrid. + :vartype enrichments: list[~azure.mgmt.iothub.v2023_06_30.models.EnrichmentProperties] + """ + + _attribute_map = { + "endpoints": {"key": "endpoints", "type": "RoutingEndpoints"}, + "routes": {"key": "routes", "type": "[RouteProperties]"}, + "fallback_route": {"key": "fallbackRoute", "type": "FallbackRouteProperties"}, + "enrichments": {"key": "enrichments", "type": "[EnrichmentProperties]"}, + } + + def __init__( + self, + *, + endpoints: Optional["_models.RoutingEndpoints"] = None, + routes: Optional[List["_models.RouteProperties"]] = None, + fallback_route: Optional["_models.FallbackRouteProperties"] = None, + enrichments: Optional[List["_models.EnrichmentProperties"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword endpoints: The properties related to the custom endpoints to which your IoT hub routes + messages based on the routing rules. A maximum of 10 custom endpoints are allowed across all + endpoint types for paid hubs and only 1 custom endpoint is allowed across all endpoint types + for free hubs. + :paramtype endpoints: ~azure.mgmt.iothub.v2023_06_30.models.RoutingEndpoints + :keyword routes: The list of user-provided routing rules that the IoT hub uses to route + messages to built-in and custom endpoints. A maximum of 100 routing rules are allowed for paid + hubs and a maximum of 5 routing rules are allowed for free hubs. + :paramtype routes: list[~azure.mgmt.iothub.v2023_06_30.models.RouteProperties] + :keyword fallback_route: The properties of the route that is used as a fall-back route when + none of the conditions specified in the 'routes' section are met. This is an optional + parameter. When this property is not present in the template, the fallback route is disabled by + default. + :paramtype fallback_route: ~azure.mgmt.iothub.v2023_06_30.models.FallbackRouteProperties + :keyword enrichments: The list of user-provided enrichments that the IoT hub applies to + messages to be delivered to built-in and custom endpoints. See: + https://aka.ms/telemetryoneventgrid. + :paramtype enrichments: list[~azure.mgmt.iothub.v2023_06_30.models.EnrichmentProperties] + """ + super().__init__(**kwargs) + self.endpoints = endpoints + self.routes = routes + self.fallback_route = fallback_route + self.enrichments = enrichments + + +class RoutingServiceBusQueueEndpointProperties(_serialization.Model): + """The properties related to service bus queue endpoint types. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Id of the service bus queue endpoint. + :vartype id: str + :ivar connection_string: The connection string of the service bus queue endpoint. + :vartype connection_string: str + :ivar endpoint_uri: The url of the service bus queue endpoint. It must include the protocol + sb://. + :vartype endpoint_uri: str + :ivar entity_path: Queue name on the service bus namespace. + :vartype entity_path: str + :ivar authentication_type: Method used to authenticate against the service bus queue endpoint. + Known values are: "keyBased" and "identityBased". + :vartype authentication_type: str or ~azure.mgmt.iothub.v2023_06_30.models.AuthenticationType + :ivar identity: Managed identity properties of routing service bus queue endpoint. + :vartype identity: ~azure.mgmt.iothub.v2023_06_30.models.ManagedIdentity + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual queue name. Required. + :vartype name: str + :ivar subscription_id: The subscription identifier of the service bus queue endpoint. + :vartype subscription_id: str + :ivar resource_group: The name of the resource group of the service bus queue endpoint. + :vartype resource_group: str + """ + + _validation = { + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "entity_path": {"key": "entityPath", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + } + + def __init__( + self, + *, + name: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + connection_string: Optional[str] = None, + endpoint_uri: Optional[str] = None, + entity_path: Optional[str] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, + subscription_id: Optional[str] = None, + resource_group: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Id of the service bus queue endpoint. + :paramtype id: str + :keyword connection_string: The connection string of the service bus queue endpoint. + :paramtype connection_string: str + :keyword endpoint_uri: The url of the service bus queue endpoint. It must include the protocol + sb://. + :paramtype endpoint_uri: str + :keyword entity_path: Queue name on the service bus namespace. + :paramtype entity_path: str + :keyword authentication_type: Method used to authenticate against the service bus queue + endpoint. Known values are: "keyBased" and "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2023_06_30.models.AuthenticationType + :keyword identity: Managed identity properties of routing service bus queue endpoint. + :paramtype identity: ~azure.mgmt.iothub.v2023_06_30.models.ManagedIdentity + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual queue name. Required. + :paramtype name: str + :keyword subscription_id: The subscription identifier of the service bus queue endpoint. + :paramtype subscription_id: str + :keyword resource_group: The name of the resource group of the service bus queue endpoint. + :paramtype resource_group: str + """ + super().__init__(**kwargs) + self.id = id + self.connection_string = connection_string + self.endpoint_uri = endpoint_uri + self.entity_path = entity_path + self.authentication_type = authentication_type + self.identity = identity + self.name = name + self.subscription_id = subscription_id + self.resource_group = resource_group + + +class RoutingServiceBusTopicEndpointProperties(_serialization.Model): + """The properties related to service bus topic endpoint types. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Id of the service bus topic endpoint. + :vartype id: str + :ivar connection_string: The connection string of the service bus topic endpoint. + :vartype connection_string: str + :ivar endpoint_uri: The url of the service bus topic endpoint. It must include the protocol + sb://. + :vartype endpoint_uri: str + :ivar entity_path: Queue name on the service bus topic. + :vartype entity_path: str + :ivar authentication_type: Method used to authenticate against the service bus topic endpoint. + Known values are: "keyBased" and "identityBased". + :vartype authentication_type: str or ~azure.mgmt.iothub.v2023_06_30.models.AuthenticationType + :ivar identity: Managed identity properties of routing service bus topic endpoint. + :vartype identity: ~azure.mgmt.iothub.v2023_06_30.models.ManagedIdentity + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual topic name. + Required. + :vartype name: str + :ivar subscription_id: The subscription identifier of the service bus topic endpoint. + :vartype subscription_id: str + :ivar resource_group: The name of the resource group of the service bus topic endpoint. + :vartype resource_group: str + """ + + _validation = { + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "entity_path": {"key": "entityPath", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + } + + def __init__( + self, + *, + name: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + connection_string: Optional[str] = None, + endpoint_uri: Optional[str] = None, + entity_path: Optional[str] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, + subscription_id: Optional[str] = None, + resource_group: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Id of the service bus topic endpoint. + :paramtype id: str + :keyword connection_string: The connection string of the service bus topic endpoint. + :paramtype connection_string: str + :keyword endpoint_uri: The url of the service bus topic endpoint. It must include the protocol + sb://. + :paramtype endpoint_uri: str + :keyword entity_path: Queue name on the service bus topic. + :paramtype entity_path: str + :keyword authentication_type: Method used to authenticate against the service bus topic + endpoint. Known values are: "keyBased" and "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2023_06_30.models.AuthenticationType + :keyword identity: Managed identity properties of routing service bus topic endpoint. + :paramtype identity: ~azure.mgmt.iothub.v2023_06_30.models.ManagedIdentity + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual topic name. + Required. + :paramtype name: str + :keyword subscription_id: The subscription identifier of the service bus topic endpoint. + :paramtype subscription_id: str + :keyword resource_group: The name of the resource group of the service bus topic endpoint. + :paramtype resource_group: str + """ + super().__init__(**kwargs) + self.id = id + self.connection_string = connection_string + self.endpoint_uri = endpoint_uri + self.entity_path = entity_path + self.authentication_type = authentication_type + self.identity = identity + self.name = name + self.subscription_id = subscription_id + self.resource_group = resource_group + + +class RoutingStorageContainerProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes + """The properties related to a storage container endpoint. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Id of the storage container endpoint. + :vartype id: str + :ivar connection_string: The connection string of the storage account. + :vartype connection_string: str + :ivar endpoint_uri: The url of the storage endpoint. It must include the protocol https://. + :vartype endpoint_uri: str + :ivar authentication_type: Method used to authenticate against the storage endpoint. Known + values are: "keyBased" and "identityBased". + :vartype authentication_type: str or ~azure.mgmt.iothub.v2023_06_30.models.AuthenticationType + :ivar identity: Managed identity properties of routing storage endpoint. + :vartype identity: ~azure.mgmt.iothub.v2023_06_30.models.ManagedIdentity + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. + :vartype name: str + :ivar subscription_id: The subscription identifier of the storage account. + :vartype subscription_id: str + :ivar resource_group: The name of the resource group of the storage account. + :vartype resource_group: str + :ivar container_name: The name of storage container in the storage account. Required. + :vartype container_name: str + :ivar file_name_format: File name format for the blob. Default format is + {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be + reordered. + :vartype file_name_format: str + :ivar batch_frequency_in_seconds: Time interval at which blobs are written to storage. Value + should be between 60 and 720 seconds. Default value is 300 seconds. + :vartype batch_frequency_in_seconds: int + :ivar max_chunk_size_in_bytes: Maximum number of bytes for each blob written to storage. Value + should be between 10485760(10MB) and 524288000(500MB). Default value is 314572800(300MB). + :vartype max_chunk_size_in_bytes: int + :ivar encoding: Encoding that is used to serialize messages to blobs. Supported values are + 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Known values are: "Avro", + "AvroDeflate", and "JSON". + :vartype encoding: str or + ~azure.mgmt.iothub.v2023_06_30.models.RoutingStorageContainerPropertiesEncoding + """ + + _validation = { + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "container_name": {"required": True}, + "batch_frequency_in_seconds": {"maximum": 720, "minimum": 60}, + "max_chunk_size_in_bytes": {"maximum": 524288000, "minimum": 10485760}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "file_name_format": {"key": "fileNameFormat", "type": "str"}, + "batch_frequency_in_seconds": {"key": "batchFrequencyInSeconds", "type": "int"}, + "max_chunk_size_in_bytes": {"key": "maxChunkSizeInBytes", "type": "int"}, + "encoding": {"key": "encoding", "type": "str"}, + } + + def __init__( + self, + *, + name: str, + container_name: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + connection_string: Optional[str] = None, + endpoint_uri: Optional[str] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, + subscription_id: Optional[str] = None, + resource_group: Optional[str] = None, + file_name_format: Optional[str] = None, + batch_frequency_in_seconds: Optional[int] = None, + max_chunk_size_in_bytes: Optional[int] = None, + encoding: Optional[Union[str, "_models.RoutingStorageContainerPropertiesEncoding"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Id of the storage container endpoint. + :paramtype id: str + :keyword connection_string: The connection string of the storage account. + :paramtype connection_string: str + :keyword endpoint_uri: The url of the storage endpoint. It must include the protocol https://. + :paramtype endpoint_uri: str + :keyword authentication_type: Method used to authenticate against the storage endpoint. Known + values are: "keyBased" and "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2023_06_30.models.AuthenticationType + :keyword identity: Managed identity properties of routing storage endpoint. + :paramtype identity: ~azure.mgmt.iothub.v2023_06_30.models.ManagedIdentity + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. + :paramtype name: str + :keyword subscription_id: The subscription identifier of the storage account. + :paramtype subscription_id: str + :keyword resource_group: The name of the resource group of the storage account. + :paramtype resource_group: str + :keyword container_name: The name of storage container in the storage account. Required. + :paramtype container_name: str + :keyword file_name_format: File name format for the blob. Default format is + {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be + reordered. + :paramtype file_name_format: str + :keyword batch_frequency_in_seconds: Time interval at which blobs are written to storage. Value + should be between 60 and 720 seconds. Default value is 300 seconds. + :paramtype batch_frequency_in_seconds: int + :keyword max_chunk_size_in_bytes: Maximum number of bytes for each blob written to storage. + Value should be between 10485760(10MB) and 524288000(500MB). Default value is 314572800(300MB). + :paramtype max_chunk_size_in_bytes: int + :keyword encoding: Encoding that is used to serialize messages to blobs. Supported values are + 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Known values are: "Avro", + "AvroDeflate", and "JSON". + :paramtype encoding: str or + ~azure.mgmt.iothub.v2023_06_30.models.RoutingStorageContainerPropertiesEncoding + """ + super().__init__(**kwargs) + self.id = id + self.connection_string = connection_string + self.endpoint_uri = endpoint_uri + self.authentication_type = authentication_type + self.identity = identity + self.name = name + self.subscription_id = subscription_id + self.resource_group = resource_group + self.container_name = container_name + self.file_name_format = file_name_format + self.batch_frequency_in_seconds = batch_frequency_in_seconds + self.max_chunk_size_in_bytes = max_chunk_size_in_bytes + self.encoding = encoding + + +class RoutingTwin(_serialization.Model): + """Twin reference input parameter. This is an optional parameter. + + :ivar tags: Twin Tags. + :vartype tags: JSON + :ivar properties: + :vartype properties: ~azure.mgmt.iothub.v2023_06_30.models.RoutingTwinProperties + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "object"}, + "properties": {"key": "properties", "type": "RoutingTwinProperties"}, + } + + def __init__( + self, + *, + tags: Optional[JSON] = None, + properties: Optional["_models.RoutingTwinProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Twin Tags. + :paramtype tags: JSON + :keyword properties: + :paramtype properties: ~azure.mgmt.iothub.v2023_06_30.models.RoutingTwinProperties + """ + super().__init__(**kwargs) + self.tags = tags + self.properties = properties + + +class RoutingTwinProperties(_serialization.Model): + """RoutingTwinProperties. + + :ivar desired: Twin desired properties. + :vartype desired: JSON + :ivar reported: Twin desired properties. + :vartype reported: JSON + """ + + _attribute_map = { + "desired": {"key": "desired", "type": "object"}, + "reported": {"key": "reported", "type": "object"}, + } + + def __init__(self, *, desired: Optional[JSON] = None, reported: Optional[JSON] = None, **kwargs: Any) -> None: + """ + :keyword desired: Twin desired properties. + :paramtype desired: JSON + :keyword reported: Twin desired properties. + :paramtype reported: JSON + """ + super().__init__(**kwargs) + self.desired = desired + self.reported = reported + + +class SharedAccessSignatureAuthorizationRule(_serialization.Model): + """The properties of an IoT hub shared access policy. + + All required parameters must be populated in order to send to Azure. + + :ivar key_name: The name of the shared access policy. Required. + :vartype key_name: str + :ivar primary_key: The primary key. + :vartype primary_key: str + :ivar secondary_key: The secondary key. + :vartype secondary_key: str + :ivar rights: The permissions assigned to the shared access policy. Required. Known values are: + "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, + ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", + "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", + "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :vartype rights: str or ~azure.mgmt.iothub.v2023_06_30.models.AccessRights + """ + + _validation = { + "key_name": {"required": True}, + "rights": {"required": True}, + } + + _attribute_map = { + "key_name": {"key": "keyName", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "rights": {"key": "rights", "type": "str"}, + } + + def __init__( + self, + *, + key_name: str, + rights: Union[str, "_models.AccessRights"], + primary_key: Optional[str] = None, + secondary_key: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword key_name: The name of the shared access policy. Required. + :paramtype key_name: str + :keyword primary_key: The primary key. + :paramtype primary_key: str + :keyword secondary_key: The secondary key. + :paramtype secondary_key: str + :keyword rights: The permissions assigned to the shared access policy. Required. Known values + are: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, + ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", + "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", + "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :paramtype rights: str or ~azure.mgmt.iothub.v2023_06_30.models.AccessRights + """ + super().__init__(**kwargs) + self.key_name = key_name + self.primary_key = primary_key + self.secondary_key = secondary_key + self.rights = rights + + +class SharedAccessSignatureAuthorizationRuleListResult(_serialization.Model): + """The list of shared access policies with a next link. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of shared access policies. + :vartype value: + list[~azure.mgmt.iothub.v2023_06_30.models.SharedAccessSignatureAuthorizationRule] + :ivar next_link: The next link. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The list of shared access policies. + :paramtype value: + list[~azure.mgmt.iothub.v2023_06_30.models.SharedAccessSignatureAuthorizationRule] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class StorageEndpointProperties(_serialization.Model): + """The properties of the Azure Storage endpoint for file upload. + + All required parameters must be populated in order to send to Azure. + + :ivar sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + file upload is valid. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. + :vartype sas_ttl_as_iso8601: ~datetime.timedelta + :ivar connection_string: The connection string for the Azure Storage account to which files are + uploaded. Required. + :vartype connection_string: str + :ivar container_name: The name of the root container where you upload files. The container need + not exist but should be creatable using the connectionString specified. Required. + :vartype container_name: str + :ivar authentication_type: Specifies authentication type being used for connecting to the + storage account. Known values are: "keyBased" and "identityBased". + :vartype authentication_type: str or ~azure.mgmt.iothub.v2023_06_30.models.AuthenticationType + :ivar identity: Managed identity properties of storage endpoint for file upload. + :vartype identity: ~azure.mgmt.iothub.v2023_06_30.models.ManagedIdentity + """ + + _validation = { + "connection_string": {"required": True}, + "container_name": {"required": True}, + } + + _attribute_map = { + "sas_ttl_as_iso8601": {"key": "sasTtlAsIso8601", "type": "duration"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + } + + def __init__( + self, + *, + connection_string: str, + container_name: str, + sas_ttl_as_iso8601: Optional[datetime.timedelta] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, + **kwargs: Any + ) -> None: + """ + :keyword sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + file upload is valid. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. + :paramtype sas_ttl_as_iso8601: ~datetime.timedelta + :keyword connection_string: The connection string for the Azure Storage account to which files + are uploaded. Required. + :paramtype connection_string: str + :keyword container_name: The name of the root container where you upload files. The container + need not exist but should be creatable using the connectionString specified. Required. + :paramtype container_name: str + :keyword authentication_type: Specifies authentication type being used for connecting to the + storage account. Known values are: "keyBased" and "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2023_06_30.models.AuthenticationType + :keyword identity: Managed identity properties of storage endpoint for file upload. + :paramtype identity: ~azure.mgmt.iothub.v2023_06_30.models.ManagedIdentity + """ + super().__init__(**kwargs) + self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 + self.connection_string = connection_string + self.container_name = container_name + self.authentication_type = authentication_type + self.identity = identity + + +class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.iothub.v2023_06_30.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.iothub.v2023_06_30.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or ~azure.mgmt.iothub.v2023_06_30.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.iothub.v2023_06_30.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class TagsResource(_serialization.Model): + """A container holding only the Tags for a resource, allowing the user to update the tags on an + IoT Hub instance. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags + + +class TestAllRoutesInput(_serialization.Model): + """Input for testing all routes. + + :ivar routing_source: Routing source. Known values are: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and + "DeviceConnectionStateEvents". + :vartype routing_source: str or ~azure.mgmt.iothub.v2023_06_30.models.RoutingSource + :ivar message: Routing message. + :vartype message: ~azure.mgmt.iothub.v2023_06_30.models.RoutingMessage + :ivar twin: Routing Twin Reference. + :vartype twin: ~azure.mgmt.iothub.v2023_06_30.models.RoutingTwin + """ + + _attribute_map = { + "routing_source": {"key": "routingSource", "type": "str"}, + "message": {"key": "message", "type": "RoutingMessage"}, + "twin": {"key": "twin", "type": "RoutingTwin"}, + } + + def __init__( + self, + *, + routing_source: Optional[Union[str, "_models.RoutingSource"]] = None, + message: Optional["_models.RoutingMessage"] = None, + twin: Optional["_models.RoutingTwin"] = None, + **kwargs: Any + ) -> None: + """ + :keyword routing_source: Routing source. Known values are: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", and + "DeviceConnectionStateEvents". + :paramtype routing_source: str or ~azure.mgmt.iothub.v2023_06_30.models.RoutingSource + :keyword message: Routing message. + :paramtype message: ~azure.mgmt.iothub.v2023_06_30.models.RoutingMessage + :keyword twin: Routing Twin Reference. + :paramtype twin: ~azure.mgmt.iothub.v2023_06_30.models.RoutingTwin + """ + super().__init__(**kwargs) + self.routing_source = routing_source + self.message = message + self.twin = twin + + +class TestAllRoutesResult(_serialization.Model): + """Result of testing all routes. + + :ivar routes: JSON-serialized array of matched routes. + :vartype routes: list[~azure.mgmt.iothub.v2023_06_30.models.MatchedRoute] + """ + + _attribute_map = { + "routes": {"key": "routes", "type": "[MatchedRoute]"}, + } + + def __init__(self, *, routes: Optional[List["_models.MatchedRoute"]] = None, **kwargs: Any) -> None: + """ + :keyword routes: JSON-serialized array of matched routes. + :paramtype routes: list[~azure.mgmt.iothub.v2023_06_30.models.MatchedRoute] + """ + super().__init__(**kwargs) + self.routes = routes + + +class TestRouteInput(_serialization.Model): + """Input for testing route. + + All required parameters must be populated in order to send to Azure. + + :ivar message: Routing message. + :vartype message: ~azure.mgmt.iothub.v2023_06_30.models.RoutingMessage + :ivar route: Route properties. Required. + :vartype route: ~azure.mgmt.iothub.v2023_06_30.models.RouteProperties + :ivar twin: Routing Twin Reference. + :vartype twin: ~azure.mgmt.iothub.v2023_06_30.models.RoutingTwin + """ + + _validation = { + "route": {"required": True}, + } + + _attribute_map = { + "message": {"key": "message", "type": "RoutingMessage"}, + "route": {"key": "route", "type": "RouteProperties"}, + "twin": {"key": "twin", "type": "RoutingTwin"}, + } + + def __init__( + self, + *, + route: "_models.RouteProperties", + message: Optional["_models.RoutingMessage"] = None, + twin: Optional["_models.RoutingTwin"] = None, + **kwargs: Any + ) -> None: + """ + :keyword message: Routing message. + :paramtype message: ~azure.mgmt.iothub.v2023_06_30.models.RoutingMessage + :keyword route: Route properties. Required. + :paramtype route: ~azure.mgmt.iothub.v2023_06_30.models.RouteProperties + :keyword twin: Routing Twin Reference. + :paramtype twin: ~azure.mgmt.iothub.v2023_06_30.models.RoutingTwin + """ + super().__init__(**kwargs) + self.message = message + self.route = route + self.twin = twin + + +class TestRouteResult(_serialization.Model): + """Result of testing one route. + + :ivar result: Result of testing route. Known values are: "undefined", "false", and "true". + :vartype result: str or ~azure.mgmt.iothub.v2023_06_30.models.TestResultStatus + :ivar details: Detailed result of testing route. + :vartype details: ~azure.mgmt.iothub.v2023_06_30.models.TestRouteResultDetails + """ + + _attribute_map = { + "result": {"key": "result", "type": "str"}, + "details": {"key": "details", "type": "TestRouteResultDetails"}, + } + + def __init__( + self, + *, + result: Optional[Union[str, "_models.TestResultStatus"]] = None, + details: Optional["_models.TestRouteResultDetails"] = None, + **kwargs: Any + ) -> None: + """ + :keyword result: Result of testing route. Known values are: "undefined", "false", and "true". + :paramtype result: str or ~azure.mgmt.iothub.v2023_06_30.models.TestResultStatus + :keyword details: Detailed result of testing route. + :paramtype details: ~azure.mgmt.iothub.v2023_06_30.models.TestRouteResultDetails + """ + super().__init__(**kwargs) + self.result = result + self.details = details + + +class TestRouteResultDetails(_serialization.Model): + """Detailed result of testing a route. + + :ivar compilation_errors: JSON-serialized list of route compilation errors. + :vartype compilation_errors: list[~azure.mgmt.iothub.v2023_06_30.models.RouteCompilationError] + """ + + _attribute_map = { + "compilation_errors": {"key": "compilationErrors", "type": "[RouteCompilationError]"}, + } + + def __init__( + self, *, compilation_errors: Optional[List["_models.RouteCompilationError"]] = None, **kwargs: Any + ) -> None: + """ + :keyword compilation_errors: JSON-serialized list of route compilation errors. + :paramtype compilation_errors: + list[~azure.mgmt.iothub.v2023_06_30.models.RouteCompilationError] + """ + super().__init__(**kwargs) + self.compilation_errors = compilation_errors + + +class UserSubscriptionQuota(_serialization.Model): + """User subscription quota response. + + :ivar id: IotHub type id. + :vartype id: str + :ivar type: Response type. + :vartype type: str + :ivar unit: Unit of IotHub type. + :vartype unit: str + :ivar current_value: Current number of IotHub type. + :vartype current_value: int + :ivar limit: Numerical limit on IotHub type. + :vartype limit: int + :ivar name: IotHub type. + :vartype name: ~azure.mgmt.iothub.v2023_06_30.models.Name + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "Name"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + type: Optional[str] = None, + unit: Optional[str] = None, + current_value: Optional[int] = None, + limit: Optional[int] = None, + name: Optional["_models.Name"] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: IotHub type id. + :paramtype id: str + :keyword type: Response type. + :paramtype type: str + :keyword unit: Unit of IotHub type. + :paramtype unit: str + :keyword current_value: Current number of IotHub type. + :paramtype current_value: int + :keyword limit: Numerical limit on IotHub type. + :paramtype limit: int + :keyword name: IotHub type. + :paramtype name: ~azure.mgmt.iothub.v2023_06_30.models.Name + """ + super().__init__(**kwargs) + self.id = id + self.type = type + self.unit = unit + self.current_value = current_value + self.limit = limit + self.name = name + + +class UserSubscriptionQuotaListResult(_serialization.Model): + """Json-serialized array of User subscription quota response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: + :vartype value: list[~azure.mgmt.iothub.v2023_06_30.models.UserSubscriptionQuota] + :ivar next_link: + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[UserSubscriptionQuota]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.UserSubscriptionQuota"]] = None, **kwargs: Any) -> None: + """ + :keyword value: + :paramtype value: list[~azure.mgmt.iothub.v2023_06_30.models.UserSubscriptionQuota] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/models/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/__init__.py new file mode 100644 index 000000000000..96fcc782e2e1 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/__init__.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations import Operations +from ._iot_hub_resource_operations import IotHubResourceOperations +from ._resource_provider_common_operations import ResourceProviderCommonOperations +from ._certificates_operations import CertificatesOperations +from ._iot_hub_operations import IotHubOperations +from ._private_link_resources_operations import PrivateLinkResourcesOperations +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "Operations", + "IotHubResourceOperations", + "ResourceProviderCommonOperations", + "CertificatesOperations", + "IotHubOperations", + "PrivateLinkResourcesOperations", + "PrivateEndpointConnectionsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_certificates_operations.py new file mode 100644 index 000000000000..f516b0f9ea6f --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_certificates_operations.py @@ -0,0 +1,913 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_iot_hub_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, resource_name: str, certificate_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + resource_name: str, + certificate_name: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + resource_name: str, + certificate_name: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_generate_verification_code_request( + resource_group_name: str, + resource_name: str, + certificate_name: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_verify_request( + resource_group_name: str, + resource_name: str, + certificate_name: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30.IotHubClient`'s + :attr:`certificates` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_by_iot_hub( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: + """Get the certificate list. + + Returns the list of certificates. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateListDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateListDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) + + request = build_list_by_iot_hub_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateListDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_iot_hub.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates" + } + + @distributed_trace + def get( + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: + """Get the certificate. + + Returns the certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: Union[_models.CertificateDescription, IO], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Is either a CertificateDescription type + or a IO type. Required. + :type certificate_description: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription or + IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IOBase, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateDescription") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CertificateDescription", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("CertificateDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}" + } + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> None: + """Delete an X509 certificate. + + Deletes an existing X509 certificate or does nothing if it does not exist. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}" + } + + @distributed_trace + def generate_verification_code( + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: + """Generate verification code for proof of possession flow. + + Generates verification code for proof of possession flow. The verification code will be used to + generate a leaf certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateWithNonceDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateWithNonceDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) + + request = build_generate_verification_code_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + generate_verification_code.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode" + } + + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2023_06_30.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Is either a + CertificateVerificationDescription type or a IO type. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2023_06_30.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IOBase, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") + + request = build_verify_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + verify.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify" + } diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_iot_hub_operations.py new file mode 100644 index 000000000000..e8500722b4b5 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_iot_hub_operations.py @@ -0,0 +1,326 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_manual_failover_request( + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover", + ) # pylint: disable=line-too-long + path_format_arguments = { + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class IotHubOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30.IotHubClient`'s + :attr:`iot_hub` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + def _manual_failover_initial( # pylint: disable=inconsistent-return-statements + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: Union[_models.FailoverInput, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(failover_input, (IOBase, bytes)): + _content = failover_input + else: + _json = self._serialize.body(failover_input, "FailoverInput") + + request = build_manual_failover_request( + iot_hub_name=iot_hub_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._manual_failover_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _manual_failover_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover" + } + + @overload + def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: _models.FailoverInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: ~azure.mgmt.iothub.v2023_06_30.models.FailoverInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: Union[_models.FailoverInput, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Is either a FailoverInput type or a IO type. Required. + :type failover_input: ~azure.mgmt.iothub.v2023_06_30.models.FailoverInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._manual_failover_initial( # type: ignore + iot_hub_name=iot_hub_name, + resource_group_name=resource_group_name, + failover_input=failover_input, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_manual_failover.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover" + } diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_iot_hub_resource_operations.py new file mode 100644 index 000000000000..fa4564dc2011 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_iot_hub_resource_operations.py @@ -0,0 +1,3464 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, *, if_match: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_stats_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_valid_skus_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_event_hub_consumer_groups_request( + resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_event_hub_consumer_group_request( + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_event_hub_consumer_group_request( + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_event_hub_consumer_group_request( + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_jobs_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_job_request( + resource_group_name: str, resource_name: str, job_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "jobId": _SERIALIZER.url("job_id", job_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_quota_metrics_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_endpoint_health_request( + resource_group_name: str, iot_hub_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_test_all_routes_request( + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall", + ) # pylint: disable=line-too-long + path_format_arguments = { + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_test_route_request( + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew", + ) # pylint: disable=line-too-long + path_format_arguments = { + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_keys_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_keys_for_key_name_request( + resource_group_name: str, resource_name: str, key_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_export_devices_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_import_devices_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30.IotHubClient`'s + :attr:`iot_hub_resource` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: + """Get the non-security related metadata of an IoT hub. + + Get the non-security related metadata of an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + def _create_or_update_initial( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: Union[_models.IotHubDescription, IO], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.IotHubDescription: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IOBase, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: _models.IotHubDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: Union[_models.IotHubDescription, IO], + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. If certain properties are missing in the JSON, + updating IoT Hub may cause these values to fallback to default, which may lead to unexpected + behavior. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a + IotHubDescription type or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription or IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + iot_hub_description=iot_hub_description, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("IotHubDescription", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + def _update_initial( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.IotHubDescription: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_tags, (IOBase, bytes)): + _content = iot_hub_tags + else: + _json = self._serialize.body(iot_hub_tags, "TagsResource") + + request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: _models.TagsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2023_06_30.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Is either a + TagsResource type or a IO type. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2023_06_30.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + iot_hub_tags=iot_hub_tags, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("IotHubDescription", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + def _delete_initial( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if response.status_code == 404: + deserialized = self._deserialize("ErrorDetails", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Delete an IoT hub. + + Delete an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or An instance of + LROPoller that returns either ErrorDetails or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription] + or ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2023_06_30.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("IotHubDescription", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: + """Get all the IoT hubs in a subscription. + + Get all the IoT hubs in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: + """Get all the IoT hubs in a resource group. + + Get all the IoT hubs in a resource group. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs" + } + + @distributed_trace + def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.RegistryStatistics: + """Get the statistics from an IoT hub. + + Get the statistics from an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RegistryStatistics or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.RegistryStatistics + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) + + request = build_get_stats_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegistryStatistics", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_stats.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats" + } + + @distributed_trace + def get_valid_skus( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescription"]: + """Get the list of valid SKUs for an IoT hub. + + Get the list of valid SKUs for an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IotHubSkuDescription or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2023_06_30.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_get_valid_skus_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + get_valid_skus.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus" + } + + @distributed_trace + def list_event_hub_consumer_groups( + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> Iterable["_models.EventHubConsumerGroupInfo"]: + """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an + IoT hub. + + Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an + IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. + :type event_hub_endpoint_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_event_hub_consumer_groups_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_event_hub_consumer_groups.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups" + } + + @distributed_trace + def get_event_hub_consumer_group( + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. + + Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to retrieve. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) + + request = build_get_event_hub_consumer_group_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_event_hub_consumer_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}" + } + + @overload + def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: _models.EventHubConsumerGroupBodyDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Required. + :type consumer_group_body: + ~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupBodyDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Required. + :type consumer_group_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: Union[_models.EventHubConsumerGroupBodyDescription, IO], + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Is either a + EventHubConsumerGroupBodyDescription type or a IO type. Required. + :type consumer_group_body: + ~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupBodyDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(consumer_group_body, (IOBase, bytes)): + _content = consumer_group_body + else: + _json = self._serialize.body(consumer_group_body, "EventHubConsumerGroupBodyDescription") + + request = build_create_event_hub_consumer_group_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_event_hub_consumer_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}" + } + + @distributed_trace + def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> None: + """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + + Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to delete. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_event_hub_consumer_group_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_event_hub_consumer_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}" + } + + @distributed_trace + def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterable["_models.JobResponse"]: + """Get a list of all the jobs in an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + + Get a list of all the jobs in an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either JobResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2023_06_30.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_jobs_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("JobResponseListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_jobs.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs" + } + + @distributed_trace + def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any) -> _models.JobResponse: + """Get the details of a job from an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + + Get the details of a job from an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param job_id: The job identifier. Required. + :type job_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) + + request = build_get_job_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("JobResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_job.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}" + } + + @distributed_trace + def get_quota_metrics( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfo"]: + """Get the quota metrics for an IoT hub. + + Get the quota metrics for an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2023_06_30.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_get_quota_metrics_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + get_quota_metrics.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics" + } + + @distributed_trace + def get_endpoint_health( + self, resource_group_name: str, iot_hub_name: str, **kwargs: Any + ) -> Iterable["_models.EndpointHealthData"]: + """Get the health for routing endpoints. + + Get the health for routing endpoints. + + :param resource_group_name: Required. + :type resource_group_name: str + :param iot_hub_name: Required. + :type iot_hub_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EndpointHealthData or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2023_06_30.models.EndpointHealthData] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_get_endpoint_health_request( + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_endpoint_health.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("EndpointHealthDataListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + get_endpoint_health.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth" + } + + @overload + def check_name_availability( + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2023_06_30.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a OperationInputs type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2023_06_30.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IOBase, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability" + } + + @overload + def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: _models.TestAllRoutesInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: ~azure.mgmt.iothub.v2023_06_30.models.TestAllRoutesInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def test_all_routes( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestAllRoutesInput, IO], **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Is either a TestAllRoutesInput type or a IO type. + Required. + :type input: ~azure.mgmt.iothub.v2023_06_30.models.TestAllRoutesInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IOBase, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestAllRoutesInput") + + request = build_test_all_routes_request( + iot_hub_name=iot_hub_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.test_all_routes.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestAllRoutesResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + test_all_routes.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall" + } + + @overload + def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: _models.TestRouteInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: ~azure.mgmt.iothub.v2023_06_30.models.TestRouteInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def test_route( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestRouteInput, IO], **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Is either a TestRouteInput type or a IO type. + Required. + :type input: ~azure.mgmt.iothub.v2023_06_30.models.TestRouteInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IOBase, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestRouteInput") + + request = build_test_route_request( + iot_hub_name=iot_hub_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.test_route.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestRouteResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + test_route.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew" + } + + @distributed_trace + def list_keys( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRule"]: + """Get the security metadata for an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + + Get the security metadata for an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2023_06_30.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_keys_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys" + } + + @distributed_trace + def get_keys_for_key_name( + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: + """Get a shared access policy by name from an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + + Get a shared access policy by name from an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param key_name: The name of the shared access policy. Required. + :type key_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.SharedAccessSignatureAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) + + request = build_get_keys_for_key_name_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_keys_for_key_name.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys" + } + + @overload + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: ~azure.mgmt.iothub.v2023_06_30.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a ExportDevicesRequest type or a IO type. Required. + :type export_devices_parameters: ~azure.mgmt.iothub.v2023_06_30.models.ExportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IOBase, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") + + request = build_export_devices_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("JobResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + export_devices.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices" + } + + @overload + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: ~azure.mgmt.iothub.v2023_06_30.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a ImportDevicesRequest type or a IO type. Required. + :type import_devices_parameters: ~azure.mgmt.iothub.v2023_06_30.models.ImportDevicesRequest or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IOBase, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") + + request = build_import_devices_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("JobResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + import_devices.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices" + } diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_operations.py new file mode 100644 index 000000000000..2c88c2a7ed50 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_operations.py @@ -0,0 +1,156 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Devices/operations") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30.IotHubClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: + """Lists all of the available IoT Hub REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2023_06_30.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..cafcae2edd65 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,727 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30.IotHubClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> List[_models.PrivateEndpointConnection]: + """List private endpoint connections. + + List private endpoint connection properties. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of PrivateEndpointConnection or the result of cls(response) + :rtype: list[~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + + request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("[PrivateEndpointConnection]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections" + } + + @distributed_trace + def get( + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Get private endpoint connection. + + Get private endpoint connection properties. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + def _update_initial( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IOBase, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. + :type private_endpoint_connection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. Is + either a PrivateEndpointConnection type or a IO type. Required. + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpointConnection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + private_endpoint_connection=private_endpoint_connection, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + def _delete_initial( + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Optional[_models.PrivateEndpointConnection]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Delete private endpoint connection. + + Delete private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..7785ebf42b5d --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_private_link_resources_operations.py @@ -0,0 +1,251 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, resource_name: str, group_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "groupId": _SERIALIZER.url("group_id", group_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30.IotHubClient`'s + :attr:`private_link_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: + """List private link resources. + + List private link resources for the given IotHub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkResources or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.PrivateLinkResources + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.PrivateLinkResources] = kwargs.pop("cls", None) + + request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResources", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources" + } + + @distributed_trace + def get( + self, resource_group_name: str, resource_name: str, group_id: str, **kwargs: Any + ) -> _models.GroupIdInformation: + """Get the specified private link resource. + + Get the specified private link resource for the given IotHub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param group_id: The name of the private link resource. Required. + :type group_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GroupIdInformation or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.GroupIdInformation + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + group_id=group_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GroupIdInformation", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}" + } diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_resource_provider_common_operations.py new file mode 100644 index 000000000000..74aee0e9c482 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_resource_provider_common_operations.py @@ -0,0 +1,135 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ResourceProviderCommonOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30.IotHubClient`'s + :attr:`resource_provider_common` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: + """Get the number of iot hubs in the subscription. + + Get the number of free and paid iot hubs in the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UserSubscriptionQuotaListResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30.models.UserSubscriptionQuotaListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) + + request = build_get_subscription_quota_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_subscription_quota.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UserSubscriptionQuotaListResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_subscription_quota.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages"} diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/py.typed b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/__init__.py new file mode 100644 index 000000000000..c6c8f9fc0a14 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/__init__.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._iot_hub_client import IotHubClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "IotHubClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/_configuration.py new file mode 100644 index 000000000000..563538274d3c --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/_configuration.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for IotHubClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The subscription identifier. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2023-06-30-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-06-30-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/_iot_hub_client.py new file mode 100644 index 000000000000..04e99d389420 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/_iot_hub_client.py @@ -0,0 +1,133 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import IotHubClientConfiguration +from .operations import ( + CertificatesOperations, + IotHubOperations, + IotHubResourceOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + ResourceProviderCommonOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """Use this API to manage the IoT hubs in your Azure subscription. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.iothub.v2023_06_30_preview.operations.Operations + :ivar iot_hub_resource: IotHubResourceOperations operations + :vartype iot_hub_resource: + azure.mgmt.iothub.v2023_06_30_preview.operations.IotHubResourceOperations + :ivar resource_provider_common: ResourceProviderCommonOperations operations + :vartype resource_provider_common: + azure.mgmt.iothub.v2023_06_30_preview.operations.ResourceProviderCommonOperations + :ivar certificates: CertificatesOperations operations + :vartype certificates: azure.mgmt.iothub.v2023_06_30_preview.operations.CertificatesOperations + :ivar iot_hub: IotHubOperations operations + :vartype iot_hub: azure.mgmt.iothub.v2023_06_30_preview.operations.IotHubOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.iothub.v2023_06_30_preview.operations.PrivateLinkResourcesOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.iothub.v2023_06_30_preview.operations.PrivateEndpointConnectionsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The subscription identifier. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2023-06-30-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize, "2023-06-30-preview" + ) + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-06-30-preview" + ) + self.resource_provider_common = ResourceProviderCommonOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-06-30-preview" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-06-30-preview" + ) + self.iot_hub = IotHubOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-06-30-preview" + ) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-06-30-preview" + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-06-30-preview" + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> "IotHubClient": + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/_metadata.json new file mode 100644 index 000000000000..fc6d69e7e824 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/_metadata.json @@ -0,0 +1,116 @@ +{ + "chosen_version": "2023-06-30-preview", + "total_api_version_list": ["2023-06-30-preview"], + "client": { + "name": "IotHubClient", + "filename": "_iot_hub_client", + "description": "Use this API to manage the IoT hubs in your Azure subscription.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true, + "method_location": "positional" + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The subscription identifier. Required.", + "docstring_type": "str", + "required": true, + "method_location": "positional" + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The subscription identifier. Required.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version: Optional[str]=None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles=KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "operations": "Operations", + "iot_hub_resource": "IotHubResourceOperations", + "resource_provider_common": "ResourceProviderCommonOperations", + "certificates": "CertificatesOperations", + "iot_hub": "IotHubOperations", + "private_link_resources": "PrivateLinkResourcesOperations", + "private_endpoint_connections": "PrivateEndpointConnectionsOperations" + } +} diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/_vendor.py new file mode 100644 index 000000000000..0dafe0e287ff --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/__init__.py new file mode 100644 index 000000000000..63c7f30f2936 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._iot_hub_client import IotHubClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "IotHubClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/_configuration.py new file mode 100644 index 000000000000..4810e630fcbd --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/_configuration.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class IotHubClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for IotHubClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The subscription identifier. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2023-06-30-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-06-30-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothub/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/_iot_hub_client.py new file mode 100644 index 000000000000..7948516dfeb1 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/_iot_hub_client.py @@ -0,0 +1,134 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models as _models +from ..._serialization import Deserializer, Serializer +from ._configuration import IotHubClientConfiguration +from .operations import ( + CertificatesOperations, + IotHubOperations, + IotHubResourceOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + ResourceProviderCommonOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class IotHubClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """Use this API to manage the IoT hubs in your Azure subscription. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.iothub.v2023_06_30_preview.aio.operations.Operations + :ivar iot_hub_resource: IotHubResourceOperations operations + :vartype iot_hub_resource: + azure.mgmt.iothub.v2023_06_30_preview.aio.operations.IotHubResourceOperations + :ivar resource_provider_common: ResourceProviderCommonOperations operations + :vartype resource_provider_common: + azure.mgmt.iothub.v2023_06_30_preview.aio.operations.ResourceProviderCommonOperations + :ivar certificates: CertificatesOperations operations + :vartype certificates: + azure.mgmt.iothub.v2023_06_30_preview.aio.operations.CertificatesOperations + :ivar iot_hub: IotHubOperations operations + :vartype iot_hub: azure.mgmt.iothub.v2023_06_30_preview.aio.operations.IotHubOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.iothub.v2023_06_30_preview.aio.operations.PrivateLinkResourcesOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.iothub.v2023_06_30_preview.aio.operations.PrivateEndpointConnectionsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The subscription identifier. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2023-06-30-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize, "2023-06-30-preview" + ) + self.iot_hub_resource = IotHubResourceOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-06-30-preview" + ) + self.resource_provider_common = ResourceProviderCommonOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-06-30-preview" + ) + self.certificates = CertificatesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-06-30-preview" + ) + self.iot_hub = IotHubOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-06-30-preview" + ) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-06-30-preview" + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-06-30-preview" + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "IotHubClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/__init__.py new file mode 100644 index 000000000000..96fcc782e2e1 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/__init__.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations import Operations +from ._iot_hub_resource_operations import IotHubResourceOperations +from ._resource_provider_common_operations import ResourceProviderCommonOperations +from ._certificates_operations import CertificatesOperations +from ._iot_hub_operations import IotHubOperations +from ._private_link_resources_operations import PrivateLinkResourcesOperations +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "Operations", + "IotHubResourceOperations", + "ResourceProviderCommonOperations", + "CertificatesOperations", + "IotHubOperations", + "PrivateLinkResourcesOperations", + "PrivateEndpointConnectionsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_certificates_operations.py new file mode 100644 index 000000000000..4d4b6e2e197a --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_certificates_operations.py @@ -0,0 +1,694 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._certificates_operations import ( + build_create_or_update_request, + build_delete_request, + build_generate_verification_code_request, + build_get_request, + build_list_by_iot_hub_request, + build_verify_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30_preview.aio.IotHubClient`'s + :attr:`certificates` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def list_by_iot_hub( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: + """Get the certificate list. + + Returns the list of certificates. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateListDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateListDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) + + request = build_list_by_iot_hub_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateListDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_iot_hub.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: + """Get the certificate. + + Returns the certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: + ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: Union[_models.CertificateDescription, IO], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Is either a CertificateDescription type + or a IO type. Required. + :type certificate_description: + ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateDescription or IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IOBase, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateDescription") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CertificateDescription", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("CertificateDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}" + } + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> None: + """Delete an X509 certificate. + + Deletes an existing X509 certificate or does nothing if it does not exist. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}" + } + + @distributed_trace_async + async def generate_verification_code( + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: + """Generate verification code for proof of possession flow. + + Generates verification code for proof of possession flow. The verification code will be used to + generate a leaf certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateWithNonceDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateWithNonceDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) + + request = build_generate_verification_code_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + generate_verification_code.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode" + } + + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Is either a + CertificateVerificationDescription type or a IO type. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IOBase, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") + + request = build_verify_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + verify.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify" + } diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_iot_hub_operations.py new file mode 100644 index 000000000000..046d4bab55d0 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_iot_hub_operations.py @@ -0,0 +1,293 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._iot_hub_operations import build_manual_failover_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class IotHubOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30_preview.aio.IotHubClient`'s + :attr:`iot_hub` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + async def _manual_failover_initial( # pylint: disable=inconsistent-return-statements + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: Union[_models.FailoverInput, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(failover_input, (IOBase, bytes)): + _content = failover_input + else: + _json = self._serialize.body(failover_input, "FailoverInput") + + request = build_manual_failover_request( + iot_hub_name=iot_hub_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._manual_failover_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _manual_failover_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover" + } + + @overload + async def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: _models.FailoverInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: ~azure.mgmt.iothub.v2023_06_30_preview.models.FailoverInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: Union[_models.FailoverInput, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Is either a FailoverInput type or a IO type. Required. + :type failover_input: ~azure.mgmt.iothub.v2023_06_30_preview.models.FailoverInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._manual_failover_initial( # type: ignore + iot_hub_name=iot_hub_name, + resource_group_name=resource_group_name, + failover_input=failover_input, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_manual_failover.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover" + } diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_iot_hub_resource_operations.py new file mode 100644 index 000000000000..f2ff31604e97 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_iot_hub_resource_operations.py @@ -0,0 +1,2824 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._iot_hub_resource_operations import ( + build_check_name_availability_request, + build_create_event_hub_consumer_group_request, + build_create_or_update_request, + build_delete_event_hub_consumer_group_request, + build_delete_request, + build_export_devices_request, + build_get_endpoint_health_request, + build_get_event_hub_consumer_group_request, + build_get_job_request, + build_get_keys_for_key_name_request, + build_get_quota_metrics_request, + build_get_request, + build_get_stats_request, + build_get_valid_skus_request, + build_import_devices_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_list_event_hub_consumer_groups_request, + build_list_jobs_request, + build_list_keys_request, + build_test_all_routes_request, + build_test_route_request, + build_update_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30_preview.aio.IotHubClient`'s + :attr:`iot_hub_resource` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: + """Get the non-security related metadata of an IoT hub. + + Get the non-security related metadata of an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + async def _create_or_update_initial( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: Union[_models.IotHubDescription, IO], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.IotHubDescription: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IOBase, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: _models.IotHubDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: Union[_models.IotHubDescription, IO], + if_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a + IotHubDescription type or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription or + IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + iot_hub_description=iot_hub_description, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("IotHubDescription", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + async def _update_initial( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.IotHubDescription: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_tags, (IOBase, bytes)): + _content = iot_hub_tags + else: + _json = self._serialize.body(iot_hub_tags, "TagsResource") + + request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: _models.TagsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2023_06_30_preview.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Is either a + TagsResource type or a IO type. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2023_06_30_preview.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + iot_hub_tags=iot_hub_tags, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("IotHubDescription", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + async def _delete_initial( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if response.status_code == 404: + deserialized = self._deserialize("ErrorDetails", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.IotHubDescription]: + """Delete an IoT hub. + + Delete an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or An instance of + AsyncLROPoller that returns either ErrorDetails or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription] + or + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2023_06_30_preview.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("IotHubDescription", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDescription"]: + """Get all the IoT hubs in a subscription. + + Get all the IoT hubs in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubDescription"]: + """Get all the IoT hubs in a resource group. + + Get all the IoT hubs in a resource group. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs" + } + + @distributed_trace_async + async def get_stats( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.RegistryStatistics: + """Get the statistics from an IoT hub. + + Get the statistics from an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RegistryStatistics or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.RegistryStatistics + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) + + request = build_get_stats_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegistryStatistics", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_stats.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats" + } + + @distributed_trace + def get_valid_skus( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubSkuDescription"]: + """Get the list of valid SKUs for an IoT hub. + + Get the list of valid SKUs for an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IotHubSkuDescription or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_get_valid_skus_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + get_valid_skus.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus" + } + + @distributed_trace + def list_event_hub_consumer_groups( + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EventHubConsumerGroupInfo"]: + """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an + IoT hub. + + Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an + IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. + :type event_hub_endpoint_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2023_06_30_preview.models.EventHubConsumerGroupInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_event_hub_consumer_groups_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_event_hub_consumer_groups.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups" + } + + @distributed_trace_async + async def get_event_hub_consumer_group( + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. + + Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to retrieve. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) + + request = build_get_event_hub_consumer_group_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_event_hub_consumer_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}" + } + + @overload + async def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: _models.EventHubConsumerGroupBodyDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Required. + :type consumer_group_body: + ~azure.mgmt.iothub.v2023_06_30_preview.models.EventHubConsumerGroupBodyDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Required. + :type consumer_group_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: Union[_models.EventHubConsumerGroupBodyDescription, IO], + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Is either a + EventHubConsumerGroupBodyDescription type or a IO type. Required. + :type consumer_group_body: + ~azure.mgmt.iothub.v2023_06_30_preview.models.EventHubConsumerGroupBodyDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(consumer_group_body, (IOBase, bytes)): + _content = consumer_group_body + else: + _json = self._serialize.body(consumer_group_body, "EventHubConsumerGroupBodyDescription") + + request = build_create_event_hub_consumer_group_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_event_hub_consumer_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}" + } + + @distributed_trace_async + async def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> None: + """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + + Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to delete. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_event_hub_consumer_group_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_event_hub_consumer_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}" + } + + @distributed_trace + def list_jobs( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.JobResponse"]: + """Get a list of all the jobs in an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + + Get a list of all the jobs in an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either JobResponse or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2023_06_30_preview.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_jobs_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("JobResponseListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_jobs.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs" + } + + @distributed_trace_async + async def get_job( + self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any + ) -> _models.JobResponse: + """Get the details of a job from an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + + Get the details of a job from an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param job_id: The job identifier. Required. + :type job_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) + + request = build_get_job_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("JobResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_job.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}" + } + + @distributed_trace + def get_quota_metrics( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotHubQuotaMetricInfo"]: + """Get the quota metrics for an IoT hub. + + Get the quota metrics for an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_get_quota_metrics_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + get_quota_metrics.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics" + } + + @distributed_trace + def get_endpoint_health( + self, resource_group_name: str, iot_hub_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EndpointHealthData"]: + """Get the health for routing endpoints. + + Get the health for routing endpoints. + + :param resource_group_name: Required. + :type resource_group_name: str + :param iot_hub_name: Required. + :type iot_hub_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EndpointHealthData or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2023_06_30_preview.models.EndpointHealthData] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_get_endpoint_health_request( + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_endpoint_health.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("EndpointHealthDataListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + get_endpoint_health.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth" + } + + @overload + async def check_name_availability( + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2023_06_30_preview.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a OperationInputs type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2023_06_30_preview.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IOBase, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability" + } + + @overload + async def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: _models.TestAllRoutesInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestAllRoutesInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def test_all_routes( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestAllRoutesInput, IO], **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Is either a TestAllRoutesInput type or a IO type. + Required. + :type input: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestAllRoutesInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IOBase, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestAllRoutesInput") + + request = build_test_all_routes_request( + iot_hub_name=iot_hub_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.test_all_routes.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestAllRoutesResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + test_all_routes.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall" + } + + @overload + async def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: _models.TestRouteInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestRouteInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def test_route( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestRouteInput, IO], **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Is either a TestRouteInput type or a IO type. + Required. + :type input: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestRouteInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IOBase, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestRouteInput") + + request = build_test_route_request( + iot_hub_name=iot_hub_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.test_route.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestRouteResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + test_route.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew" + } + + @distributed_trace + def list_keys( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRule"]: + """Get the security metadata for an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + + Get the security metadata for an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2023_06_30_preview.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_keys_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys" + } + + @distributed_trace_async + async def get_keys_for_key_name( + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: + """Get a shared access policy by name from an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + + Get a shared access policy by name from an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param key_name: The name of the shared access policy. Required. + :type key_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.SharedAccessSignatureAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) + + request = build_get_keys_for_key_name_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_keys_for_key_name.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys" + } + + @overload + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: + ~azure.mgmt.iothub.v2023_06_30_preview.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a ExportDevicesRequest type or a IO type. Required. + :type export_devices_parameters: + ~azure.mgmt.iothub.v2023_06_30_preview.models.ExportDevicesRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IOBase, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") + + request = build_export_devices_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("JobResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + export_devices.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices" + } + + @overload + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: + ~azure.mgmt.iothub.v2023_06_30_preview.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a ImportDevicesRequest type or a IO type. Required. + :type import_devices_parameters: + ~azure.mgmt.iothub.v2023_06_30_preview.models.ImportDevicesRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IOBase, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") + + request = build_import_devices_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("JobResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + import_devices.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices" + } diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_operations.py new file mode 100644 index 000000000000..f3a6d7a97e2f --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_operations.py @@ -0,0 +1,137 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30_preview.aio.IotHubClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: + """Lists all of the available IoT Hub REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2023_06_30_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..2ce60051fad7 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,597 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._private_endpoint_connections_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30_preview.aio.IotHubClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> List[_models.PrivateEndpointConnection]: + """List private endpoint connections. + + List private endpoint connection properties. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of PrivateEndpointConnection or the result of cls(response) + :rtype: list[~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + + request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("[PrivateEndpointConnection]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Get private endpoint connection. + + Get private endpoint connection properties. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + async def _update_initial( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IOBase, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. + :type private_endpoint_connection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. Is + either a PrivateEndpointConnection type or a IO type. Required. + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateEndpointConnection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + private_endpoint_connection=private_endpoint_connection, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + async def _delete_initial( + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Optional[_models.PrivateEndpointConnection]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Delete private endpoint connection. + + Delete private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..98b6a71a984c --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_private_link_resources_operations.py @@ -0,0 +1,189 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._private_link_resources_operations import build_get_request, build_list_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30_preview.aio.IotHubClient`'s + :attr:`private_link_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: + """List private link resources. + + List private link resources for the given IotHub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkResources or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateLinkResources + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.PrivateLinkResources] = kwargs.pop("cls", None) + + request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResources", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, resource_name: str, group_id: str, **kwargs: Any + ) -> _models.GroupIdInformation: + """Get the specified private link resource. + + Get the specified private link resource for the given IotHub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param group_id: The name of the private link resource. Required. + :type group_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GroupIdInformation or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.GroupIdInformation + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + group_id=group_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GroupIdInformation", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}" + } diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_resource_provider_common_operations.py new file mode 100644 index 000000000000..28a49b139b1b --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_resource_provider_common_operations.py @@ -0,0 +1,110 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._resource_provider_common_operations import build_get_subscription_quota_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ResourceProviderCommonOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30_preview.aio.IotHubClient`'s + :attr:`resource_provider_common` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: + """Get the number of iot hubs in the subscription. + + Get the number of free and paid iot hubs in the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UserSubscriptionQuotaListResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.UserSubscriptionQuotaListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) + + request = build_get_subscription_quota_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_subscription_quota.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UserSubscriptionQuotaListResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_subscription_quota.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages"} diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/models/__init__.py new file mode 100644 index 000000000000..e1b08595db25 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/models/__init__.py @@ -0,0 +1,237 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import ArmIdentity +from ._models_py3 import ArmUserIdentity +from ._models_py3 import CertificateBodyDescription +from ._models_py3 import CertificateDescription +from ._models_py3 import CertificateListDescription +from ._models_py3 import CertificateProperties +from ._models_py3 import CertificatePropertiesWithNonce +from ._models_py3 import CertificateVerificationDescription +from ._models_py3 import CertificateWithNonceDescription +from ._models_py3 import CloudToDeviceProperties +from ._models_py3 import EncryptionPropertiesDescription +from ._models_py3 import EndpointHealthData +from ._models_py3 import EndpointHealthDataListResult +from ._models_py3 import EnrichmentProperties +from ._models_py3 import ErrorDetails +from ._models_py3 import EventHubConsumerGroupBodyDescription +from ._models_py3 import EventHubConsumerGroupInfo +from ._models_py3 import EventHubConsumerGroupName +from ._models_py3 import EventHubConsumerGroupsListResult +from ._models_py3 import EventHubProperties +from ._models_py3 import ExportDevicesRequest +from ._models_py3 import FailoverInput +from ._models_py3 import FallbackRouteProperties +from ._models_py3 import FeedbackProperties +from ._models_py3 import GroupIdInformation +from ._models_py3 import GroupIdInformationProperties +from ._models_py3 import ImportDevicesRequest +from ._models_py3 import IotHubCapacity +from ._models_py3 import IotHubDescription +from ._models_py3 import IotHubDescriptionListResult +from ._models_py3 import IotHubLocationDescription +from ._models_py3 import IotHubNameAvailabilityInfo +from ._models_py3 import IotHubProperties +from ._models_py3 import IotHubPropertiesDeviceStreams +from ._models_py3 import IotHubQuotaMetricInfo +from ._models_py3 import IotHubQuotaMetricInfoListResult +from ._models_py3 import IotHubSkuDescription +from ._models_py3 import IotHubSkuDescriptionListResult +from ._models_py3 import IotHubSkuInfo +from ._models_py3 import IpFilterRule +from ._models_py3 import JobResponse +from ._models_py3 import JobResponseListResult +from ._models_py3 import KeyVaultKeyProperties +from ._models_py3 import ManagedIdentity +from ._models_py3 import MatchedRoute +from ._models_py3 import MessagingEndpointProperties +from ._models_py3 import Name +from ._models_py3 import NetworkRuleSetIpRule +from ._models_py3 import NetworkRuleSetProperties +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationInputs +from ._models_py3 import OperationListResult +from ._models_py3 import PrivateEndpoint +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionProperties +from ._models_py3 import PrivateLinkResources +from ._models_py3 import PrivateLinkServiceConnectionState +from ._models_py3 import RegistryStatistics +from ._models_py3 import Resource +from ._models_py3 import RootCertificateProperties +from ._models_py3 import RouteCompilationError +from ._models_py3 import RouteErrorPosition +from ._models_py3 import RouteErrorRange +from ._models_py3 import RouteProperties +from ._models_py3 import RoutingCosmosDBSqlApiProperties +from ._models_py3 import RoutingEndpoints +from ._models_py3 import RoutingEventHubProperties +from ._models_py3 import RoutingMessage +from ._models_py3 import RoutingProperties +from ._models_py3 import RoutingServiceBusQueueEndpointProperties +from ._models_py3 import RoutingServiceBusTopicEndpointProperties +from ._models_py3 import RoutingStorageContainerProperties +from ._models_py3 import RoutingTwin +from ._models_py3 import RoutingTwinProperties +from ._models_py3 import SharedAccessSignatureAuthorizationRule +from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult +from ._models_py3 import StorageEndpointProperties +from ._models_py3 import SystemData +from ._models_py3 import TagsResource +from ._models_py3 import TestAllRoutesInput +from ._models_py3 import TestAllRoutesResult +from ._models_py3 import TestRouteInput +from ._models_py3 import TestRouteResult +from ._models_py3 import TestRouteResultDetails +from ._models_py3 import UserSubscriptionQuota +from ._models_py3 import UserSubscriptionQuotaListResult + +from ._iot_hub_client_enums import AccessRights +from ._iot_hub_client_enums import AuthenticationType +from ._iot_hub_client_enums import Capabilities +from ._iot_hub_client_enums import CreatedByType +from ._iot_hub_client_enums import DefaultAction +from ._iot_hub_client_enums import EndpointHealthStatus +from ._iot_hub_client_enums import IotHubNameUnavailabilityReason +from ._iot_hub_client_enums import IotHubReplicaRoleType +from ._iot_hub_client_enums import IotHubScaleType +from ._iot_hub_client_enums import IotHubSku +from ._iot_hub_client_enums import IotHubSkuTier +from ._iot_hub_client_enums import IpFilterActionType +from ._iot_hub_client_enums import IpVersion +from ._iot_hub_client_enums import JobStatus +from ._iot_hub_client_enums import JobType +from ._iot_hub_client_enums import NetworkRuleIPAction +from ._iot_hub_client_enums import PrivateLinkServiceConnectionStatus +from ._iot_hub_client_enums import PublicNetworkAccess +from ._iot_hub_client_enums import ResourceIdentityType +from ._iot_hub_client_enums import RouteErrorSeverity +from ._iot_hub_client_enums import RoutingSource +from ._iot_hub_client_enums import RoutingStorageContainerPropertiesEncoding +from ._iot_hub_client_enums import TestResultStatus +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ArmIdentity", + "ArmUserIdentity", + "CertificateBodyDescription", + "CertificateDescription", + "CertificateListDescription", + "CertificateProperties", + "CertificatePropertiesWithNonce", + "CertificateVerificationDescription", + "CertificateWithNonceDescription", + "CloudToDeviceProperties", + "EncryptionPropertiesDescription", + "EndpointHealthData", + "EndpointHealthDataListResult", + "EnrichmentProperties", + "ErrorDetails", + "EventHubConsumerGroupBodyDescription", + "EventHubConsumerGroupInfo", + "EventHubConsumerGroupName", + "EventHubConsumerGroupsListResult", + "EventHubProperties", + "ExportDevicesRequest", + "FailoverInput", + "FallbackRouteProperties", + "FeedbackProperties", + "GroupIdInformation", + "GroupIdInformationProperties", + "ImportDevicesRequest", + "IotHubCapacity", + "IotHubDescription", + "IotHubDescriptionListResult", + "IotHubLocationDescription", + "IotHubNameAvailabilityInfo", + "IotHubProperties", + "IotHubPropertiesDeviceStreams", + "IotHubQuotaMetricInfo", + "IotHubQuotaMetricInfoListResult", + "IotHubSkuDescription", + "IotHubSkuDescriptionListResult", + "IotHubSkuInfo", + "IpFilterRule", + "JobResponse", + "JobResponseListResult", + "KeyVaultKeyProperties", + "ManagedIdentity", + "MatchedRoute", + "MessagingEndpointProperties", + "Name", + "NetworkRuleSetIpRule", + "NetworkRuleSetProperties", + "Operation", + "OperationDisplay", + "OperationInputs", + "OperationListResult", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionProperties", + "PrivateLinkResources", + "PrivateLinkServiceConnectionState", + "RegistryStatistics", + "Resource", + "RootCertificateProperties", + "RouteCompilationError", + "RouteErrorPosition", + "RouteErrorRange", + "RouteProperties", + "RoutingCosmosDBSqlApiProperties", + "RoutingEndpoints", + "RoutingEventHubProperties", + "RoutingMessage", + "RoutingProperties", + "RoutingServiceBusQueueEndpointProperties", + "RoutingServiceBusTopicEndpointProperties", + "RoutingStorageContainerProperties", + "RoutingTwin", + "RoutingTwinProperties", + "SharedAccessSignatureAuthorizationRule", + "SharedAccessSignatureAuthorizationRuleListResult", + "StorageEndpointProperties", + "SystemData", + "TagsResource", + "TestAllRoutesInput", + "TestAllRoutesResult", + "TestRouteInput", + "TestRouteResult", + "TestRouteResultDetails", + "UserSubscriptionQuota", + "UserSubscriptionQuotaListResult", + "AccessRights", + "AuthenticationType", + "Capabilities", + "CreatedByType", + "DefaultAction", + "EndpointHealthStatus", + "IotHubNameUnavailabilityReason", + "IotHubReplicaRoleType", + "IotHubScaleType", + "IotHubSku", + "IotHubSkuTier", + "IpFilterActionType", + "IpVersion", + "JobStatus", + "JobType", + "NetworkRuleIPAction", + "PrivateLinkServiceConnectionStatus", + "PublicNetworkAccess", + "ResourceIdentityType", + "RouteErrorSeverity", + "RoutingSource", + "RoutingStorageContainerPropertiesEncoding", + "TestResultStatus", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/models/_iot_hub_client_enums.py new file mode 100644 index 000000000000..8e8bf07cccb6 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/models/_iot_hub_client_enums.py @@ -0,0 +1,240 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The permissions assigned to the shared access policy.""" + + REGISTRY_READ = "RegistryRead" + REGISTRY_WRITE = "RegistryWrite" + SERVICE_CONNECT = "ServiceConnect" + DEVICE_CONNECT = "DeviceConnect" + REGISTRY_READ_REGISTRY_WRITE = "RegistryRead, RegistryWrite" + REGISTRY_READ_SERVICE_CONNECT = "RegistryRead, ServiceConnect" + REGISTRY_READ_DEVICE_CONNECT = "RegistryRead, DeviceConnect" + REGISTRY_WRITE_SERVICE_CONNECT = "RegistryWrite, ServiceConnect" + REGISTRY_WRITE_DEVICE_CONNECT = "RegistryWrite, DeviceConnect" + SERVICE_CONNECT_DEVICE_CONNECT = "ServiceConnect, DeviceConnect" + REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect" + REGISTRY_READ_REGISTRY_WRITE_DEVICE_CONNECT = "RegistryRead, RegistryWrite, DeviceConnect" + REGISTRY_READ_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, ServiceConnect, DeviceConnect" + REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" + REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = ( + "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" + ) + + +class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies authentication type being used for connecting to the storage account.""" + + KEY_BASED = "keyBased" + IDENTITY_BASED = "identityBased" + + +class Capabilities(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The capabilities and features enabled for the IoT hub.""" + + NONE = "None" + DEVICE_MANAGEMENT = "DeviceManagement" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Default Action for Network Rule Set.""" + + DENY = "Deny" + ALLOW = "Allow" + + +class EndpointHealthStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Health statuses have following meanings. The 'healthy' status shows that the endpoint is + accepting messages as expected. The 'unhealthy' status shows that the endpoint is not accepting + messages as expected and IoT Hub is retrying to send data to this endpoint. The status of an + unhealthy endpoint will be updated to healthy when IoT Hub has established an eventually + consistent state of health. The 'dead' status shows that the endpoint is not accepting + messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub metrics to + identify errors and monitor issues with endpoints. The 'unknown' status shows that the IoT Hub + has not established a connection with the endpoint. No messages have been delivered to or + rejected from this endpoint. + """ + + UNKNOWN = "unknown" + HEALTHY = "healthy" + DEGRADED = "degraded" + UNHEALTHY = "unhealthy" + DEAD = "dead" + + +class IotHubNameUnavailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The reason for unavailability.""" + + INVALID = "Invalid" + ALREADY_EXISTS = "AlreadyExists" + + +class IotHubReplicaRoleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The role of the region, can be either primary or secondary. The primary region is where the IoT + hub is currently provisioned. The secondary region is the Azure disaster recovery (DR) paired + region and also the region where the IoT hub can failover to. + """ + + PRIMARY = "primary" + SECONDARY = "secondary" + + +class IotHubScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the scaling enabled.""" + + AUTOMATIC = "Automatic" + MANUAL = "Manual" + NONE = "None" + + +class IotHubSku(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The name of the SKU.""" + + F1 = "F1" + S1 = "S1" + S2 = "S2" + S3 = "S3" + B1 = "B1" + B2 = "B2" + B3 = "B3" + + +class IotHubSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The billing tier for the IoT hub.""" + + FREE = "Free" + STANDARD = "Standard" + BASIC = "Basic" + + +class IpFilterActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The desired action for requests captured by this rule.""" + + ACCEPT = "Accept" + REJECT = "Reject" + + +class IpVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This property specifies the IP Version the hub is currently utilizing.""" + + IPV4 = "ipv4" + IPV6 = "ipv6" + IPV4_IPV6 = "ipv4ipv6" + + +class JobStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the job.""" + + UNKNOWN = "unknown" + ENQUEUED = "enqueued" + RUNNING = "running" + COMPLETED = "completed" + FAILED = "failed" + CANCELLED = "cancelled" + + +class JobType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the job.""" + + UNKNOWN = "unknown" + EXPORT = "export" + IMPORT = "import" + BACKUP = "backup" + READ_DEVICE_PROPERTIES = "readDeviceProperties" + WRITE_DEVICE_PROPERTIES = "writeDeviceProperties" + UPDATE_DEVICE_CONFIGURATION = "updateDeviceConfiguration" + REBOOT_DEVICE = "rebootDevice" + FACTORY_RESET_DEVICE = "factoryResetDevice" + FIRMWARE_UPDATE = "firmwareUpdate" + IMPORT_ENUM = "import" + + +class NetworkRuleIPAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """IP Filter Action.""" + + ALLOW = "Allow" + + +class PrivateLinkServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of a private endpoint connection.""" + + PENDING = "Pending" + APPROVED = "Approved" + REJECTED = "Rejected" + DISCONNECTED = "Disconnected" + + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether requests from Public Network are allowed.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity used for the resource. The type 'SystemAssigned,UserAssigned' includes + both an implicitly created identity and a set of user assigned identities. The type 'None' will + remove any identities from the service. + """ + + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + NONE = "None" + + +class RouteErrorSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Severity of the route error.""" + + ERROR = "error" + WARNING = "warning" + + +class RoutingSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The source that the routing rule is to be applied to, such as DeviceMessages.""" + + INVALID = "Invalid" + DEVICE_MESSAGES = "DeviceMessages" + TWIN_CHANGE_EVENTS = "TwinChangeEvents" + DEVICE_LIFECYCLE_EVENTS = "DeviceLifecycleEvents" + DEVICE_JOB_LIFECYCLE_EVENTS = "DeviceJobLifecycleEvents" + DIGITAL_TWIN_CHANGE_EVENTS = "DigitalTwinChangeEvents" + DEVICE_CONNECTION_STATE_EVENTS = "DeviceConnectionStateEvents" + MQTT_BROKER_MESSAGES = "MqttBrokerMessages" + + +class RoutingStorageContainerPropertiesEncoding(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Encoding that is used to serialize messages to blobs. Supported values are 'avro', + 'avrodeflate', and 'JSON'. Default value is 'avro'. + """ + + AVRO = "Avro" + AVRO_DEFLATE = "AvroDeflate" + JSON = "JSON" + + +class TestResultStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Result of testing route.""" + + UNDEFINED = "undefined" + FALSE = "false" + TRUE = "true" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/models/_models_py3.py new file mode 100644 index 000000000000..b5cfea2443be --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/models/_models_py3.py @@ -0,0 +1,4272 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import datetime +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union + +from ... import _serialization + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object + + +class ArmIdentity(_serialization.Model): + """ArmIdentity. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: Principal Id. + :vartype principal_id: str + :ivar tenant_id: Tenant Id. + :vartype tenant_id: str + :ivar type: The type of identity used for the resource. The type 'SystemAssigned,UserAssigned' + includes both an implicitly created identity and a set of user assigned identities. The type + 'None' will remove any identities from the service. Known values are: "SystemAssigned", + "UserAssigned", "SystemAssigned, UserAssigned", and "None". + :vartype type: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.ResourceIdentityType + :ivar user_assigned_identities: Dictionary of :code:``. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.iothub.v2023_06_30_preview.models.ArmUserIdentity] + """ + + _validation = { + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{ArmUserIdentity}"}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.ArmUserIdentity"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword type: The type of identity used for the resource. The type + 'SystemAssigned,UserAssigned' includes both an implicitly created identity and a set of user + assigned identities. The type 'None' will remove any identities from the service. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and "None". + :paramtype type: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.ResourceIdentityType + :keyword user_assigned_identities: Dictionary of :code:``. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.iothub.v2023_06_30_preview.models.ArmUserIdentity] + """ + super().__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + self.user_assigned_identities = user_assigned_identities + + +class ArmUserIdentity(_serialization.Model): + """ArmUserIdentity. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: + :vartype principal_id: str + :ivar client_id: + :vartype client_id: str + """ + + _validation = { + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.principal_id = None + self.client_id = None + + +class CertificateBodyDescription(_serialization.Model): + """The JSON-serialized X509 Certificate. + + :ivar certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem + file content. + :vartype certificate: str + :ivar is_verified: True indicates that the certificate will be created in verified state and + proof of possession will not be required. + :vartype is_verified: bool + """ + + _attribute_map = { + "certificate": {"key": "certificate", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + } + + def __init__(self, *, certificate: Optional[str] = None, is_verified: Optional[bool] = None, **kwargs: Any) -> None: + """ + :keyword certificate: base-64 representation of the X509 leaf certificate .cer file or just + .pem file content. + :paramtype certificate: str + :keyword is_verified: True indicates that the certificate will be created in verified state and + proof of possession will not be required. + :paramtype is_verified: bool + """ + super().__init__(**kwargs) + self.certificate = certificate + self.is_verified = is_verified + + +class CertificateDescription(_serialization.Model): + """The X509 Certificate. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar properties: The description of an X509 CA Certificate. + :vartype properties: ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateProperties + :ivar id: The resource identifier. + :vartype id: str + :ivar name: The name of the certificate. + :vartype name: str + :ivar etag: The entity tag. + :vartype etag: str + :ivar type: The resource type. + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "properties": {"key": "properties", "type": "CertificateProperties"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, properties: Optional["_models.CertificateProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: The description of an X509 CA Certificate. + :paramtype properties: ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateProperties + """ + super().__init__(**kwargs) + self.properties = properties + self.id = None + self.name = None + self.etag = None + self.type = None + + +class CertificateListDescription(_serialization.Model): + """The JSON-serialized array of Certificate objects. + + :ivar value: The array of Certificate objects. + :vartype value: list[~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateDescription] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[CertificateDescription]"}, + } + + def __init__(self, *, value: Optional[List["_models.CertificateDescription"]] = None, **kwargs: Any) -> None: + """ + :keyword value: The array of Certificate objects. + :paramtype value: list[~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateDescription] + """ + super().__init__(**kwargs) + self.value = value + + +class CertificateProperties(_serialization.Model): + """The description of an X509 CA Certificate. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar subject: The certificate's subject name. + :vartype subject: str + :ivar expiry: The certificate's expiration date and time. + :vartype expiry: ~datetime.datetime + :ivar thumbprint: The certificate's thumbprint. + :vartype thumbprint: str + :ivar is_verified: Determines whether certificate has been verified. + :vartype is_verified: bool + :ivar created: The certificate's create date and time. + :vartype created: ~datetime.datetime + :ivar updated: The certificate's last update date and time. + :vartype updated: ~datetime.datetime + :ivar certificate: The certificate content. + :vartype certificate: str + """ + + _validation = { + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, + } + + _attribute_map = { + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, + "certificate": {"key": "certificate", "type": "str"}, + } + + def __init__(self, *, is_verified: Optional[bool] = None, certificate: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword is_verified: Determines whether certificate has been verified. + :paramtype is_verified: bool + :keyword certificate: The certificate content. + :paramtype certificate: str + """ + super().__init__(**kwargs) + self.subject = None + self.expiry = None + self.thumbprint = None + self.is_verified = is_verified + self.created = None + self.updated = None + self.certificate = certificate + + +class CertificatePropertiesWithNonce(_serialization.Model): + """The description of an X509 CA Certificate including the challenge nonce issued for the + Proof-Of-Possession flow. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar subject: The certificate's subject name. + :vartype subject: str + :ivar expiry: The certificate's expiration date and time. + :vartype expiry: ~datetime.datetime + :ivar thumbprint: The certificate's thumbprint. + :vartype thumbprint: str + :ivar is_verified: Determines whether certificate has been verified. + :vartype is_verified: bool + :ivar created: The certificate's create date and time. + :vartype created: ~datetime.datetime + :ivar updated: The certificate's last update date and time. + :vartype updated: ~datetime.datetime + :ivar verification_code: The certificate's verification code that will be used for proof of + possession. + :vartype verification_code: str + :ivar certificate: The certificate content. + :vartype certificate: str + """ + + _validation = { + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "is_verified": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, + "verification_code": {"readonly": True}, + "certificate": {"readonly": True}, + } + + _attribute_map = { + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, + "verification_code": {"key": "verificationCode", "type": "str"}, + "certificate": {"key": "certificate", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.subject = None + self.expiry = None + self.thumbprint = None + self.is_verified = None + self.created = None + self.updated = None + self.verification_code = None + self.certificate = None + + +class CertificateVerificationDescription(_serialization.Model): + """The JSON-serialized leaf certificate. + + :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file + content. + :vartype certificate: str + """ + + _attribute_map = { + "certificate": {"key": "certificate", "type": "str"}, + } + + def __init__(self, *, certificate: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file + content. + :paramtype certificate: str + """ + super().__init__(**kwargs) + self.certificate = certificate + + +class CertificateWithNonceDescription(_serialization.Model): + """The X509 Certificate. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar properties: The description of an X509 CA Certificate including the challenge nonce + issued for the Proof-Of-Possession flow. + :vartype properties: + ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificatePropertiesWithNonce + :ivar id: The resource identifier. + :vartype id: str + :ivar name: The name of the certificate. + :vartype name: str + :ivar etag: The entity tag. + :vartype etag: str + :ivar type: The resource type. + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "properties": {"key": "properties", "type": "CertificatePropertiesWithNonce"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, properties: Optional["_models.CertificatePropertiesWithNonce"] = None, **kwargs: Any) -> None: + """ + :keyword properties: The description of an X509 CA Certificate including the challenge nonce + issued for the Proof-Of-Possession flow. + :paramtype properties: + ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificatePropertiesWithNonce + """ + super().__init__(**kwargs) + self.properties = properties + self.id = None + self.name = None + self.etag = None + self.type = None + + +class CloudToDeviceProperties(_serialization.Model): + """The IoT hub cloud-to-device messaging properties. + + :ivar max_delivery_count: The max delivery count for cloud-to-device messages in the device + queue. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :vartype max_delivery_count: int + :ivar default_ttl_as_iso8601: The default time to live for cloud-to-device messages in the + device queue. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :vartype default_ttl_as_iso8601: ~datetime.timedelta + :ivar feedback: The properties of the feedback queue for cloud-to-device messages. + :vartype feedback: ~azure.mgmt.iothub.v2023_06_30_preview.models.FeedbackProperties + """ + + _validation = { + "max_delivery_count": {"maximum": 100, "minimum": 1}, + } + + _attribute_map = { + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, + "default_ttl_as_iso8601": {"key": "defaultTtlAsIso8601", "type": "duration"}, + "feedback": {"key": "feedback", "type": "FeedbackProperties"}, + } + + def __init__( + self, + *, + max_delivery_count: Optional[int] = None, + default_ttl_as_iso8601: Optional[datetime.timedelta] = None, + feedback: Optional["_models.FeedbackProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword max_delivery_count: The max delivery count for cloud-to-device messages in the device + queue. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :paramtype max_delivery_count: int + :keyword default_ttl_as_iso8601: The default time to live for cloud-to-device messages in the + device queue. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :paramtype default_ttl_as_iso8601: ~datetime.timedelta + :keyword feedback: The properties of the feedback queue for cloud-to-device messages. + :paramtype feedback: ~azure.mgmt.iothub.v2023_06_30_preview.models.FeedbackProperties + """ + super().__init__(**kwargs) + self.max_delivery_count = max_delivery_count + self.default_ttl_as_iso8601 = default_ttl_as_iso8601 + self.feedback = feedback + + +class EncryptionPropertiesDescription(_serialization.Model): + """The encryption properties for the IoT hub. + + :ivar key_source: The source of the key. + :vartype key_source: str + :ivar key_vault_properties: The properties of the KeyVault key. + :vartype key_vault_properties: + list[~azure.mgmt.iothub.v2023_06_30_preview.models.KeyVaultKeyProperties] + """ + + _attribute_map = { + "key_source": {"key": "keySource", "type": "str"}, + "key_vault_properties": {"key": "keyVaultProperties", "type": "[KeyVaultKeyProperties]"}, + } + + def __init__( + self, + *, + key_source: Optional[str] = None, + key_vault_properties: Optional[List["_models.KeyVaultKeyProperties"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword key_source: The source of the key. + :paramtype key_source: str + :keyword key_vault_properties: The properties of the KeyVault key. + :paramtype key_vault_properties: + list[~azure.mgmt.iothub.v2023_06_30_preview.models.KeyVaultKeyProperties] + """ + super().__init__(**kwargs) + self.key_source = key_source + self.key_vault_properties = key_vault_properties + + +class EndpointHealthData(_serialization.Model): + """The health data for an endpoint. + + :ivar endpoint_id: Id of the endpoint. + :vartype endpoint_id: str + :ivar health_status: Health statuses have following meanings. The 'healthy' status shows that + the endpoint is accepting messages as expected. The 'unhealthy' status shows that the endpoint + is not accepting messages as expected and IoT Hub is retrying to send data to this endpoint. + The status of an unhealthy endpoint will be updated to healthy when IoT Hub has established an + eventually consistent state of health. The 'dead' status shows that the endpoint is not + accepting messages, after IoT Hub retried sending messages for the retrial period. See IoT Hub + metrics to identify errors and monitor issues with endpoints. The 'unknown' status shows that + the IoT Hub has not established a connection with the endpoint. No messages have been delivered + to or rejected from this endpoint. Known values are: "unknown", "healthy", "degraded", + "unhealthy", and "dead". + :vartype health_status: str or + ~azure.mgmt.iothub.v2023_06_30_preview.models.EndpointHealthStatus + :ivar last_known_error: Last error obtained when a message failed to be delivered to iot hub. + :vartype last_known_error: str + :ivar last_known_error_time: Time at which the last known error occurred. + :vartype last_known_error_time: ~datetime.datetime + :ivar last_successful_send_attempt_time: Last time iot hub successfully sent a message to the + endpoint. + :vartype last_successful_send_attempt_time: ~datetime.datetime + :ivar last_send_attempt_time: Last time iot hub tried to send a message to the endpoint. + :vartype last_send_attempt_time: ~datetime.datetime + """ + + _attribute_map = { + "endpoint_id": {"key": "endpointId", "type": "str"}, + "health_status": {"key": "healthStatus", "type": "str"}, + "last_known_error": {"key": "lastKnownError", "type": "str"}, + "last_known_error_time": {"key": "lastKnownErrorTime", "type": "rfc-1123"}, + "last_successful_send_attempt_time": {"key": "lastSuccessfulSendAttemptTime", "type": "rfc-1123"}, + "last_send_attempt_time": {"key": "lastSendAttemptTime", "type": "rfc-1123"}, + } + + def __init__( + self, + *, + endpoint_id: Optional[str] = None, + health_status: Optional[Union[str, "_models.EndpointHealthStatus"]] = None, + last_known_error: Optional[str] = None, + last_known_error_time: Optional[datetime.datetime] = None, + last_successful_send_attempt_time: Optional[datetime.datetime] = None, + last_send_attempt_time: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword endpoint_id: Id of the endpoint. + :paramtype endpoint_id: str + :keyword health_status: Health statuses have following meanings. The 'healthy' status shows + that the endpoint is accepting messages as expected. The 'unhealthy' status shows that the + endpoint is not accepting messages as expected and IoT Hub is retrying to send data to this + endpoint. The status of an unhealthy endpoint will be updated to healthy when IoT Hub has + established an eventually consistent state of health. The 'dead' status shows that the endpoint + is not accepting messages, after IoT Hub retried sending messages for the retrial period. See + IoT Hub metrics to identify errors and monitor issues with endpoints. The 'unknown' status + shows that the IoT Hub has not established a connection with the endpoint. No messages have + been delivered to or rejected from this endpoint. Known values are: "unknown", "healthy", + "degraded", "unhealthy", and "dead". + :paramtype health_status: str or + ~azure.mgmt.iothub.v2023_06_30_preview.models.EndpointHealthStatus + :keyword last_known_error: Last error obtained when a message failed to be delivered to iot + hub. + :paramtype last_known_error: str + :keyword last_known_error_time: Time at which the last known error occurred. + :paramtype last_known_error_time: ~datetime.datetime + :keyword last_successful_send_attempt_time: Last time iot hub successfully sent a message to + the endpoint. + :paramtype last_successful_send_attempt_time: ~datetime.datetime + :keyword last_send_attempt_time: Last time iot hub tried to send a message to the endpoint. + :paramtype last_send_attempt_time: ~datetime.datetime + """ + super().__init__(**kwargs) + self.endpoint_id = endpoint_id + self.health_status = health_status + self.last_known_error = last_known_error + self.last_known_error_time = last_known_error_time + self.last_successful_send_attempt_time = last_successful_send_attempt_time + self.last_send_attempt_time = last_send_attempt_time + + +class EndpointHealthDataListResult(_serialization.Model): + """The JSON-serialized array of EndpointHealthData objects with a next link. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: JSON-serialized array of Endpoint health data. + :vartype value: list[~azure.mgmt.iothub.v2023_06_30_preview.models.EndpointHealthData] + :ivar next_link: Link to more results. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[EndpointHealthData]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.EndpointHealthData"]] = None, **kwargs: Any) -> None: + """ + :keyword value: JSON-serialized array of Endpoint health data. + :paramtype value: list[~azure.mgmt.iothub.v2023_06_30_preview.models.EndpointHealthData] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class EnrichmentProperties(_serialization.Model): + """The properties of an enrichment that your IoT hub applies to messages delivered to endpoints. + + All required parameters must be populated in order to send to Azure. + + :ivar key: The key or name for the enrichment property. Required. + :vartype key: str + :ivar value: The value for the enrichment property. Required. + :vartype value: str + :ivar endpoint_names: The list of endpoints for which the enrichment is applied to the message. + Required. + :vartype endpoint_names: list[str] + """ + + _validation = { + "key": {"required": True}, + "value": {"required": True}, + "endpoint_names": {"required": True, "min_items": 1}, + } + + _attribute_map = { + "key": {"key": "key", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + } + + def __init__(self, *, key: str, value: str, endpoint_names: List[str], **kwargs: Any) -> None: + """ + :keyword key: The key or name for the enrichment property. Required. + :paramtype key: str + :keyword value: The value for the enrichment property. Required. + :paramtype value: str + :keyword endpoint_names: The list of endpoints for which the enrichment is applied to the + message. Required. + :paramtype endpoint_names: list[str] + """ + super().__init__(**kwargs) + self.key = key + self.value = value + self.endpoint_names = endpoint_names + + +class ErrorDetails(_serialization.Model): + """Error details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar http_status_code: The HTTP status code. + :vartype http_status_code: str + :ivar message: The error message. + :vartype message: str + :ivar details: The error details. + :vartype details: str + """ + + _validation = { + "code": {"readonly": True}, + "http_status_code": {"readonly": True}, + "message": {"readonly": True}, + "details": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "http_status_code": {"key": "httpStatusCode", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.http_status_code = None + self.message = None + self.details = None + + +class EventHubConsumerGroupBodyDescription(_serialization.Model): + """The EventHub consumer group. + + All required parameters must be populated in order to send to Azure. + + :ivar properties: The EventHub consumer group name. Required. + :vartype properties: ~azure.mgmt.iothub.v2023_06_30_preview.models.EventHubConsumerGroupName + """ + + _validation = { + "properties": {"required": True}, + } + + _attribute_map = { + "properties": {"key": "properties", "type": "EventHubConsumerGroupName"}, + } + + def __init__(self, *, properties: "_models.EventHubConsumerGroupName", **kwargs: Any) -> None: + """ + :keyword properties: The EventHub consumer group name. Required. + :paramtype properties: ~azure.mgmt.iothub.v2023_06_30_preview.models.EventHubConsumerGroupName + """ + super().__init__(**kwargs) + self.properties = properties + + +class EventHubConsumerGroupInfo(_serialization.Model): + """The properties of the EventHubConsumerGroupInfo object. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar properties: The tags. + :vartype properties: dict[str, any] + :ivar id: The Event Hub-compatible consumer group identifier. + :vartype id: str + :ivar name: The Event Hub-compatible consumer group name. + :vartype name: str + :ivar type: the resource type. + :vartype type: str + :ivar etag: The etag. + :vartype etag: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + } + + _attribute_map = { + "properties": {"key": "properties", "type": "{object}"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + } + + def __init__(self, *, properties: Optional[Dict[str, Any]] = None, **kwargs: Any) -> None: + """ + :keyword properties: The tags. + :paramtype properties: dict[str, any] + """ + super().__init__(**kwargs) + self.properties = properties + self.id = None + self.name = None + self.type = None + self.etag = None + + +class EventHubConsumerGroupName(_serialization.Model): + """The EventHub consumer group name. + + All required parameters must be populated in order to send to Azure. + + :ivar name: EventHub consumer group name. Required. + :vartype name: str + """ + + _validation = { + "name": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + } + + def __init__(self, *, name: str, **kwargs: Any) -> None: + """ + :keyword name: EventHub consumer group name. Required. + :paramtype name: str + """ + super().__init__(**kwargs) + self.name = name + + +class EventHubConsumerGroupsListResult(_serialization.Model): + """The JSON-serialized array of Event Hub-compatible consumer group names with a next link. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of consumer groups objects. + :vartype value: list[~azure.mgmt.iothub.v2023_06_30_preview.models.EventHubConsumerGroupInfo] + :ivar next_link: The next link. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[EventHubConsumerGroupInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.EventHubConsumerGroupInfo"]] = None, **kwargs: Any) -> None: + """ + :keyword value: List of consumer groups objects. + :paramtype value: list[~azure.mgmt.iothub.v2023_06_30_preview.models.EventHubConsumerGroupInfo] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class EventHubProperties(_serialization.Model): + """The properties of the provisioned Event Hub-compatible endpoint used by the IoT hub. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar retention_time_in_days: The retention time for device-to-cloud messages in days. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. + :vartype retention_time_in_days: int + :ivar partition_count: The number of partitions for receiving device-to-cloud messages in the + Event Hub-compatible endpoint. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. + :vartype partition_count: int + :ivar partition_ids: The partition ids in the Event Hub-compatible endpoint. + :vartype partition_ids: list[str] + :ivar path: The Event Hub-compatible name. + :vartype path: str + :ivar endpoint: The Event Hub-compatible endpoint. + :vartype endpoint: str + """ + + _validation = { + "partition_ids": {"readonly": True}, + "path": {"readonly": True}, + "endpoint": {"readonly": True}, + } + + _attribute_map = { + "retention_time_in_days": {"key": "retentionTimeInDays", "type": "int"}, + "partition_count": {"key": "partitionCount", "type": "int"}, + "partition_ids": {"key": "partitionIds", "type": "[str]"}, + "path": {"key": "path", "type": "str"}, + "endpoint": {"key": "endpoint", "type": "str"}, + } + + def __init__( + self, *, retention_time_in_days: Optional[int] = None, partition_count: Optional[int] = None, **kwargs: Any + ) -> None: + """ + :keyword retention_time_in_days: The retention time for device-to-cloud messages in days. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. + :paramtype retention_time_in_days: int + :keyword partition_count: The number of partitions for receiving device-to-cloud messages in + the Event Hub-compatible endpoint. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#device-to-cloud-messages. + :paramtype partition_count: int + """ + super().__init__(**kwargs) + self.retention_time_in_days = retention_time_in_days + self.partition_count = partition_count + self.partition_ids = None + self.path = None + self.endpoint = None + + +class ExportDevicesRequest(_serialization.Model): + """Use to provide parameters when requesting an export of all devices in the IoT hub. + + All required parameters must be populated in order to send to Azure. + + :ivar export_blob_container_uri: The export blob container URI. Required. + :vartype export_blob_container_uri: str + :ivar exclude_keys: The value indicating whether keys should be excluded during export. + Required. + :vartype exclude_keys: bool + :ivar export_blob_name: The name of the blob that will be created in the provided output blob + container. This blob will contain the exported device registry information for the IoT Hub. + :vartype export_blob_name: str + :ivar authentication_type: Specifies authentication type being used for connecting to the + storage account. Known values are: "keyBased" and "identityBased". + :vartype authentication_type: str or + ~azure.mgmt.iothub.v2023_06_30_preview.models.AuthenticationType + :ivar identity: Managed identity properties of storage endpoint for export devices. + :vartype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :ivar include_configurations: The value indicating whether configurations should be exported. + :vartype include_configurations: bool + :ivar configurations_blob_name: The name of the blob that will be created in the provided + output blob container. This blob will contain the exported configurations for the Iot Hub. + :vartype configurations_blob_name: str + """ + + _validation = { + "export_blob_container_uri": {"required": True}, + "exclude_keys": {"required": True}, + } + + _attribute_map = { + "export_blob_container_uri": {"key": "exportBlobContainerUri", "type": "str"}, + "exclude_keys": {"key": "excludeKeys", "type": "bool"}, + "export_blob_name": {"key": "exportBlobName", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "include_configurations": {"key": "includeConfigurations", "type": "bool"}, + "configurations_blob_name": {"key": "configurationsBlobName", "type": "str"}, + } + + def __init__( + self, + *, + export_blob_container_uri: str, + exclude_keys: bool, + export_blob_name: Optional[str] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, + include_configurations: Optional[bool] = None, + configurations_blob_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword export_blob_container_uri: The export blob container URI. Required. + :paramtype export_blob_container_uri: str + :keyword exclude_keys: The value indicating whether keys should be excluded during export. + Required. + :paramtype exclude_keys: bool + :keyword export_blob_name: The name of the blob that will be created in the provided output + blob container. This blob will contain the exported device registry information for the IoT + Hub. + :paramtype export_blob_name: str + :keyword authentication_type: Specifies authentication type being used for connecting to the + storage account. Known values are: "keyBased" and "identityBased". + :paramtype authentication_type: str or + ~azure.mgmt.iothub.v2023_06_30_preview.models.AuthenticationType + :keyword identity: Managed identity properties of storage endpoint for export devices. + :paramtype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :keyword include_configurations: The value indicating whether configurations should be + exported. + :paramtype include_configurations: bool + :keyword configurations_blob_name: The name of the blob that will be created in the provided + output blob container. This blob will contain the exported configurations for the Iot Hub. + :paramtype configurations_blob_name: str + """ + super().__init__(**kwargs) + self.export_blob_container_uri = export_blob_container_uri + self.exclude_keys = exclude_keys + self.export_blob_name = export_blob_name + self.authentication_type = authentication_type + self.identity = identity + self.include_configurations = include_configurations + self.configurations_blob_name = configurations_blob_name + + +class FailoverInput(_serialization.Model): + """Use to provide failover region when requesting manual Failover for a hub. + + All required parameters must be populated in order to send to Azure. + + :ivar failover_region: Region the hub will be failed over to. Required. + :vartype failover_region: str + """ + + _validation = { + "failover_region": {"required": True}, + } + + _attribute_map = { + "failover_region": {"key": "failoverRegion", "type": "str"}, + } + + def __init__(self, *, failover_region: str, **kwargs: Any) -> None: + """ + :keyword failover_region: Region the hub will be failed over to. Required. + :paramtype failover_region: str + """ + super().__init__(**kwargs) + self.failover_region = failover_region + + +class FallbackRouteProperties(_serialization.Model): + """The properties of the fallback route. IoT Hub uses these properties when it routes messages to + the fallback endpoint. + + All required parameters must be populated in order to send to Azure. + + :ivar name: The name of the route. The name can only include alphanumeric characters, periods, + underscores, hyphens, has a maximum length of 64 characters, and must be unique. + :vartype name: str + :ivar source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents", + "DeviceConnectionStateEvents", and "MqttBrokerMessages". + :vartype source: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingSource + :ivar condition: The condition which is evaluated in order to apply the fallback route. If the + condition is not provided it will evaluate to true by default. For grammar, See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. + :vartype condition: str + :ivar endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. + :vartype endpoint_names: list[str] + :ivar is_enabled: Used to specify whether the fallback route is enabled. Required. + :vartype is_enabled: bool + """ + + _validation = { + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + } + + def __init__( + self, + *, + source: Union[str, "_models.RoutingSource"], + endpoint_names: List[str], + is_enabled: bool, + name: Optional[str] = None, + condition: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the route. The name can only include alphanumeric characters, + periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + :paramtype name: str + :keyword source: The source to which the routing rule is to be applied to. For example, + DeviceMessages. Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents", + "DeviceConnectionStateEvents", and "MqttBrokerMessages". + :paramtype source: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingSource + :keyword condition: The condition which is evaluated in order to apply the fallback route. If + the condition is not provided it will evaluate to true by default. For grammar, See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. + :paramtype condition: str + :keyword endpoint_names: The list of endpoints to which the messages that satisfy the condition + are routed to. Currently only 1 endpoint is allowed. Required. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Used to specify whether the fallback route is enabled. Required. + :paramtype is_enabled: bool + """ + super().__init__(**kwargs) + self.name = name + self.source = source + self.condition = condition + self.endpoint_names = endpoint_names + self.is_enabled = is_enabled + + +class FeedbackProperties(_serialization.Model): + """The properties of the feedback queue for cloud-to-device messages. + + :ivar lock_duration_as_iso8601: The lock duration for the feedback queue. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :vartype lock_duration_as_iso8601: ~datetime.timedelta + :ivar ttl_as_iso8601: The period of time for which a message is available to consume before it + is expired by the IoT hub. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :vartype ttl_as_iso8601: ~datetime.timedelta + :ivar max_delivery_count: The number of times the IoT hub attempts to deliver a message on the + feedback queue. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :vartype max_delivery_count: int + """ + + _validation = { + "max_delivery_count": {"maximum": 100, "minimum": 1}, + } + + _attribute_map = { + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, + } + + def __init__( + self, + *, + lock_duration_as_iso8601: Optional[datetime.timedelta] = None, + ttl_as_iso8601: Optional[datetime.timedelta] = None, + max_delivery_count: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword lock_duration_as_iso8601: The lock duration for the feedback queue. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :paramtype lock_duration_as_iso8601: ~datetime.timedelta + :keyword ttl_as_iso8601: The period of time for which a message is available to consume before + it is expired by the IoT hub. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :paramtype ttl_as_iso8601: ~datetime.timedelta + :keyword max_delivery_count: The number of times the IoT hub attempts to deliver a message on + the feedback queue. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging#cloud-to-device-messages. + :paramtype max_delivery_count: int + """ + super().__init__(**kwargs) + self.lock_duration_as_iso8601 = lock_duration_as_iso8601 + self.ttl_as_iso8601 = ttl_as_iso8601 + self.max_delivery_count = max_delivery_count + + +class GroupIdInformation(_serialization.Model): + """The group information for creating a private endpoint on an IotHub. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The resource identifier. + :vartype id: str + :ivar name: The resource name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :ivar properties: The properties for a group information object. Required. + :vartype properties: ~azure.mgmt.iothub.v2023_06_30_preview.models.GroupIdInformationProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "properties": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "GroupIdInformationProperties"}, + } + + def __init__(self, *, properties: "_models.GroupIdInformationProperties", **kwargs: Any) -> None: + """ + :keyword properties: The properties for a group information object. Required. + :paramtype properties: + ~azure.mgmt.iothub.v2023_06_30_preview.models.GroupIdInformationProperties + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.properties = properties + + +class GroupIdInformationProperties(_serialization.Model): + """The properties for a group information object. + + :ivar group_id: The group id. + :vartype group_id: str + :ivar required_members: The required members for a specific group id. + :vartype required_members: list[str] + :ivar required_zone_names: The required DNS zones for a specific group id. + :vartype required_zone_names: list[str] + """ + + _attribute_map = { + "group_id": {"key": "groupId", "type": "str"}, + "required_members": {"key": "requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "requiredZoneNames", "type": "[str]"}, + } + + def __init__( + self, + *, + group_id: Optional[str] = None, + required_members: Optional[List[str]] = None, + required_zone_names: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword group_id: The group id. + :paramtype group_id: str + :keyword required_members: The required members for a specific group id. + :paramtype required_members: list[str] + :keyword required_zone_names: The required DNS zones for a specific group id. + :paramtype required_zone_names: list[str] + """ + super().__init__(**kwargs) + self.group_id = group_id + self.required_members = required_members + self.required_zone_names = required_zone_names + + +class ImportDevicesRequest(_serialization.Model): + """Use to provide parameters when requesting an import of all devices in the hub. + + All required parameters must be populated in order to send to Azure. + + :ivar input_blob_container_uri: The input blob container URI. Required. + :vartype input_blob_container_uri: str + :ivar output_blob_container_uri: The output blob container URI. Required. + :vartype output_blob_container_uri: str + :ivar input_blob_name: The blob name to be used when importing from the provided input blob + container. + :vartype input_blob_name: str + :ivar output_blob_name: The blob name to use for storing the status of the import job. + :vartype output_blob_name: str + :ivar authentication_type: Specifies authentication type being used for connecting to the + storage account. Known values are: "keyBased" and "identityBased". + :vartype authentication_type: str or + ~azure.mgmt.iothub.v2023_06_30_preview.models.AuthenticationType + :ivar identity: Managed identity properties of storage endpoint for import devices. + :vartype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :ivar include_configurations: The value indicating whether configurations should be imported. + :vartype include_configurations: bool + :ivar configurations_blob_name: The blob name to be used when importing configurations from the + provided input blob container. + :vartype configurations_blob_name: str + """ + + _validation = { + "input_blob_container_uri": {"required": True}, + "output_blob_container_uri": {"required": True}, + } + + _attribute_map = { + "input_blob_container_uri": {"key": "inputBlobContainerUri", "type": "str"}, + "output_blob_container_uri": {"key": "outputBlobContainerUri", "type": "str"}, + "input_blob_name": {"key": "inputBlobName", "type": "str"}, + "output_blob_name": {"key": "outputBlobName", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "include_configurations": {"key": "includeConfigurations", "type": "bool"}, + "configurations_blob_name": {"key": "configurationsBlobName", "type": "str"}, + } + + def __init__( + self, + *, + input_blob_container_uri: str, + output_blob_container_uri: str, + input_blob_name: Optional[str] = None, + output_blob_name: Optional[str] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, + include_configurations: Optional[bool] = None, + configurations_blob_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword input_blob_container_uri: The input blob container URI. Required. + :paramtype input_blob_container_uri: str + :keyword output_blob_container_uri: The output blob container URI. Required. + :paramtype output_blob_container_uri: str + :keyword input_blob_name: The blob name to be used when importing from the provided input blob + container. + :paramtype input_blob_name: str + :keyword output_blob_name: The blob name to use for storing the status of the import job. + :paramtype output_blob_name: str + :keyword authentication_type: Specifies authentication type being used for connecting to the + storage account. Known values are: "keyBased" and "identityBased". + :paramtype authentication_type: str or + ~azure.mgmt.iothub.v2023_06_30_preview.models.AuthenticationType + :keyword identity: Managed identity properties of storage endpoint for import devices. + :paramtype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :keyword include_configurations: The value indicating whether configurations should be + imported. + :paramtype include_configurations: bool + :keyword configurations_blob_name: The blob name to be used when importing configurations from + the provided input blob container. + :paramtype configurations_blob_name: str + """ + super().__init__(**kwargs) + self.input_blob_container_uri = input_blob_container_uri + self.output_blob_container_uri = output_blob_container_uri + self.input_blob_name = input_blob_name + self.output_blob_name = output_blob_name + self.authentication_type = authentication_type + self.identity = identity + self.include_configurations = include_configurations + self.configurations_blob_name = configurations_blob_name + + +class IotHubCapacity(_serialization.Model): + """IoT Hub capacity information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar minimum: The minimum number of units. + :vartype minimum: int + :ivar maximum: The maximum number of units. + :vartype maximum: int + :ivar default: The default number of units. + :vartype default: int + :ivar scale_type: The type of the scaling enabled. Known values are: "Automatic", "Manual", and + "None". + :vartype scale_type: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubScaleType + """ + + _validation = { + "minimum": {"readonly": True, "maximum": 1, "minimum": 1}, + "maximum": {"readonly": True}, + "default": {"readonly": True}, + "scale_type": {"readonly": True}, + } + + _attribute_map = { + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "scale_type": {"key": "scaleType", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.minimum = None + self.maximum = None + self.default = None + self.scale_type = None + + +class Resource(_serialization.Model): + """The common properties of an Azure resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The resource identifier. + :vartype id: str + :ivar name: The resource name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :ivar location: The resource location. Required. + :vartype location: str + :ivar tags: The resource tags. + :vartype tags: dict[str, str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword location: The resource location. Required. + :paramtype location: str + :keyword tags: The resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + + +class IotHubDescription(Resource): + """The description of the IoT hub. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The resource identifier. + :vartype id: str + :ivar name: The resource name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :ivar location: The resource location. Required. + :vartype location: str + :ivar tags: The resource tags. + :vartype tags: dict[str, str] + :ivar etag: The Etag field is *not* required. If it is provided in the response body, it must + also be provided as a header per the normal ETag convention. + :vartype etag: str + :ivar properties: IotHub properties. + :vartype properties: ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubProperties + :ivar sku: IotHub SKU info. Required. + :vartype sku: ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubSkuInfo + :ivar identity: The managed identities for the IotHub. + :vartype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ArmIdentity + :ivar system_data: The system meta data relating to this resource. + :vartype system_data: ~azure.mgmt.iothub.v2023_06_30_preview.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"required": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "etag": {"key": "etag", "type": "str"}, + "properties": {"key": "properties", "type": "IotHubProperties"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, + "identity": {"key": "identity", "type": "ArmIdentity"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__( + self, + *, + location: str, + sku: "_models.IotHubSkuInfo", + tags: Optional[Dict[str, str]] = None, + etag: Optional[str] = None, + properties: Optional["_models.IotHubProperties"] = None, + identity: Optional["_models.ArmIdentity"] = None, + **kwargs: Any + ) -> None: + """ + :keyword location: The resource location. Required. + :paramtype location: str + :keyword tags: The resource tags. + :paramtype tags: dict[str, str] + :keyword etag: The Etag field is *not* required. If it is provided in the response body, it + must also be provided as a header per the normal ETag convention. + :paramtype etag: str + :keyword properties: IotHub properties. + :paramtype properties: ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubProperties + :keyword sku: IotHub SKU info. Required. + :paramtype sku: ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubSkuInfo + :keyword identity: The managed identities for the IotHub. + :paramtype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ArmIdentity + """ + super().__init__(location=location, tags=tags, **kwargs) + self.etag = etag + self.properties = properties + self.sku = sku + self.identity = identity + self.system_data = None + + +class IotHubDescriptionListResult(_serialization.Model): + """The JSON-serialized array of IotHubDescription objects with a next link. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The array of IotHubDescription objects. + :vartype value: list[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription] + :ivar next_link: The next link. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[IotHubDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.IotHubDescription"]] = None, **kwargs: Any) -> None: + """ + :keyword value: The array of IotHubDescription objects. + :paramtype value: list[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class IotHubLocationDescription(_serialization.Model): + """Public representation of one of the locations where a resource is provisioned. + + :ivar location: The name of the Azure region. + :vartype location: str + :ivar role: The role of the region, can be either primary or secondary. The primary region is + where the IoT hub is currently provisioned. The secondary region is the Azure disaster recovery + (DR) paired region and also the region where the IoT hub can failover to. Known values are: + "primary" and "secondary". + :vartype role: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubReplicaRoleType + """ + + _attribute_map = { + "location": {"key": "location", "type": "str"}, + "role": {"key": "role", "type": "str"}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + role: Optional[Union[str, "_models.IotHubReplicaRoleType"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword location: The name of the Azure region. + :paramtype location: str + :keyword role: The role of the region, can be either primary or secondary. The primary region + is where the IoT hub is currently provisioned. The secondary region is the Azure disaster + recovery (DR) paired region and also the region where the IoT hub can failover to. Known values + are: "primary" and "secondary". + :paramtype role: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubReplicaRoleType + """ + super().__init__(**kwargs) + self.location = location + self.role = role + + +class IotHubNameAvailabilityInfo(_serialization.Model): + """The properties indicating whether a given IoT hub name is available. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name_available: The value which indicates whether the provided name is available. + :vartype name_available: bool + :ivar reason: The reason for unavailability. Known values are: "Invalid" and "AlreadyExists". + :vartype reason: str or + ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubNameUnavailabilityReason + :ivar message: The detailed reason message. + :vartype message: str + """ + + _validation = { + "name_available": {"readonly": True}, + "reason": {"readonly": True}, + } + + _attribute_map = { + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, *, message: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword message: The detailed reason message. + :paramtype message: str + """ + super().__init__(**kwargs) + self.name_available = None + self.reason = None + self.message = message + + +class IotHubProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes + """The properties of an IoT hub. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar authorization_policies: The shared access policies you can use to secure a connection to + the IoT hub. + :vartype authorization_policies: + list[~azure.mgmt.iothub.v2023_06_30_preview.models.SharedAccessSignatureAuthorizationRule] + :ivar disable_local_auth: If true, SAS tokens with Iot hub scoped SAS keys cannot be used for + authentication. + :vartype disable_local_auth: bool + :ivar disable_device_sas: If true, all device(including Edge devices but excluding modules) + scoped SAS keys cannot be used for authentication. + :vartype disable_device_sas: bool + :ivar disable_module_sas: If true, all module scoped SAS keys cannot be used for + authentication. + :vartype disable_module_sas: bool + :ivar restrict_outbound_network_access: If true, egress from IotHub will be restricted to only + the allowed FQDNs that are configured via allowedFqdnList. + :vartype restrict_outbound_network_access: bool + :ivar allowed_fqdn_list: List of allowed FQDNs(Fully Qualified Domain Name) for egress from Iot + Hub. + :vartype allowed_fqdn_list: list[str] + :ivar public_network_access: Whether requests from Public Network are allowed. Known values + are: "Enabled" and "Disabled". + :vartype public_network_access: str or + ~azure.mgmt.iothub.v2023_06_30_preview.models.PublicNetworkAccess + :ivar ip_filter_rules: The IP filter rules. + :vartype ip_filter_rules: list[~azure.mgmt.iothub.v2023_06_30_preview.models.IpFilterRule] + :ivar network_rule_sets: Network Rule Set Properties of IotHub. + :vartype network_rule_sets: + ~azure.mgmt.iothub.v2023_06_30_preview.models.NetworkRuleSetProperties + :ivar min_tls_version: Specifies the minimum TLS version to support for this hub. Can be set to + "1.2" to have clients that use a TLS version below 1.2 to be rejected. + :vartype min_tls_version: str + :ivar private_endpoint_connections: Private endpoint connections created on this IotHub. + :vartype private_endpoint_connections: + list[~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateEndpointConnection] + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str + :ivar state: The hub state. + :vartype state: str + :ivar host_name: The name of the host. + :vartype host_name: str + :ivar event_hub_endpoints: The Event Hub-compatible endpoint properties. The only possible keys + to this dictionary is events. This key has to be present in the dictionary while making create + or update calls for the IoT hub. + :vartype event_hub_endpoints: dict[str, + ~azure.mgmt.iothub.v2023_06_30_preview.models.EventHubProperties] + :ivar routing: The routing related properties of the IoT hub. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. + :vartype routing: ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingProperties + :ivar storage_endpoints: The list of Azure Storage endpoints where you can upload files. + Currently you can configure only one Azure Storage account and that MUST have its key as + $default. Specifying more than one storage account causes an error to be thrown. Not specifying + a value for this property when the enableFileUploadNotifications property is set to True, + causes an error to be thrown. + :vartype storage_endpoints: dict[str, + ~azure.mgmt.iothub.v2023_06_30_preview.models.StorageEndpointProperties] + :ivar messaging_endpoints: The messaging endpoint properties for the file upload notification + queue. + :vartype messaging_endpoints: dict[str, + ~azure.mgmt.iothub.v2023_06_30_preview.models.MessagingEndpointProperties] + :ivar enable_file_upload_notifications: If True, file upload notifications are enabled. + :vartype enable_file_upload_notifications: bool + :ivar cloud_to_device: The IoT hub cloud-to-device messaging properties. + :vartype cloud_to_device: ~azure.mgmt.iothub.v2023_06_30_preview.models.CloudToDeviceProperties + :ivar comments: IoT hub comments. + :vartype comments: str + :ivar device_streams: The device streams properties of iothub. + :vartype device_streams: + ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubPropertiesDeviceStreams + :ivar features: The capabilities and features enabled for the IoT hub. Known values are: "None" + and "DeviceManagement". + :vartype features: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.Capabilities + :ivar encryption: The encryption properties for the IoT hub. + :vartype encryption: + ~azure.mgmt.iothub.v2023_06_30_preview.models.EncryptionPropertiesDescription + :ivar locations: Primary and secondary location for iot hub. + :vartype locations: + list[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubLocationDescription] + :ivar enable_data_residency: This property when set to true, will enable data residency, thus, + disabling disaster recovery. + :vartype enable_data_residency: bool + :ivar root_certificate: This property store root certificate related information. + :vartype root_certificate: + ~azure.mgmt.iothub.v2023_06_30_preview.models.RootCertificateProperties + :ivar ip_version: This property specifies the IP Version the hub is currently utilizing. Known + values are: "ipv4", "ipv6", and "ipv4ipv6". + :vartype ip_version: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.IpVersion + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "state": {"readonly": True}, + "host_name": {"readonly": True}, + "locations": {"readonly": True}, + } + + _attribute_map = { + "authorization_policies": {"key": "authorizationPolicies", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "disable_local_auth": {"key": "disableLocalAuth", "type": "bool"}, + "disable_device_sas": {"key": "disableDeviceSAS", "type": "bool"}, + "disable_module_sas": {"key": "disableModuleSAS", "type": "bool"}, + "restrict_outbound_network_access": {"key": "restrictOutboundNetworkAccess", "type": "bool"}, + "allowed_fqdn_list": {"key": "allowedFqdnList", "type": "[str]"}, + "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, + "ip_filter_rules": {"key": "ipFilterRules", "type": "[IpFilterRule]"}, + "network_rule_sets": {"key": "networkRuleSets", "type": "NetworkRuleSetProperties"}, + "min_tls_version": {"key": "minTlsVersion", "type": "str"}, + "private_endpoint_connections": {"key": "privateEndpointConnections", "type": "[PrivateEndpointConnection]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "host_name": {"key": "hostName", "type": "str"}, + "event_hub_endpoints": {"key": "eventHubEndpoints", "type": "{EventHubProperties}"}, + "routing": {"key": "routing", "type": "RoutingProperties"}, + "storage_endpoints": {"key": "storageEndpoints", "type": "{StorageEndpointProperties}"}, + "messaging_endpoints": {"key": "messagingEndpoints", "type": "{MessagingEndpointProperties}"}, + "enable_file_upload_notifications": {"key": "enableFileUploadNotifications", "type": "bool"}, + "cloud_to_device": {"key": "cloudToDevice", "type": "CloudToDeviceProperties"}, + "comments": {"key": "comments", "type": "str"}, + "device_streams": {"key": "deviceStreams", "type": "IotHubPropertiesDeviceStreams"}, + "features": {"key": "features", "type": "str"}, + "encryption": {"key": "encryption", "type": "EncryptionPropertiesDescription"}, + "locations": {"key": "locations", "type": "[IotHubLocationDescription]"}, + "enable_data_residency": {"key": "enableDataResidency", "type": "bool"}, + "root_certificate": {"key": "rootCertificate", "type": "RootCertificateProperties"}, + "ip_version": {"key": "ipVersion", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals + self, + *, + authorization_policies: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, + disable_local_auth: Optional[bool] = None, + disable_device_sas: Optional[bool] = None, + disable_module_sas: Optional[bool] = None, + restrict_outbound_network_access: Optional[bool] = None, + allowed_fqdn_list: Optional[List[str]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + ip_filter_rules: Optional[List["_models.IpFilterRule"]] = None, + network_rule_sets: Optional["_models.NetworkRuleSetProperties"] = None, + min_tls_version: Optional[str] = None, + private_endpoint_connections: Optional[List["_models.PrivateEndpointConnection"]] = None, + event_hub_endpoints: Optional[Dict[str, "_models.EventHubProperties"]] = None, + routing: Optional["_models.RoutingProperties"] = None, + storage_endpoints: Optional[Dict[str, "_models.StorageEndpointProperties"]] = None, + messaging_endpoints: Optional[Dict[str, "_models.MessagingEndpointProperties"]] = None, + enable_file_upload_notifications: Optional[bool] = None, + cloud_to_device: Optional["_models.CloudToDeviceProperties"] = None, + comments: Optional[str] = None, + device_streams: Optional["_models.IotHubPropertiesDeviceStreams"] = None, + features: Optional[Union[str, "_models.Capabilities"]] = None, + encryption: Optional["_models.EncryptionPropertiesDescription"] = None, + enable_data_residency: Optional[bool] = None, + root_certificate: Optional["_models.RootCertificateProperties"] = None, + ip_version: Optional[Union[str, "_models.IpVersion"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword authorization_policies: The shared access policies you can use to secure a connection + to the IoT hub. + :paramtype authorization_policies: + list[~azure.mgmt.iothub.v2023_06_30_preview.models.SharedAccessSignatureAuthorizationRule] + :keyword disable_local_auth: If true, SAS tokens with Iot hub scoped SAS keys cannot be used + for authentication. + :paramtype disable_local_auth: bool + :keyword disable_device_sas: If true, all device(including Edge devices but excluding modules) + scoped SAS keys cannot be used for authentication. + :paramtype disable_device_sas: bool + :keyword disable_module_sas: If true, all module scoped SAS keys cannot be used for + authentication. + :paramtype disable_module_sas: bool + :keyword restrict_outbound_network_access: If true, egress from IotHub will be restricted to + only the allowed FQDNs that are configured via allowedFqdnList. + :paramtype restrict_outbound_network_access: bool + :keyword allowed_fqdn_list: List of allowed FQDNs(Fully Qualified Domain Name) for egress from + Iot Hub. + :paramtype allowed_fqdn_list: list[str] + :keyword public_network_access: Whether requests from Public Network are allowed. Known values + are: "Enabled" and "Disabled". + :paramtype public_network_access: str or + ~azure.mgmt.iothub.v2023_06_30_preview.models.PublicNetworkAccess + :keyword ip_filter_rules: The IP filter rules. + :paramtype ip_filter_rules: list[~azure.mgmt.iothub.v2023_06_30_preview.models.IpFilterRule] + :keyword network_rule_sets: Network Rule Set Properties of IotHub. + :paramtype network_rule_sets: + ~azure.mgmt.iothub.v2023_06_30_preview.models.NetworkRuleSetProperties + :keyword min_tls_version: Specifies the minimum TLS version to support for this hub. Can be set + to "1.2" to have clients that use a TLS version below 1.2 to be rejected. + :paramtype min_tls_version: str + :keyword private_endpoint_connections: Private endpoint connections created on this IotHub. + :paramtype private_endpoint_connections: + list[~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateEndpointConnection] + :keyword event_hub_endpoints: The Event Hub-compatible endpoint properties. The only possible + keys to this dictionary is events. This key has to be present in the dictionary while making + create or update calls for the IoT hub. + :paramtype event_hub_endpoints: dict[str, + ~azure.mgmt.iothub.v2023_06_30_preview.models.EventHubProperties] + :keyword routing: The routing related properties of the IoT hub. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. + :paramtype routing: ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingProperties + :keyword storage_endpoints: The list of Azure Storage endpoints where you can upload files. + Currently you can configure only one Azure Storage account and that MUST have its key as + $default. Specifying more than one storage account causes an error to be thrown. Not specifying + a value for this property when the enableFileUploadNotifications property is set to True, + causes an error to be thrown. + :paramtype storage_endpoints: dict[str, + ~azure.mgmt.iothub.v2023_06_30_preview.models.StorageEndpointProperties] + :keyword messaging_endpoints: The messaging endpoint properties for the file upload + notification queue. + :paramtype messaging_endpoints: dict[str, + ~azure.mgmt.iothub.v2023_06_30_preview.models.MessagingEndpointProperties] + :keyword enable_file_upload_notifications: If True, file upload notifications are enabled. + :paramtype enable_file_upload_notifications: bool + :keyword cloud_to_device: The IoT hub cloud-to-device messaging properties. + :paramtype cloud_to_device: + ~azure.mgmt.iothub.v2023_06_30_preview.models.CloudToDeviceProperties + :keyword comments: IoT hub comments. + :paramtype comments: str + :keyword device_streams: The device streams properties of iothub. + :paramtype device_streams: + ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubPropertiesDeviceStreams + :keyword features: The capabilities and features enabled for the IoT hub. Known values are: + "None" and "DeviceManagement". + :paramtype features: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.Capabilities + :keyword encryption: The encryption properties for the IoT hub. + :paramtype encryption: + ~azure.mgmt.iothub.v2023_06_30_preview.models.EncryptionPropertiesDescription + :keyword enable_data_residency: This property when set to true, will enable data residency, + thus, disabling disaster recovery. + :paramtype enable_data_residency: bool + :keyword root_certificate: This property store root certificate related information. + :paramtype root_certificate: + ~azure.mgmt.iothub.v2023_06_30_preview.models.RootCertificateProperties + :keyword ip_version: This property specifies the IP Version the hub is currently utilizing. + Known values are: "ipv4", "ipv6", and "ipv4ipv6". + :paramtype ip_version: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.IpVersion + """ + super().__init__(**kwargs) + self.authorization_policies = authorization_policies + self.disable_local_auth = disable_local_auth + self.disable_device_sas = disable_device_sas + self.disable_module_sas = disable_module_sas + self.restrict_outbound_network_access = restrict_outbound_network_access + self.allowed_fqdn_list = allowed_fqdn_list + self.public_network_access = public_network_access + self.ip_filter_rules = ip_filter_rules + self.network_rule_sets = network_rule_sets + self.min_tls_version = min_tls_version + self.private_endpoint_connections = private_endpoint_connections + self.provisioning_state = None + self.state = None + self.host_name = None + self.event_hub_endpoints = event_hub_endpoints + self.routing = routing + self.storage_endpoints = storage_endpoints + self.messaging_endpoints = messaging_endpoints + self.enable_file_upload_notifications = enable_file_upload_notifications + self.cloud_to_device = cloud_to_device + self.comments = comments + self.device_streams = device_streams + self.features = features + self.encryption = encryption + self.locations = None + self.enable_data_residency = enable_data_residency + self.root_certificate = root_certificate + self.ip_version = ip_version + + +class IotHubPropertiesDeviceStreams(_serialization.Model): + """The device streams properties of iothub. + + :ivar streaming_endpoints: List of Device Streams Endpoints. + :vartype streaming_endpoints: list[str] + """ + + _attribute_map = { + "streaming_endpoints": {"key": "streamingEndpoints", "type": "[str]"}, + } + + def __init__(self, *, streaming_endpoints: Optional[List[str]] = None, **kwargs: Any) -> None: + """ + :keyword streaming_endpoints: List of Device Streams Endpoints. + :paramtype streaming_endpoints: list[str] + """ + super().__init__(**kwargs) + self.streaming_endpoints = streaming_endpoints + + +class IotHubQuotaMetricInfo(_serialization.Model): + """Quota metrics properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the quota metric. + :vartype name: str + :ivar current_value: The current value for the quota metric. + :vartype current_value: int + :ivar max_value: The maximum value of the quota metric. + :vartype max_value: int + """ + + _validation = { + "name": {"readonly": True}, + "current_value": {"readonly": True}, + "max_value": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "max_value": {"key": "maxValue", "type": "int"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.name = None + self.current_value = None + self.max_value = None + + +class IotHubQuotaMetricInfoListResult(_serialization.Model): + """The JSON-serialized array of IotHubQuotaMetricInfo objects with a next link. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The array of quota metrics objects. + :vartype value: list[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubQuotaMetricInfo] + :ivar next_link: The next link. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[IotHubQuotaMetricInfo]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.IotHubQuotaMetricInfo"]] = None, **kwargs: Any) -> None: + """ + :keyword value: The array of quota metrics objects. + :paramtype value: list[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubQuotaMetricInfo] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class IotHubSkuDescription(_serialization.Model): + """SKU properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar resource_type: The type of the resource. + :vartype resource_type: str + :ivar sku: The type of the resource. Required. + :vartype sku: ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubSkuInfo + :ivar capacity: IotHub capacity. Required. + :vartype capacity: ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubCapacity + """ + + _validation = { + "resource_type": {"readonly": True}, + "sku": {"required": True}, + "capacity": {"required": True}, + } + + _attribute_map = { + "resource_type": {"key": "resourceType", "type": "str"}, + "sku": {"key": "sku", "type": "IotHubSkuInfo"}, + "capacity": {"key": "capacity", "type": "IotHubCapacity"}, + } + + def __init__(self, *, sku: "_models.IotHubSkuInfo", capacity: "_models.IotHubCapacity", **kwargs: Any) -> None: + """ + :keyword sku: The type of the resource. Required. + :paramtype sku: ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubSkuInfo + :keyword capacity: IotHub capacity. Required. + :paramtype capacity: ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubCapacity + """ + super().__init__(**kwargs) + self.resource_type = None + self.sku = sku + self.capacity = capacity + + +class IotHubSkuDescriptionListResult(_serialization.Model): + """The JSON-serialized array of IotHubSkuDescription objects with a next link. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The array of IotHubSkuDescription. + :vartype value: list[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubSkuDescription] + :ivar next_link: The next link. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[IotHubSkuDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.IotHubSkuDescription"]] = None, **kwargs: Any) -> None: + """ + :keyword value: The array of IotHubSkuDescription. + :paramtype value: list[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubSkuDescription] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class IotHubSkuInfo(_serialization.Model): + """Information about the SKU of the IoT hub. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", "S3", "B1", + "B2", and "B3". + :vartype name: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubSku + :ivar tier: The billing tier for the IoT hub. Known values are: "Free", "Standard", and + "Basic". + :vartype tier: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubSkuTier + :ivar capacity: The number of provisioned IoT Hub units. See: + https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. + :vartype capacity: int + """ + + _validation = { + "name": {"required": True}, + "tier": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, + } + + def __init__(self, *, name: Union[str, "_models.IotHubSku"], capacity: Optional[int] = None, **kwargs: Any) -> None: + """ + :keyword name: The name of the SKU. Required. Known values are: "F1", "S1", "S2", "S3", "B1", + "B2", and "B3". + :paramtype name: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubSku + :keyword capacity: The number of provisioned IoT Hub units. See: + https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. + :paramtype capacity: int + """ + super().__init__(**kwargs) + self.name = name + self.tier = None + self.capacity = capacity + + +class IpFilterRule(_serialization.Model): + """The IP filter rules for the IoT hub. + + All required parameters must be populated in order to send to Azure. + + :ivar filter_name: The name of the IP filter rule. Required. + :vartype filter_name: str + :ivar action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". + :vartype action: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.IpFilterActionType + :ivar ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. + :vartype ip_mask: str + """ + + _validation = { + "filter_name": {"required": True}, + "action": {"required": True}, + "ip_mask": {"required": True}, + } + + _attribute_map = { + "filter_name": {"key": "filterName", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "ip_mask": {"key": "ipMask", "type": "str"}, + } + + def __init__( + self, *, filter_name: str, action: Union[str, "_models.IpFilterActionType"], ip_mask: str, **kwargs: Any + ) -> None: + """ + :keyword filter_name: The name of the IP filter rule. Required. + :paramtype filter_name: str + :keyword action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". + :paramtype action: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.IpFilterActionType + :keyword ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. + :paramtype ip_mask: str + """ + super().__init__(**kwargs) + self.filter_name = filter_name + self.action = action + self.ip_mask = ip_mask + + +class JobResponse(_serialization.Model): + """The properties of the Job Response object. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar job_id: The job identifier. + :vartype job_id: str + :ivar start_time_utc: The start time of the job. + :vartype start_time_utc: ~datetime.datetime + :ivar end_time_utc: The time the job stopped processing. + :vartype end_time_utc: ~datetime.datetime + :ivar type: The type of the job. Known values are: "unknown", "export", "import", "backup", + "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", "rebootDevice", + "factoryResetDevice", "firmwareUpdate", and "import". + :vartype type: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.JobType + :ivar status: The status of the job. Known values are: "unknown", "enqueued", "running", + "completed", "failed", and "cancelled". + :vartype status: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.JobStatus + :ivar failure_reason: If status == failed, this string containing the reason for the failure. + :vartype failure_reason: str + :ivar status_message: The status message for the job. + :vartype status_message: str + :ivar parent_job_id: The job identifier of the parent job, if any. + :vartype parent_job_id: str + """ + + _validation = { + "job_id": {"readonly": True}, + "start_time_utc": {"readonly": True}, + "end_time_utc": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "failure_reason": {"readonly": True}, + "status_message": {"readonly": True}, + "parent_job_id": {"readonly": True}, + } + + _attribute_map = { + "job_id": {"key": "jobId", "type": "str"}, + "start_time_utc": {"key": "startTimeUtc", "type": "rfc-1123"}, + "end_time_utc": {"key": "endTimeUtc", "type": "rfc-1123"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "status_message": {"key": "statusMessage", "type": "str"}, + "parent_job_id": {"key": "parentJobId", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.job_id = None + self.start_time_utc = None + self.end_time_utc = None + self.type = None + self.status = None + self.failure_reason = None + self.status_message = None + self.parent_job_id = None + + +class JobResponseListResult(_serialization.Model): + """The JSON-serialized array of JobResponse objects with a next link. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The array of JobResponse objects. + :vartype value: list[~azure.mgmt.iothub.v2023_06_30_preview.models.JobResponse] + :ivar next_link: The next link. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[JobResponse]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.JobResponse"]] = None, **kwargs: Any) -> None: + """ + :keyword value: The array of JobResponse objects. + :paramtype value: list[~azure.mgmt.iothub.v2023_06_30_preview.models.JobResponse] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class KeyVaultKeyProperties(_serialization.Model): + """The properties of the KeyVault key. + + :ivar key_identifier: The identifier of the key. + :vartype key_identifier: str + :ivar identity: Managed identity properties of KeyVault Key. + :vartype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + """ + + _attribute_map = { + "key_identifier": {"key": "keyIdentifier", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + } + + def __init__( + self, + *, + key_identifier: Optional[str] = None, + identity: Optional["_models.ManagedIdentity"] = None, + **kwargs: Any + ) -> None: + """ + :keyword key_identifier: The identifier of the key. + :paramtype key_identifier: str + :keyword identity: Managed identity properties of KeyVault Key. + :paramtype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + """ + super().__init__(**kwargs) + self.key_identifier = key_identifier + self.identity = identity + + +class ManagedIdentity(_serialization.Model): + """The properties of the Managed identity. + + :ivar user_assigned_identity: The user assigned identity. + :vartype user_assigned_identity: str + """ + + _attribute_map = { + "user_assigned_identity": {"key": "userAssignedIdentity", "type": "str"}, + } + + def __init__(self, *, user_assigned_identity: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword user_assigned_identity: The user assigned identity. + :paramtype user_assigned_identity: str + """ + super().__init__(**kwargs) + self.user_assigned_identity = user_assigned_identity + + +class MatchedRoute(_serialization.Model): + """Routes that matched. + + :ivar properties: Properties of routes that matched. + :vartype properties: ~azure.mgmt.iothub.v2023_06_30_preview.models.RouteProperties + """ + + _attribute_map = { + "properties": {"key": "properties", "type": "RouteProperties"}, + } + + def __init__(self, *, properties: Optional["_models.RouteProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: Properties of routes that matched. + :paramtype properties: ~azure.mgmt.iothub.v2023_06_30_preview.models.RouteProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class MessagingEndpointProperties(_serialization.Model): + """The properties of the messaging endpoints used by this IoT hub. + + :ivar lock_duration_as_iso8601: The lock duration. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. + :vartype lock_duration_as_iso8601: ~datetime.timedelta + :ivar ttl_as_iso8601: The period of time for which a message is available to consume before it + is expired by the IoT hub. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. + :vartype ttl_as_iso8601: ~datetime.timedelta + :ivar max_delivery_count: The number of times the IoT hub attempts to deliver a message. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. + :vartype max_delivery_count: int + """ + + _validation = { + "max_delivery_count": {"maximum": 100, "minimum": 1}, + } + + _attribute_map = { + "lock_duration_as_iso8601": {"key": "lockDurationAsIso8601", "type": "duration"}, + "ttl_as_iso8601": {"key": "ttlAsIso8601", "type": "duration"}, + "max_delivery_count": {"key": "maxDeliveryCount", "type": "int"}, + } + + def __init__( + self, + *, + lock_duration_as_iso8601: Optional[datetime.timedelta] = None, + ttl_as_iso8601: Optional[datetime.timedelta] = None, + max_delivery_count: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword lock_duration_as_iso8601: The lock duration. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. + :paramtype lock_duration_as_iso8601: ~datetime.timedelta + :keyword ttl_as_iso8601: The period of time for which a message is available to consume before + it is expired by the IoT hub. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. + :paramtype ttl_as_iso8601: ~datetime.timedelta + :keyword max_delivery_count: The number of times the IoT hub attempts to deliver a message. + See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. + :paramtype max_delivery_count: int + """ + super().__init__(**kwargs) + self.lock_duration_as_iso8601 = lock_duration_as_iso8601 + self.ttl_as_iso8601 = ttl_as_iso8601 + self.max_delivery_count = max_delivery_count + + +class Name(_serialization.Model): + """Name of Iot Hub type. + + :ivar value: IotHub type. + :vartype value: str + :ivar localized_value: Localized value of name. + :vartype localized_value: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, + } + + def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: IotHub type. + :paramtype value: str + :keyword localized_value: Localized value of name. + :paramtype localized_value: str + """ + super().__init__(**kwargs) + self.value = value + self.localized_value = localized_value + + +class NetworkRuleSetIpRule(_serialization.Model): + """IP Rule to be applied as part of Network Rule Set. + + All required parameters must be populated in order to send to Azure. + + :ivar filter_name: Name of the IP filter rule. Required. + :vartype filter_name: str + :ivar action: IP Filter Action. "Allow" + :vartype action: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.NetworkRuleIPAction + :ivar ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. + :vartype ip_mask: str + """ + + _validation = { + "filter_name": {"required": True}, + "ip_mask": {"required": True}, + } + + _attribute_map = { + "filter_name": {"key": "filterName", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "ip_mask": {"key": "ipMask", "type": "str"}, + } + + def __init__( + self, + *, + filter_name: str, + ip_mask: str, + action: Union[str, "_models.NetworkRuleIPAction"] = "Allow", + **kwargs: Any + ) -> None: + """ + :keyword filter_name: Name of the IP filter rule. Required. + :paramtype filter_name: str + :keyword action: IP Filter Action. "Allow" + :paramtype action: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.NetworkRuleIPAction + :keyword ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. + :paramtype ip_mask: str + """ + super().__init__(**kwargs) + self.filter_name = filter_name + self.action = action + self.ip_mask = ip_mask + + +class NetworkRuleSetProperties(_serialization.Model): + """Network Rule Set Properties of IotHub. + + All required parameters must be populated in order to send to Azure. + + :ivar default_action: Default Action for Network Rule Set. Known values are: "Deny" and + "Allow". + :vartype default_action: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.DefaultAction + :ivar apply_to_built_in_event_hub_endpoint: If True, then Network Rule Set is also applied to + BuiltIn EventHub EndPoint of IotHub. Required. + :vartype apply_to_built_in_event_hub_endpoint: bool + :ivar ip_rules: List of IP Rules. Required. + :vartype ip_rules: list[~azure.mgmt.iothub.v2023_06_30_preview.models.NetworkRuleSetIpRule] + """ + + _validation = { + "apply_to_built_in_event_hub_endpoint": {"required": True}, + "ip_rules": {"required": True}, + } + + _attribute_map = { + "default_action": {"key": "defaultAction", "type": "str"}, + "apply_to_built_in_event_hub_endpoint": {"key": "applyToBuiltInEventHubEndpoint", "type": "bool"}, + "ip_rules": {"key": "ipRules", "type": "[NetworkRuleSetIpRule]"}, + } + + def __init__( + self, + *, + apply_to_built_in_event_hub_endpoint: bool, + ip_rules: List["_models.NetworkRuleSetIpRule"], + default_action: Union[str, "_models.DefaultAction"] = "Deny", + **kwargs: Any + ) -> None: + """ + :keyword default_action: Default Action for Network Rule Set. Known values are: "Deny" and + "Allow". + :paramtype default_action: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.DefaultAction + :keyword apply_to_built_in_event_hub_endpoint: If True, then Network Rule Set is also applied + to BuiltIn EventHub EndPoint of IotHub. Required. + :paramtype apply_to_built_in_event_hub_endpoint: bool + :keyword ip_rules: List of IP Rules. Required. + :paramtype ip_rules: list[~azure.mgmt.iothub.v2023_06_30_preview.models.NetworkRuleSetIpRule] + """ + super().__init__(**kwargs) + self.default_action = default_action + self.apply_to_built_in_event_hub_endpoint = apply_to_built_in_event_hub_endpoint + self.ip_rules = ip_rules + + +class Operation(_serialization.Model): + """IoT Hub REST API operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Operation name: {provider}/{resource}/{read | write | action | delete}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.iothub.v2023_06_30_preview.models.OperationDisplay + """ + + _validation = { + "name": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + } + + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any) -> None: + """ + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.iothub.v2023_06_30_preview.models.OperationDisplay + """ + super().__init__(**kwargs) + self.name = None + self.display = display + + +class OperationDisplay(_serialization.Model): + """The object that represents the operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: Service provider: Microsoft Devices. + :vartype provider: str + :ivar resource: Resource Type: IotHubs. + :vartype resource: str + :ivar operation: Name of the operation. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str + """ + + _validation = { + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None + + +class OperationInputs(_serialization.Model): + """Input values. + + All required parameters must be populated in order to send to Azure. + + :ivar name: The name of the IoT hub to check. Required. + :vartype name: str + """ + + _validation = { + "name": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + } + + def __init__(self, *, name: str, **kwargs: Any) -> None: + """ + :keyword name: The name of the IoT hub to check. Required. + :paramtype name: str + """ + super().__init__(**kwargs) + self.name = name + + +class OperationListResult(_serialization.Model): + """Result of the request to list IoT Hub operations. It contains a list of operations and a URL + link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of IoT Hub operations supported by the Microsoft.Devices resource provider. + :vartype value: list[~azure.mgmt.iothub.v2023_06_30_preview.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class PrivateEndpoint(_serialization.Model): + """The private endpoint property of a private endpoint connection. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource identifier. + :vartype id: str + """ + + _validation = { + "id": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + + +class PrivateEndpointConnection(_serialization.Model): + """The private endpoint connection of an IotHub. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The resource identifier. + :vartype id: str + :ivar name: The resource name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :ivar properties: The properties of a private endpoint connection. Required. + :vartype properties: + ~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateEndpointConnectionProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "properties": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "PrivateEndpointConnectionProperties"}, + } + + def __init__(self, *, properties: "_models.PrivateEndpointConnectionProperties", **kwargs: Any) -> None: + """ + :keyword properties: The properties of a private endpoint connection. Required. + :paramtype properties: + ~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateEndpointConnectionProperties + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.properties = properties + + +class PrivateEndpointConnectionProperties(_serialization.Model): + """The properties of a private endpoint connection. + + All required parameters must be populated in order to send to Azure. + + :ivar private_endpoint: The private endpoint property of a private endpoint connection. + :vartype private_endpoint: ~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateEndpoint + :ivar private_link_service_connection_state: The current state of a private endpoint + connection. Required. + :vartype private_link_service_connection_state: + ~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateLinkServiceConnectionState + """ + + _validation = { + "private_link_service_connection_state": {"required": True}, + } + + _attribute_map = { + "private_endpoint": {"key": "privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + } + + def __init__( + self, + *, + private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState", + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + **kwargs: Any + ) -> None: + """ + :keyword private_endpoint: The private endpoint property of a private endpoint connection. + :paramtype private_endpoint: ~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateEndpoint + :keyword private_link_service_connection_state: The current state of a private endpoint + connection. Required. + :paramtype private_link_service_connection_state: + ~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateLinkServiceConnectionState + """ + super().__init__(**kwargs) + self.private_endpoint = private_endpoint + self.private_link_service_connection_state = private_link_service_connection_state + + +class PrivateLinkResources(_serialization.Model): + """The available private link resources for an IotHub. + + :ivar value: The list of available private link resources for an IotHub. + :vartype value: list[~azure.mgmt.iothub.v2023_06_30_preview.models.GroupIdInformation] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[GroupIdInformation]"}, + } + + def __init__(self, *, value: Optional[List["_models.GroupIdInformation"]] = None, **kwargs: Any) -> None: + """ + :keyword value: The list of available private link resources for an IotHub. + :paramtype value: list[~azure.mgmt.iothub.v2023_06_30_preview.models.GroupIdInformation] + """ + super().__init__(**kwargs) + self.value = value + + +class PrivateLinkServiceConnectionState(_serialization.Model): + """The current state of a private endpoint connection. + + All required parameters must be populated in order to send to Azure. + + :ivar status: The status of a private endpoint connection. Required. Known values are: + "Pending", "Approved", "Rejected", and "Disconnected". + :vartype status: str or + ~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateLinkServiceConnectionStatus + :ivar description: The description for the current state of a private endpoint connection. + Required. + :vartype description: str + :ivar actions_required: Actions required for a private endpoint connection. + :vartype actions_required: str + """ + + _validation = { + "status": {"required": True}, + "description": {"required": True}, + } + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, + } + + def __init__( + self, + *, + status: Union[str, "_models.PrivateLinkServiceConnectionStatus"], + description: str, + actions_required: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword status: The status of a private endpoint connection. Required. Known values are: + "Pending", "Approved", "Rejected", and "Disconnected". + :paramtype status: str or + ~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateLinkServiceConnectionStatus + :keyword description: The description for the current state of a private endpoint connection. + Required. + :paramtype description: str + :keyword actions_required: Actions required for a private endpoint connection. + :paramtype actions_required: str + """ + super().__init__(**kwargs) + self.status = status + self.description = description + self.actions_required = actions_required + + +class RegistryStatistics(_serialization.Model): + """Identity registry statistics. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar total_device_count: The total count of devices in the identity registry. + :vartype total_device_count: int + :ivar enabled_device_count: The count of enabled devices in the identity registry. + :vartype enabled_device_count: int + :ivar disabled_device_count: The count of disabled devices in the identity registry. + :vartype disabled_device_count: int + """ + + _validation = { + "total_device_count": {"readonly": True}, + "enabled_device_count": {"readonly": True}, + "disabled_device_count": {"readonly": True}, + } + + _attribute_map = { + "total_device_count": {"key": "totalDeviceCount", "type": "int"}, + "enabled_device_count": {"key": "enabledDeviceCount", "type": "int"}, + "disabled_device_count": {"key": "disabledDeviceCount", "type": "int"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.total_device_count = None + self.enabled_device_count = None + self.disabled_device_count = None + + +class RootCertificateProperties(_serialization.Model): + """This property store root certificate related information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar enable_root_certificate_v2: This property when set to true, hub will use G2 cert; while + it's set to false, hub uses Baltimore Cert. + :vartype enable_root_certificate_v2: bool + :ivar last_updated_time_utc: the last update time to root certificate flag. + :vartype last_updated_time_utc: ~datetime.datetime + """ + + _validation = { + "last_updated_time_utc": {"readonly": True}, + } + + _attribute_map = { + "enable_root_certificate_v2": {"key": "enableRootCertificateV2", "type": "bool"}, + "last_updated_time_utc": {"key": "lastUpdatedTimeUtc", "type": "iso-8601"}, + } + + def __init__(self, *, enable_root_certificate_v2: Optional[bool] = None, **kwargs: Any) -> None: + """ + :keyword enable_root_certificate_v2: This property when set to true, hub will use G2 cert; + while it's set to false, hub uses Baltimore Cert. + :paramtype enable_root_certificate_v2: bool + """ + super().__init__(**kwargs) + self.enable_root_certificate_v2 = enable_root_certificate_v2 + self.last_updated_time_utc = None + + +class RouteCompilationError(_serialization.Model): + """Compilation error when evaluating route. + + :ivar message: Route error message. + :vartype message: str + :ivar severity: Severity of the route error. Known values are: "error" and "warning". + :vartype severity: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.RouteErrorSeverity + :ivar location: Location where the route error happened. + :vartype location: ~azure.mgmt.iothub.v2023_06_30_preview.models.RouteErrorRange + """ + + _attribute_map = { + "message": {"key": "message", "type": "str"}, + "severity": {"key": "severity", "type": "str"}, + "location": {"key": "location", "type": "RouteErrorRange"}, + } + + def __init__( + self, + *, + message: Optional[str] = None, + severity: Optional[Union[str, "_models.RouteErrorSeverity"]] = None, + location: Optional["_models.RouteErrorRange"] = None, + **kwargs: Any + ) -> None: + """ + :keyword message: Route error message. + :paramtype message: str + :keyword severity: Severity of the route error. Known values are: "error" and "warning". + :paramtype severity: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.RouteErrorSeverity + :keyword location: Location where the route error happened. + :paramtype location: ~azure.mgmt.iothub.v2023_06_30_preview.models.RouteErrorRange + """ + super().__init__(**kwargs) + self.message = message + self.severity = severity + self.location = location + + +class RouteErrorPosition(_serialization.Model): + """Position where the route error happened. + + :ivar line: Line where the route error happened. + :vartype line: int + :ivar column: Column where the route error happened. + :vartype column: int + """ + + _attribute_map = { + "line": {"key": "line", "type": "int"}, + "column": {"key": "column", "type": "int"}, + } + + def __init__(self, *, line: Optional[int] = None, column: Optional[int] = None, **kwargs: Any) -> None: + """ + :keyword line: Line where the route error happened. + :paramtype line: int + :keyword column: Column where the route error happened. + :paramtype column: int + """ + super().__init__(**kwargs) + self.line = line + self.column = column + + +class RouteErrorRange(_serialization.Model): + """Range of route errors. + + :ivar start: Start where the route error happened. + :vartype start: ~azure.mgmt.iothub.v2023_06_30_preview.models.RouteErrorPosition + :ivar end: End where the route error happened. + :vartype end: ~azure.mgmt.iothub.v2023_06_30_preview.models.RouteErrorPosition + """ + + _attribute_map = { + "start": {"key": "start", "type": "RouteErrorPosition"}, + "end": {"key": "end", "type": "RouteErrorPosition"}, + } + + def __init__( + self, + *, + start: Optional["_models.RouteErrorPosition"] = None, + end: Optional["_models.RouteErrorPosition"] = None, + **kwargs: Any + ) -> None: + """ + :keyword start: Start where the route error happened. + :paramtype start: ~azure.mgmt.iothub.v2023_06_30_preview.models.RouteErrorPosition + :keyword end: End where the route error happened. + :paramtype end: ~azure.mgmt.iothub.v2023_06_30_preview.models.RouteErrorPosition + """ + super().__init__(**kwargs) + self.start = start + self.end = end + + +class RouteProperties(_serialization.Model): + """The properties of a routing rule that your IoT hub uses to route messages to endpoints. + + All required parameters must be populated in order to send to Azure. + + :ivar name: The name of the route. The name can only include alphanumeric characters, periods, + underscores, hyphens, has a maximum length of 64 characters, and must be unique. Required. + :vartype name: str + :ivar source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents", + "DeviceConnectionStateEvents", and "MqttBrokerMessages". + :vartype source: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingSource + :ivar condition: The condition that is evaluated to apply the routing rule. If no condition is + provided, it evaluates to true by default. For grammar, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. + :vartype condition: str + :ivar endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. + :vartype endpoint_names: list[str] + :ivar is_enabled: Used to specify whether a route is enabled. Required. + :vartype is_enabled: bool + """ + + _validation = { + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "source": {"required": True}, + "endpoint_names": {"required": True, "max_items": 1, "min_items": 1}, + "is_enabled": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "source": {"key": "source", "type": "str"}, + "condition": {"key": "condition", "type": "str"}, + "endpoint_names": {"key": "endpointNames", "type": "[str]"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + } + + def __init__( + self, + *, + name: str, + source: Union[str, "_models.RoutingSource"], + endpoint_names: List[str], + is_enabled: bool, + condition: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name of the route. The name can only include alphanumeric characters, + periods, underscores, hyphens, has a maximum length of 64 characters, and must be unique. + Required. + :paramtype name: str + :keyword source: The source that the routing rule is to be applied to, such as DeviceMessages. + Required. Known values are: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents", + "DeviceConnectionStateEvents", and "MqttBrokerMessages". + :paramtype source: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingSource + :keyword condition: The condition that is evaluated to apply the routing rule. If no condition + is provided, it evaluates to true by default. For grammar, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-query-language. + :paramtype condition: str + :keyword endpoint_names: The list of endpoints to which messages that satisfy the condition are + routed. Currently only one endpoint is allowed. Required. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Used to specify whether a route is enabled. Required. + :paramtype is_enabled: bool + """ + super().__init__(**kwargs) + self.name = name + self.source = source + self.condition = condition + self.endpoint_names = endpoint_names + self.is_enabled = is_enabled + + +class RoutingCosmosDBSqlApiProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes + """The properties related to a cosmos DB sql container endpoint. + + All required parameters must be populated in order to send to Azure. + + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. + :vartype name: str + :ivar id: Id of the cosmos DB sql container endpoint. + :vartype id: str + :ivar subscription_id: The subscription identifier of the cosmos DB account. + :vartype subscription_id: str + :ivar resource_group: The name of the resource group of the cosmos DB account. + :vartype resource_group: str + :ivar endpoint_uri: The url of the cosmos DB account. It must include the protocol https://. + Required. + :vartype endpoint_uri: str + :ivar authentication_type: Method used to authenticate against the cosmos DB sql container + endpoint. Known values are: "keyBased" and "identityBased". + :vartype authentication_type: str or + ~azure.mgmt.iothub.v2023_06_30_preview.models.AuthenticationType + :ivar identity: Managed identity properties of routing cosmos DB container endpoint. + :vartype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :ivar primary_key: The primary key of the cosmos DB account. + :vartype primary_key: str + :ivar secondary_key: The secondary key of the cosmos DB account. + :vartype secondary_key: str + :ivar database_name: The name of the cosmos DB database in the cosmos DB account. Required. + :vartype database_name: str + :ivar container_name: The name of the cosmos DB sql container in the cosmos DB database. + Required. + :vartype container_name: str + :ivar partition_key_name: The name of the partition key associated with this cosmos DB sql + container if one exists. This is an optional parameter. + :vartype partition_key_name: str + :ivar partition_key_template: The template for generating a synthetic partition key value for + use with this cosmos DB sql container. The template must include at least one of the following + placeholders: {iothub}, {deviceid}, {DD}, {MM}, and {YYYY}. Any one placeholder may be + specified at most once, but order and non-placeholder components are arbitrary. This parameter + is only required if PartitionKeyName is specified. + :vartype partition_key_template: str + """ + + _validation = { + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "endpoint_uri": {"required": True}, + "database_name": {"required": True}, + "container_name": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "database_name": {"key": "databaseName", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "partition_key_name": {"key": "partitionKeyName", "type": "str"}, + "partition_key_template": {"key": "partitionKeyTemplate", "type": "str"}, + } + + def __init__( + self, + *, + name: str, + endpoint_uri: str, + database_name: str, + container_name: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + subscription_id: Optional[str] = None, + resource_group: Optional[str] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, + primary_key: Optional[str] = None, + secondary_key: Optional[str] = None, + partition_key_name: Optional[str] = None, + partition_key_template: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. + :paramtype name: str + :keyword id: Id of the cosmos DB sql container endpoint. + :paramtype id: str + :keyword subscription_id: The subscription identifier of the cosmos DB account. + :paramtype subscription_id: str + :keyword resource_group: The name of the resource group of the cosmos DB account. + :paramtype resource_group: str + :keyword endpoint_uri: The url of the cosmos DB account. It must include the protocol https://. + Required. + :paramtype endpoint_uri: str + :keyword authentication_type: Method used to authenticate against the cosmos DB sql container + endpoint. Known values are: "keyBased" and "identityBased". + :paramtype authentication_type: str or + ~azure.mgmt.iothub.v2023_06_30_preview.models.AuthenticationType + :keyword identity: Managed identity properties of routing cosmos DB container endpoint. + :paramtype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :keyword primary_key: The primary key of the cosmos DB account. + :paramtype primary_key: str + :keyword secondary_key: The secondary key of the cosmos DB account. + :paramtype secondary_key: str + :keyword database_name: The name of the cosmos DB database in the cosmos DB account. Required. + :paramtype database_name: str + :keyword container_name: The name of the cosmos DB sql container in the cosmos DB database. + Required. + :paramtype container_name: str + :keyword partition_key_name: The name of the partition key associated with this cosmos DB sql + container if one exists. This is an optional parameter. + :paramtype partition_key_name: str + :keyword partition_key_template: The template for generating a synthetic partition key value + for use with this cosmos DB sql container. The template must include at least one of the + following placeholders: {iothub}, {deviceid}, {DD}, {MM}, and {YYYY}. Any one placeholder may + be specified at most once, but order and non-placeholder components are arbitrary. This + parameter is only required if PartitionKeyName is specified. + :paramtype partition_key_template: str + """ + super().__init__(**kwargs) + self.name = name + self.id = id + self.subscription_id = subscription_id + self.resource_group = resource_group + self.endpoint_uri = endpoint_uri + self.authentication_type = authentication_type + self.identity = identity + self.primary_key = primary_key + self.secondary_key = secondary_key + self.database_name = database_name + self.container_name = container_name + self.partition_key_name = partition_key_name + self.partition_key_template = partition_key_template + + +class RoutingEndpoints(_serialization.Model): + """The properties related to the custom endpoints to which your IoT hub routes messages based on + the routing rules. A maximum of 10 custom endpoints are allowed across all endpoint types for + paid hubs and only 1 custom endpoint is allowed across all endpoint types for free hubs. + + :ivar service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the + messages to, based on the routing rules. + :vartype service_bus_queues: + list[~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingServiceBusQueueEndpointProperties] + :ivar service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the + messages to, based on the routing rules. + :vartype service_bus_topics: + list[~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingServiceBusTopicEndpointProperties] + :ivar event_hubs: The list of Event Hubs endpoints that IoT hub routes messages to, based on + the routing rules. This list does not include the built-in Event Hubs endpoint. + :vartype event_hubs: + list[~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingEventHubProperties] + :ivar storage_containers: The list of storage container endpoints that IoT hub routes messages + to, based on the routing rules. + :vartype storage_containers: + list[~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingStorageContainerProperties] + :ivar cosmos_db_sql_containers: The list of Cosmos DB container endpoints that IoT hub routes + messages to, based on the routing rules. + :vartype cosmos_db_sql_containers: + list[~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingCosmosDBSqlApiProperties] + """ + + _attribute_map = { + "service_bus_queues": {"key": "serviceBusQueues", "type": "[RoutingServiceBusQueueEndpointProperties]"}, + "service_bus_topics": {"key": "serviceBusTopics", "type": "[RoutingServiceBusTopicEndpointProperties]"}, + "event_hubs": {"key": "eventHubs", "type": "[RoutingEventHubProperties]"}, + "storage_containers": {"key": "storageContainers", "type": "[RoutingStorageContainerProperties]"}, + "cosmos_db_sql_containers": {"key": "cosmosDBSqlContainers", "type": "[RoutingCosmosDBSqlApiProperties]"}, + } + + def __init__( + self, + *, + service_bus_queues: Optional[List["_models.RoutingServiceBusQueueEndpointProperties"]] = None, + service_bus_topics: Optional[List["_models.RoutingServiceBusTopicEndpointProperties"]] = None, + event_hubs: Optional[List["_models.RoutingEventHubProperties"]] = None, + storage_containers: Optional[List["_models.RoutingStorageContainerProperties"]] = None, + cosmos_db_sql_containers: Optional[List["_models.RoutingCosmosDBSqlApiProperties"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the + messages to, based on the routing rules. + :paramtype service_bus_queues: + list[~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingServiceBusQueueEndpointProperties] + :keyword service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes + the messages to, based on the routing rules. + :paramtype service_bus_topics: + list[~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingServiceBusTopicEndpointProperties] + :keyword event_hubs: The list of Event Hubs endpoints that IoT hub routes messages to, based on + the routing rules. This list does not include the built-in Event Hubs endpoint. + :paramtype event_hubs: + list[~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingEventHubProperties] + :keyword storage_containers: The list of storage container endpoints that IoT hub routes + messages to, based on the routing rules. + :paramtype storage_containers: + list[~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingStorageContainerProperties] + :keyword cosmos_db_sql_containers: The list of Cosmos DB container endpoints that IoT hub + routes messages to, based on the routing rules. + :paramtype cosmos_db_sql_containers: + list[~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingCosmosDBSqlApiProperties] + """ + super().__init__(**kwargs) + self.service_bus_queues = service_bus_queues + self.service_bus_topics = service_bus_topics + self.event_hubs = event_hubs + self.storage_containers = storage_containers + self.cosmos_db_sql_containers = cosmos_db_sql_containers + + +class RoutingEventHubProperties(_serialization.Model): + """The properties related to an event hub endpoint. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Id of the event hub endpoint. + :vartype id: str + :ivar connection_string: The connection string of the event hub endpoint. + :vartype connection_string: str + :ivar endpoint_uri: The url of the event hub endpoint. It must include the protocol sb://. + :vartype endpoint_uri: str + :ivar entity_path: Event hub name on the event hub namespace. + :vartype entity_path: str + :ivar authentication_type: Method used to authenticate against the event hub endpoint. Known + values are: "keyBased" and "identityBased". + :vartype authentication_type: str or + ~azure.mgmt.iothub.v2023_06_30_preview.models.AuthenticationType + :ivar identity: Managed identity properties of routing event hub endpoint. + :vartype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. + :vartype name: str + :ivar subscription_id: The subscription identifier of the event hub endpoint. + :vartype subscription_id: str + :ivar resource_group: The name of the resource group of the event hub endpoint. + :vartype resource_group: str + """ + + _validation = { + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "entity_path": {"key": "entityPath", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + } + + def __init__( + self, + *, + name: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + connection_string: Optional[str] = None, + endpoint_uri: Optional[str] = None, + entity_path: Optional[str] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, + subscription_id: Optional[str] = None, + resource_group: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Id of the event hub endpoint. + :paramtype id: str + :keyword connection_string: The connection string of the event hub endpoint. + :paramtype connection_string: str + :keyword endpoint_uri: The url of the event hub endpoint. It must include the protocol sb://. + :paramtype endpoint_uri: str + :keyword entity_path: Event hub name on the event hub namespace. + :paramtype entity_path: str + :keyword authentication_type: Method used to authenticate against the event hub endpoint. Known + values are: "keyBased" and "identityBased". + :paramtype authentication_type: str or + ~azure.mgmt.iothub.v2023_06_30_preview.models.AuthenticationType + :keyword identity: Managed identity properties of routing event hub endpoint. + :paramtype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. + :paramtype name: str + :keyword subscription_id: The subscription identifier of the event hub endpoint. + :paramtype subscription_id: str + :keyword resource_group: The name of the resource group of the event hub endpoint. + :paramtype resource_group: str + """ + super().__init__(**kwargs) + self.id = id + self.connection_string = connection_string + self.endpoint_uri = endpoint_uri + self.entity_path = entity_path + self.authentication_type = authentication_type + self.identity = identity + self.name = name + self.subscription_id = subscription_id + self.resource_group = resource_group + + +class RoutingMessage(_serialization.Model): + """Routing message. + + :ivar body: Body of routing message. + :vartype body: str + :ivar app_properties: App properties. + :vartype app_properties: dict[str, str] + :ivar system_properties: System properties. + :vartype system_properties: dict[str, str] + """ + + _attribute_map = { + "body": {"key": "body", "type": "str"}, + "app_properties": {"key": "appProperties", "type": "{str}"}, + "system_properties": {"key": "systemProperties", "type": "{str}"}, + } + + def __init__( + self, + *, + body: Optional[str] = None, + app_properties: Optional[Dict[str, str]] = None, + system_properties: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword body: Body of routing message. + :paramtype body: str + :keyword app_properties: App properties. + :paramtype app_properties: dict[str, str] + :keyword system_properties: System properties. + :paramtype system_properties: dict[str, str] + """ + super().__init__(**kwargs) + self.body = body + self.app_properties = app_properties + self.system_properties = system_properties + + +class RoutingProperties(_serialization.Model): + """The routing related properties of the IoT hub. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. + + :ivar endpoints: The properties related to the custom endpoints to which your IoT hub routes + messages based on the routing rules. A maximum of 10 custom endpoints are allowed across all + endpoint types for paid hubs and only 1 custom endpoint is allowed across all endpoint types + for free hubs. + :vartype endpoints: ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingEndpoints + :ivar routes: The list of user-provided routing rules that the IoT hub uses to route messages + to built-in and custom endpoints. A maximum of 100 routing rules are allowed for paid hubs and + a maximum of 5 routing rules are allowed for free hubs. + :vartype routes: list[~azure.mgmt.iothub.v2023_06_30_preview.models.RouteProperties] + :ivar fallback_route: The properties of the route that is used as a fall-back route when none + of the conditions specified in the 'routes' section are met. This is an optional parameter. + When this property is not set, the messages which do not meet any of the conditions specified + in the 'routes' section get routed to the built-in eventhub endpoint. + :vartype fallback_route: ~azure.mgmt.iothub.v2023_06_30_preview.models.FallbackRouteProperties + :ivar enrichments: The list of user-provided enrichments that the IoT hub applies to messages + to be delivered to built-in and custom endpoints. See: https://aka.ms/telemetryoneventgrid. + :vartype enrichments: list[~azure.mgmt.iothub.v2023_06_30_preview.models.EnrichmentProperties] + """ + + _attribute_map = { + "endpoints": {"key": "endpoints", "type": "RoutingEndpoints"}, + "routes": {"key": "routes", "type": "[RouteProperties]"}, + "fallback_route": {"key": "fallbackRoute", "type": "FallbackRouteProperties"}, + "enrichments": {"key": "enrichments", "type": "[EnrichmentProperties]"}, + } + + def __init__( + self, + *, + endpoints: Optional["_models.RoutingEndpoints"] = None, + routes: Optional[List["_models.RouteProperties"]] = None, + fallback_route: Optional["_models.FallbackRouteProperties"] = None, + enrichments: Optional[List["_models.EnrichmentProperties"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword endpoints: The properties related to the custom endpoints to which your IoT hub routes + messages based on the routing rules. A maximum of 10 custom endpoints are allowed across all + endpoint types for paid hubs and only 1 custom endpoint is allowed across all endpoint types + for free hubs. + :paramtype endpoints: ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingEndpoints + :keyword routes: The list of user-provided routing rules that the IoT hub uses to route + messages to built-in and custom endpoints. A maximum of 100 routing rules are allowed for paid + hubs and a maximum of 5 routing rules are allowed for free hubs. + :paramtype routes: list[~azure.mgmt.iothub.v2023_06_30_preview.models.RouteProperties] + :keyword fallback_route: The properties of the route that is used as a fall-back route when + none of the conditions specified in the 'routes' section are met. This is an optional + parameter. When this property is not set, the messages which do not meet any of the conditions + specified in the 'routes' section get routed to the built-in eventhub endpoint. + :paramtype fallback_route: + ~azure.mgmt.iothub.v2023_06_30_preview.models.FallbackRouteProperties + :keyword enrichments: The list of user-provided enrichments that the IoT hub applies to + messages to be delivered to built-in and custom endpoints. See: + https://aka.ms/telemetryoneventgrid. + :paramtype enrichments: + list[~azure.mgmt.iothub.v2023_06_30_preview.models.EnrichmentProperties] + """ + super().__init__(**kwargs) + self.endpoints = endpoints + self.routes = routes + self.fallback_route = fallback_route + self.enrichments = enrichments + + +class RoutingServiceBusQueueEndpointProperties(_serialization.Model): + """The properties related to service bus queue endpoint types. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Id of the service bus queue endpoint. + :vartype id: str + :ivar connection_string: The connection string of the service bus queue endpoint. + :vartype connection_string: str + :ivar endpoint_uri: The url of the service bus queue endpoint. It must include the protocol + sb://. + :vartype endpoint_uri: str + :ivar entity_path: Queue name on the service bus namespace. + :vartype entity_path: str + :ivar authentication_type: Method used to authenticate against the service bus queue endpoint. + Known values are: "keyBased" and "identityBased". + :vartype authentication_type: str or + ~azure.mgmt.iothub.v2023_06_30_preview.models.AuthenticationType + :ivar identity: Managed identity properties of routing service bus queue endpoint. + :vartype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual queue name. Required. + :vartype name: str + :ivar subscription_id: The subscription identifier of the service bus queue endpoint. + :vartype subscription_id: str + :ivar resource_group: The name of the resource group of the service bus queue endpoint. + :vartype resource_group: str + """ + + _validation = { + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "entity_path": {"key": "entityPath", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + } + + def __init__( + self, + *, + name: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + connection_string: Optional[str] = None, + endpoint_uri: Optional[str] = None, + entity_path: Optional[str] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, + subscription_id: Optional[str] = None, + resource_group: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Id of the service bus queue endpoint. + :paramtype id: str + :keyword connection_string: The connection string of the service bus queue endpoint. + :paramtype connection_string: str + :keyword endpoint_uri: The url of the service bus queue endpoint. It must include the protocol + sb://. + :paramtype endpoint_uri: str + :keyword entity_path: Queue name on the service bus namespace. + :paramtype entity_path: str + :keyword authentication_type: Method used to authenticate against the service bus queue + endpoint. Known values are: "keyBased" and "identityBased". + :paramtype authentication_type: str or + ~azure.mgmt.iothub.v2023_06_30_preview.models.AuthenticationType + :keyword identity: Managed identity properties of routing service bus queue endpoint. + :paramtype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual queue name. Required. + :paramtype name: str + :keyword subscription_id: The subscription identifier of the service bus queue endpoint. + :paramtype subscription_id: str + :keyword resource_group: The name of the resource group of the service bus queue endpoint. + :paramtype resource_group: str + """ + super().__init__(**kwargs) + self.id = id + self.connection_string = connection_string + self.endpoint_uri = endpoint_uri + self.entity_path = entity_path + self.authentication_type = authentication_type + self.identity = identity + self.name = name + self.subscription_id = subscription_id + self.resource_group = resource_group + + +class RoutingServiceBusTopicEndpointProperties(_serialization.Model): + """The properties related to service bus topic endpoint types. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Id of the service bus topic endpoint. + :vartype id: str + :ivar connection_string: The connection string of the service bus topic endpoint. + :vartype connection_string: str + :ivar endpoint_uri: The url of the service bus topic endpoint. It must include the protocol + sb://. + :vartype endpoint_uri: str + :ivar entity_path: Queue name on the service bus topic. + :vartype entity_path: str + :ivar authentication_type: Method used to authenticate against the service bus topic endpoint. + Known values are: "keyBased" and "identityBased". + :vartype authentication_type: str or + ~azure.mgmt.iothub.v2023_06_30_preview.models.AuthenticationType + :ivar identity: Managed identity properties of routing service bus topic endpoint. + :vartype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual topic name. + Required. + :vartype name: str + :ivar subscription_id: The subscription identifier of the service bus topic endpoint. + :vartype subscription_id: str + :ivar resource_group: The name of the resource group of the service bus topic endpoint. + :vartype resource_group: str + """ + + _validation = { + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "entity_path": {"key": "entityPath", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + } + + def __init__( + self, + *, + name: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + connection_string: Optional[str] = None, + endpoint_uri: Optional[str] = None, + entity_path: Optional[str] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, + subscription_id: Optional[str] = None, + resource_group: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Id of the service bus topic endpoint. + :paramtype id: str + :keyword connection_string: The connection string of the service bus topic endpoint. + :paramtype connection_string: str + :keyword endpoint_uri: The url of the service bus topic endpoint. It must include the protocol + sb://. + :paramtype endpoint_uri: str + :keyword entity_path: Queue name on the service bus topic. + :paramtype entity_path: str + :keyword authentication_type: Method used to authenticate against the service bus topic + endpoint. Known values are: "keyBased" and "identityBased". + :paramtype authentication_type: str or + ~azure.mgmt.iothub.v2023_06_30_preview.models.AuthenticationType + :keyword identity: Managed identity properties of routing service bus topic endpoint. + :paramtype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. The name need not be the same as the actual topic name. + Required. + :paramtype name: str + :keyword subscription_id: The subscription identifier of the service bus topic endpoint. + :paramtype subscription_id: str + :keyword resource_group: The name of the resource group of the service bus topic endpoint. + :paramtype resource_group: str + """ + super().__init__(**kwargs) + self.id = id + self.connection_string = connection_string + self.endpoint_uri = endpoint_uri + self.entity_path = entity_path + self.authentication_type = authentication_type + self.identity = identity + self.name = name + self.subscription_id = subscription_id + self.resource_group = resource_group + + +class RoutingStorageContainerProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes + """The properties related to a storage container endpoint. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Id of the storage container endpoint. + :vartype id: str + :ivar connection_string: The connection string of the storage account. + :vartype connection_string: str + :ivar endpoint_uri: The url of the storage endpoint. It must include the protocol https://. + :vartype endpoint_uri: str + :ivar authentication_type: Method used to authenticate against the storage endpoint. Known + values are: "keyBased" and "identityBased". + :vartype authentication_type: str or + ~azure.mgmt.iothub.v2023_06_30_preview.models.AuthenticationType + :ivar identity: Managed identity properties of routing storage endpoint. + :vartype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :ivar name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. + :vartype name: str + :ivar subscription_id: The subscription identifier of the storage account. + :vartype subscription_id: str + :ivar resource_group: The name of the resource group of the storage account. + :vartype resource_group: str + :ivar container_name: The name of storage container in the storage account. Required. + :vartype container_name: str + :ivar file_name_format: File name format for the blob. Default format is + {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be + reordered. + :vartype file_name_format: str + :ivar batch_frequency_in_seconds: Time interval at which blobs are written to storage. Value + should be between 60 and 720 seconds. Default value is 300 seconds. + :vartype batch_frequency_in_seconds: int + :ivar max_chunk_size_in_bytes: Maximum number of bytes for each blob written to storage. Value + should be between 10485760(10MB) and 524288000(500MB). Default value is 314572800(300MB). + :vartype max_chunk_size_in_bytes: int + :ivar encoding: Encoding that is used to serialize messages to blobs. Supported values are + 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Known values are: "Avro", + "AvroDeflate", and "JSON". + :vartype encoding: str or + ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingStorageContainerPropertiesEncoding + """ + + _validation = { + "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, + "container_name": {"required": True}, + "batch_frequency_in_seconds": {"maximum": 720, "minimum": 60}, + "max_chunk_size_in_bytes": {"maximum": 524288000, "minimum": 10485760}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "endpoint_uri": {"key": "endpointUri", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "resource_group": {"key": "resourceGroup", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "file_name_format": {"key": "fileNameFormat", "type": "str"}, + "batch_frequency_in_seconds": {"key": "batchFrequencyInSeconds", "type": "int"}, + "max_chunk_size_in_bytes": {"key": "maxChunkSizeInBytes", "type": "int"}, + "encoding": {"key": "encoding", "type": "str"}, + } + + def __init__( + self, + *, + name: str, + container_name: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + connection_string: Optional[str] = None, + endpoint_uri: Optional[str] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, + subscription_id: Optional[str] = None, + resource_group: Optional[str] = None, + file_name_format: Optional[str] = None, + batch_frequency_in_seconds: Optional[int] = None, + max_chunk_size_in_bytes: Optional[int] = None, + encoding: Optional[Union[str, "_models.RoutingStorageContainerPropertiesEncoding"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Id of the storage container endpoint. + :paramtype id: str + :keyword connection_string: The connection string of the storage account. + :paramtype connection_string: str + :keyword endpoint_uri: The url of the storage endpoint. It must include the protocol https://. + :paramtype endpoint_uri: str + :keyword authentication_type: Method used to authenticate against the storage endpoint. Known + values are: "keyBased" and "identityBased". + :paramtype authentication_type: str or + ~azure.mgmt.iothub.v2023_06_30_preview.models.AuthenticationType + :keyword identity: Managed identity properties of routing storage endpoint. + :paramtype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :keyword name: The name that identifies this endpoint. The name can only include alphanumeric + characters, periods, underscores, hyphens and has a maximum length of 64 characters. The + following names are reserved: events, fileNotifications, $default. Endpoint names must be + unique across endpoint types. Required. + :paramtype name: str + :keyword subscription_id: The subscription identifier of the storage account. + :paramtype subscription_id: str + :keyword resource_group: The name of the resource group of the storage account. + :paramtype resource_group: str + :keyword container_name: The name of storage container in the storage account. Required. + :paramtype container_name: str + :keyword file_name_format: File name format for the blob. Default format is + {iothub}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}. All parameters are mandatory but can be + reordered. + :paramtype file_name_format: str + :keyword batch_frequency_in_seconds: Time interval at which blobs are written to storage. Value + should be between 60 and 720 seconds. Default value is 300 seconds. + :paramtype batch_frequency_in_seconds: int + :keyword max_chunk_size_in_bytes: Maximum number of bytes for each blob written to storage. + Value should be between 10485760(10MB) and 524288000(500MB). Default value is 314572800(300MB). + :paramtype max_chunk_size_in_bytes: int + :keyword encoding: Encoding that is used to serialize messages to blobs. Supported values are + 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Known values are: "Avro", + "AvroDeflate", and "JSON". + :paramtype encoding: str or + ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingStorageContainerPropertiesEncoding + """ + super().__init__(**kwargs) + self.id = id + self.connection_string = connection_string + self.endpoint_uri = endpoint_uri + self.authentication_type = authentication_type + self.identity = identity + self.name = name + self.subscription_id = subscription_id + self.resource_group = resource_group + self.container_name = container_name + self.file_name_format = file_name_format + self.batch_frequency_in_seconds = batch_frequency_in_seconds + self.max_chunk_size_in_bytes = max_chunk_size_in_bytes + self.encoding = encoding + + +class RoutingTwin(_serialization.Model): + """Twin reference input parameter. This is an optional parameter. + + :ivar tags: Twin Tags. + :vartype tags: JSON + :ivar properties: + :vartype properties: ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingTwinProperties + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "object"}, + "properties": {"key": "properties", "type": "RoutingTwinProperties"}, + } + + def __init__( + self, + *, + tags: Optional[JSON] = None, + properties: Optional["_models.RoutingTwinProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Twin Tags. + :paramtype tags: JSON + :keyword properties: + :paramtype properties: ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingTwinProperties + """ + super().__init__(**kwargs) + self.tags = tags + self.properties = properties + + +class RoutingTwinProperties(_serialization.Model): + """RoutingTwinProperties. + + :ivar desired: Twin desired properties. + :vartype desired: JSON + :ivar reported: Twin desired properties. + :vartype reported: JSON + """ + + _attribute_map = { + "desired": {"key": "desired", "type": "object"}, + "reported": {"key": "reported", "type": "object"}, + } + + def __init__(self, *, desired: Optional[JSON] = None, reported: Optional[JSON] = None, **kwargs: Any) -> None: + """ + :keyword desired: Twin desired properties. + :paramtype desired: JSON + :keyword reported: Twin desired properties. + :paramtype reported: JSON + """ + super().__init__(**kwargs) + self.desired = desired + self.reported = reported + + +class SharedAccessSignatureAuthorizationRule(_serialization.Model): + """The properties of an IoT hub shared access policy. + + All required parameters must be populated in order to send to Azure. + + :ivar key_name: The name of the shared access policy. Required. + :vartype key_name: str + :ivar primary_key: The primary key. + :vartype primary_key: str + :ivar secondary_key: The secondary key. + :vartype secondary_key: str + :ivar rights: The permissions assigned to the shared access policy. Required. Known values are: + "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, + ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", + "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", + "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :vartype rights: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.AccessRights + """ + + _validation = { + "key_name": {"required": True}, + "rights": {"required": True}, + } + + _attribute_map = { + "key_name": {"key": "keyName", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "rights": {"key": "rights", "type": "str"}, + } + + def __init__( + self, + *, + key_name: str, + rights: Union[str, "_models.AccessRights"], + primary_key: Optional[str] = None, + secondary_key: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword key_name: The name of the shared access policy. Required. + :paramtype key_name: str + :keyword primary_key: The primary key. + :paramtype primary_key: str + :keyword secondary_key: The secondary key. + :paramtype secondary_key: str + :keyword rights: The permissions assigned to the shared access policy. Required. Known values + are: "RegistryRead", "RegistryWrite", "ServiceConnect", "DeviceConnect", "RegistryRead, + RegistryWrite", "RegistryRead, ServiceConnect", "RegistryRead, DeviceConnect", "RegistryWrite, + ServiceConnect", "RegistryWrite, DeviceConnect", "ServiceConnect, DeviceConnect", + "RegistryRead, RegistryWrite, ServiceConnect", "RegistryRead, RegistryWrite, DeviceConnect", + "RegistryRead, ServiceConnect, DeviceConnect", "RegistryWrite, ServiceConnect, DeviceConnect", + and "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :paramtype rights: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.AccessRights + """ + super().__init__(**kwargs) + self.key_name = key_name + self.primary_key = primary_key + self.secondary_key = secondary_key + self.rights = rights + + +class SharedAccessSignatureAuthorizationRuleListResult(_serialization.Model): + """The list of shared access policies with a next link. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of shared access policies. + :vartype value: + list[~azure.mgmt.iothub.v2023_06_30_preview.models.SharedAccessSignatureAuthorizationRule] + :ivar next_link: The next link. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SharedAccessSignatureAuthorizationRule]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The list of shared access policies. + :paramtype value: + list[~azure.mgmt.iothub.v2023_06_30_preview.models.SharedAccessSignatureAuthorizationRule] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class StorageEndpointProperties(_serialization.Model): + """The properties of the Azure Storage endpoint for file upload. + + All required parameters must be populated in order to send to Azure. + + :ivar sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + file upload is valid. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. + :vartype sas_ttl_as_iso8601: ~datetime.timedelta + :ivar connection_string: The connection string for the Azure Storage account to which files are + uploaded. Required. + :vartype connection_string: str + :ivar container_name: The name of the root container where you upload files. The container need + not exist but should be creatable using the connectionString specified. Required. + :vartype container_name: str + :ivar authentication_type: Specifies authentication type being used for connecting to the + storage account. Known values are: "keyBased" and "identityBased". + :vartype authentication_type: str or + ~azure.mgmt.iothub.v2023_06_30_preview.models.AuthenticationType + :ivar identity: Managed identity properties of storage endpoint for file upload. + :vartype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + """ + + _validation = { + "connection_string": {"required": True}, + "container_name": {"required": True}, + } + + _attribute_map = { + "sas_ttl_as_iso8601": {"key": "sasTtlAsIso8601", "type": "duration"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "authentication_type": {"key": "authenticationType", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + } + + def __init__( + self, + *, + connection_string: str, + container_name: str, + sas_ttl_as_iso8601: Optional[datetime.timedelta] = None, + authentication_type: Optional[Union[str, "_models.AuthenticationType"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, + **kwargs: Any + ) -> None: + """ + :keyword sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + file upload is valid. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. + :paramtype sas_ttl_as_iso8601: ~datetime.timedelta + :keyword connection_string: The connection string for the Azure Storage account to which files + are uploaded. Required. + :paramtype connection_string: str + :keyword container_name: The name of the root container where you upload files. The container + need not exist but should be creatable using the connectionString specified. Required. + :paramtype container_name: str + :keyword authentication_type: Specifies authentication type being used for connecting to the + storage account. Known values are: "keyBased" and "identityBased". + :paramtype authentication_type: str or + ~azure.mgmt.iothub.v2023_06_30_preview.models.AuthenticationType + :keyword identity: Managed identity properties of storage endpoint for file upload. + :paramtype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + """ + super().__init__(**kwargs) + self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 + self.connection_string = connection_string + self.container_name = container_name + self.authentication_type = authentication_type + self.identity = identity + + +class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or + ~azure.mgmt.iothub.v2023_06_30_preview.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.iothub.v2023_06_30_preview.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class TagsResource(_serialization.Model): + """A container holding only the Tags for a resource, allowing the user to update the tags on an + IoT Hub instance. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags + + +class TestAllRoutesInput(_serialization.Model): + """Input for testing all routes. + + :ivar routing_source: Routing source. Known values are: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", + "DigitalTwinChangeEvents", "DeviceConnectionStateEvents", and "MqttBrokerMessages". + :vartype routing_source: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingSource + :ivar message: Routing message. + :vartype message: ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingMessage + :ivar twin: Routing Twin Reference. + :vartype twin: ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingTwin + """ + + _attribute_map = { + "routing_source": {"key": "routingSource", "type": "str"}, + "message": {"key": "message", "type": "RoutingMessage"}, + "twin": {"key": "twin", "type": "RoutingTwin"}, + } + + def __init__( + self, + *, + routing_source: Optional[Union[str, "_models.RoutingSource"]] = None, + message: Optional["_models.RoutingMessage"] = None, + twin: Optional["_models.RoutingTwin"] = None, + **kwargs: Any + ) -> None: + """ + :keyword routing_source: Routing source. Known values are: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", + "DigitalTwinChangeEvents", "DeviceConnectionStateEvents", and "MqttBrokerMessages". + :paramtype routing_source: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingSource + :keyword message: Routing message. + :paramtype message: ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingMessage + :keyword twin: Routing Twin Reference. + :paramtype twin: ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingTwin + """ + super().__init__(**kwargs) + self.routing_source = routing_source + self.message = message + self.twin = twin + + +class TestAllRoutesResult(_serialization.Model): + """Result of testing all routes. + + :ivar routes: JSON-serialized array of matched routes. + :vartype routes: list[~azure.mgmt.iothub.v2023_06_30_preview.models.MatchedRoute] + """ + + _attribute_map = { + "routes": {"key": "routes", "type": "[MatchedRoute]"}, + } + + def __init__(self, *, routes: Optional[List["_models.MatchedRoute"]] = None, **kwargs: Any) -> None: + """ + :keyword routes: JSON-serialized array of matched routes. + :paramtype routes: list[~azure.mgmt.iothub.v2023_06_30_preview.models.MatchedRoute] + """ + super().__init__(**kwargs) + self.routes = routes + + +class TestRouteInput(_serialization.Model): + """Input for testing route. + + All required parameters must be populated in order to send to Azure. + + :ivar message: Routing message. + :vartype message: ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingMessage + :ivar route: Route properties. Required. + :vartype route: ~azure.mgmt.iothub.v2023_06_30_preview.models.RouteProperties + :ivar twin: Routing Twin Reference. + :vartype twin: ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingTwin + """ + + _validation = { + "route": {"required": True}, + } + + _attribute_map = { + "message": {"key": "message", "type": "RoutingMessage"}, + "route": {"key": "route", "type": "RouteProperties"}, + "twin": {"key": "twin", "type": "RoutingTwin"}, + } + + def __init__( + self, + *, + route: "_models.RouteProperties", + message: Optional["_models.RoutingMessage"] = None, + twin: Optional["_models.RoutingTwin"] = None, + **kwargs: Any + ) -> None: + """ + :keyword message: Routing message. + :paramtype message: ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingMessage + :keyword route: Route properties. Required. + :paramtype route: ~azure.mgmt.iothub.v2023_06_30_preview.models.RouteProperties + :keyword twin: Routing Twin Reference. + :paramtype twin: ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingTwin + """ + super().__init__(**kwargs) + self.message = message + self.route = route + self.twin = twin + + +class TestRouteResult(_serialization.Model): + """Result of testing one route. + + :ivar result: Result of testing route. Known values are: "undefined", "false", and "true". + :vartype result: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.TestResultStatus + :ivar details: Detailed result of testing route. + :vartype details: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestRouteResultDetails + """ + + _attribute_map = { + "result": {"key": "result", "type": "str"}, + "details": {"key": "details", "type": "TestRouteResultDetails"}, + } + + def __init__( + self, + *, + result: Optional[Union[str, "_models.TestResultStatus"]] = None, + details: Optional["_models.TestRouteResultDetails"] = None, + **kwargs: Any + ) -> None: + """ + :keyword result: Result of testing route. Known values are: "undefined", "false", and "true". + :paramtype result: str or ~azure.mgmt.iothub.v2023_06_30_preview.models.TestResultStatus + :keyword details: Detailed result of testing route. + :paramtype details: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestRouteResultDetails + """ + super().__init__(**kwargs) + self.result = result + self.details = details + + +class TestRouteResultDetails(_serialization.Model): + """Detailed result of testing a route. + + :ivar compilation_errors: JSON-serialized list of route compilation errors. + :vartype compilation_errors: + list[~azure.mgmt.iothub.v2023_06_30_preview.models.RouteCompilationError] + """ + + _attribute_map = { + "compilation_errors": {"key": "compilationErrors", "type": "[RouteCompilationError]"}, + } + + def __init__( + self, *, compilation_errors: Optional[List["_models.RouteCompilationError"]] = None, **kwargs: Any + ) -> None: + """ + :keyword compilation_errors: JSON-serialized list of route compilation errors. + :paramtype compilation_errors: + list[~azure.mgmt.iothub.v2023_06_30_preview.models.RouteCompilationError] + """ + super().__init__(**kwargs) + self.compilation_errors = compilation_errors + + +class UserSubscriptionQuota(_serialization.Model): + """User subscription quota response. + + :ivar id: IotHub type id. + :vartype id: str + :ivar type: Response type. + :vartype type: str + :ivar unit: Unit of IotHub type. + :vartype unit: str + :ivar current_value: Current number of IotHub type. + :vartype current_value: int + :ivar limit: Numerical limit on IotHub type. + :vartype limit: int + :ivar name: IotHub type. + :vartype name: ~azure.mgmt.iothub.v2023_06_30_preview.models.Name + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "Name"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + type: Optional[str] = None, + unit: Optional[str] = None, + current_value: Optional[int] = None, + limit: Optional[int] = None, + name: Optional["_models.Name"] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: IotHub type id. + :paramtype id: str + :keyword type: Response type. + :paramtype type: str + :keyword unit: Unit of IotHub type. + :paramtype unit: str + :keyword current_value: Current number of IotHub type. + :paramtype current_value: int + :keyword limit: Numerical limit on IotHub type. + :paramtype limit: int + :keyword name: IotHub type. + :paramtype name: ~azure.mgmt.iothub.v2023_06_30_preview.models.Name + """ + super().__init__(**kwargs) + self.id = id + self.type = type + self.unit = unit + self.current_value = current_value + self.limit = limit + self.name = name + + +class UserSubscriptionQuotaListResult(_serialization.Model): + """Json-serialized array of User subscription quota response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: + :vartype value: list[~azure.mgmt.iothub.v2023_06_30_preview.models.UserSubscriptionQuota] + :ivar next_link: + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[UserSubscriptionQuota]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.UserSubscriptionQuota"]] = None, **kwargs: Any) -> None: + """ + :keyword value: + :paramtype value: list[~azure.mgmt.iothub.v2023_06_30_preview.models.UserSubscriptionQuota] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/models/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/__init__.py new file mode 100644 index 000000000000..96fcc782e2e1 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/__init__.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations import Operations +from ._iot_hub_resource_operations import IotHubResourceOperations +from ._resource_provider_common_operations import ResourceProviderCommonOperations +from ._certificates_operations import CertificatesOperations +from ._iot_hub_operations import IotHubOperations +from ._private_link_resources_operations import PrivateLinkResourcesOperations +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "Operations", + "IotHubResourceOperations", + "ResourceProviderCommonOperations", + "CertificatesOperations", + "IotHubOperations", + "PrivateLinkResourcesOperations", + "PrivateEndpointConnectionsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_certificates_operations.py new file mode 100644 index 000000000000..da3b536d4c22 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_certificates_operations.py @@ -0,0 +1,926 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_iot_hub_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, resource_name: str, certificate_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + resource_name: str, + certificate_name: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + resource_name: str, + certificate_name: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_generate_verification_code_request( + resource_group_name: str, + resource_name: str, + certificate_name: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_verify_request( + resource_group_name: str, + resource_name: str, + certificate_name: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url( + "certificate_name", certificate_name, "str", pattern=r"^[A-Za-z0-9-._]{1,64}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30_preview.IotHubClient`'s + :attr:`certificates` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_by_iot_hub( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: + """Get the certificate list. + + Returns the list of certificates. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateListDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateListDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) + + request = build_list_by_iot_hub_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_iot_hub.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateListDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_iot_hub.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates" + } + + @distributed_trace + def get( + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CertificateDescription: + """Get the certificate. + + Returns the certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: _models.CertificateDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: + ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateDescription + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: Union[_models.CertificateDescription, IO], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.CertificateDescription: + """Upload the certificate to the IoT hub. + + Adds new or replaces existing certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Is either a CertificateDescription type + or a IO type. Required. + :type certificate_description: + ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateDescription or IO + :param if_match: ETag of the Certificate. Do not specify for creating a brand new certificate. + Required to update an existing certificate. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IOBase, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateDescription") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("CertificateDescription", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("CertificateDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}" + } + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> None: + """Delete an X509 certificate. + + Deletes an existing X509 certificate or does nothing if it does not exist. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}" + } + + @distributed_trace + def generate_verification_code( + self, resource_group_name: str, resource_name: str, certificate_name: str, if_match: str, **kwargs: Any + ) -> _models.CertificateWithNonceDescription: + """Generate verification code for proof of possession flow. + + Generates verification code for proof of possession flow. The verification code will be used to + generate a leaf certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateWithNonceDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateWithNonceDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) + + request = build_generate_verification_code_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateWithNonceDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + generate_verification_code.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode" + } + + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: _models.CertificateVerificationDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateVerificationDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Required. + :type certificate_verification_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def verify( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: Union[_models.CertificateVerificationDescription, IO], + **kwargs: Any + ) -> _models.CertificateDescription: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param certificate_name: The name of the certificate. Required. + :type certificate_name: str + :param if_match: ETag of the Certificate. Required. + :type if_match: str + :param certificate_verification_body: The name of the certificate. Is either a + CertificateVerificationDescription type or a IO type. Required. + :type certificate_verification_body: + ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateVerificationDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_verification_body, (IOBase, bytes)): + _content = certificate_verification_body + else: + _json = self._serialize.body(certificate_verification_body, "CertificateVerificationDescription") + + request = build_verify_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.verify.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CertificateDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + verify.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify" + } diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_iot_hub_operations.py new file mode 100644 index 000000000000..ad0eb43de637 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_iot_hub_operations.py @@ -0,0 +1,330 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_manual_failover_request( + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover", + ) # pylint: disable=line-too-long + path_format_arguments = { + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class IotHubOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30_preview.IotHubClient`'s + :attr:`iot_hub` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + def _manual_failover_initial( # pylint: disable=inconsistent-return-statements + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: Union[_models.FailoverInput, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(failover_input, (IOBase, bytes)): + _content = failover_input + else: + _json = self._serialize.body(failover_input, "FailoverInput") + + request = build_manual_failover_request( + iot_hub_name=iot_hub_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._manual_failover_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _manual_failover_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover" + } + + @overload + def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: _models.FailoverInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: ~azure.mgmt.iothub.v2023_06_30_preview.models.FailoverInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Required. + :type failover_input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_manual_failover( + self, + iot_hub_name: str, + resource_group_name: str, + failover_input: Union[_models.FailoverInput, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Manually initiate a failover for the IoT Hub to its secondary region. + + Manually initiate a failover for the IoT Hub to its secondary region. To learn more, see + https://aka.ms/manualfailover. + + :param iot_hub_name: Name of the IoT hub to failover. Required. + :type iot_hub_name: str + :param resource_group_name: Name of the resource group containing the IoT hub resource. + Required. + :type resource_group_name: str + :param failover_input: Region to failover to. Must be the Azure paired region. Get the value + from the secondary location in the locations property. To learn more, see + https://aka.ms/manualfailover/region. Is either a FailoverInput type or a IO type. Required. + :type failover_input: ~azure.mgmt.iothub.v2023_06_30_preview.models.FailoverInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._manual_failover_initial( # type: ignore + iot_hub_name=iot_hub_name, + resource_group_name=resource_group_name, + failover_input=failover_input, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_manual_failover.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover" + } diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_iot_hub_resource_operations.py new file mode 100644 index 000000000000..3502a616d5cf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_iot_hub_resource_operations.py @@ -0,0 +1,3538 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, *, if_match: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_stats_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_valid_skus_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_event_hub_consumer_groups_request( + resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_event_hub_consumer_group_request( + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_event_hub_consumer_group_request( + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_event_hub_consumer_group_request( + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "eventHubEndpointName": _SERIALIZER.url("event_hub_endpoint_name", event_hub_endpoint_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_jobs_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_job_request( + resource_group_name: str, resource_name: str, job_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "jobId": _SERIALIZER.url("job_id", job_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_quota_metrics_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_endpoint_health_request( + resource_group_name: str, iot_hub_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_test_all_routes_request( + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall", + ) # pylint: disable=line-too-long + path_format_arguments = { + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_test_route_request( + iot_hub_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew", + ) # pylint: disable=line-too-long + path_format_arguments = { + "iotHubName": _SERIALIZER.url("iot_hub_name", iot_hub_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_keys_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_keys_for_key_name_request( + resource_group_name: str, resource_name: str, key_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_export_devices_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_import_devices_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class IotHubResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30_preview.IotHubClient`'s + :attr:`iot_hub_resource` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: + """Get the non-security related metadata of an IoT hub. + + Get the non-security related metadata of an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubDescription or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + def _create_or_update_initial( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: Union[_models.IotHubDescription, IO], + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.IotHubDescription: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_description, (IOBase, bytes)): + _content = iot_hub_description + else: + _json = self._serialize.body(iot_hub_description, "IotHubDescription") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: _models.IotHubDescription, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Required. + :type iot_hub_description: IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_description: Union[_models.IotHubDescription, IO], + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Create or update the metadata of an IoT hub. + + Create or update the metadata of an Iot hub. The usual pattern to modify a property is to + retrieve the IoT hub metadata and security metadata, and then combine them with the modified + values in a new body to update the IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param iot_hub_description: The IoT hub metadata and security metadata. Is either a + IotHubDescription type or a IO type. Required. + :type iot_hub_description: ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription or + IO + :param if_match: ETag of the IoT Hub. Do not specify for creating a brand new IoT Hub. Required + to update an existing IoT Hub. Default value is None. + :type if_match: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + iot_hub_description=iot_hub_description, + if_match=if_match, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("IotHubDescription", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + def _update_initial( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> _models.IotHubDescription: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_hub_tags, (IOBase, bytes)): + _content = iot_hub_tags + else: + _json = self._serialize.body(iot_hub_tags, "TagsResource") + + request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: _models.TagsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2023_06_30_preview.models.TagsResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + iot_hub_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Required. + :type iot_hub_tags: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, resource_group_name: str, resource_name: str, iot_hub_tags: Union[_models.TagsResource, IO], **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Update an existing IoT Hubs tags. + + Update an existing IoT Hub tags. to update other fields use the CreateOrUpdate method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param resource_name: Name of iot hub to update. Required. + :type resource_name: str + :param iot_hub_tags: Updated tag information to set into the iot hub instance. Is either a + TagsResource type or a IO type. Required. + :type iot_hub_tags: ~azure.mgmt.iothub.v2023_06_30_preview.models.TagsResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + iot_hub_tags=iot_hub_tags, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("IotHubDescription", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + def _delete_initial( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Union[_models.IotHubDescription, _models.ErrorDetails]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[Union[_models.IotHubDescription, _models.ErrorDetails]] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("IotHubDescription", pipeline_response) + + if response.status_code == 404: + deserialized = self._deserialize("ErrorDetails", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> LROPoller[_models.IotHubDescription]: + """Delete an IoT hub. + + Delete an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or An instance of + LROPoller that returns either ErrorDetails or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription] + or ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2023_06_30_preview.models.ErrorDetails] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("IotHubDescription", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}" + } + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: + """Get all the IoT hubs in a subscription. + + Get all the IoT hubs in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs"} + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: + """Get all the IoT hubs in a resource group. + + Get all the IoT hubs in a resource group. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IotHubDescription or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs" + } + + @distributed_trace + def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.RegistryStatistics: + """Get the statistics from an IoT hub. + + Get the statistics from an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RegistryStatistics or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.RegistryStatistics + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) + + request = build_get_stats_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_stats.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegistryStatistics", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_stats.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats" + } + + @distributed_trace + def get_valid_skus( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescription"]: + """Get the list of valid SKUs for an IoT hub. + + Get the list of valid SKUs for an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IotHubSkuDescription or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubSkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_get_valid_skus_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_valid_skus.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + get_valid_skus.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus" + } + + @distributed_trace + def list_event_hub_consumer_groups( + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, **kwargs: Any + ) -> Iterable["_models.EventHubConsumerGroupInfo"]: + """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an + IoT hub. + + Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an + IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. Required. + :type event_hub_endpoint_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2023_06_30_preview.models.EventHubConsumerGroupInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_event_hub_consumer_groups_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_event_hub_consumer_groups.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_event_hub_consumer_groups.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups" + } + + @distributed_trace + def get_event_hub_consumer_group( + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. + + Get a consumer group from the Event Hub-compatible device-to-cloud endpoint for an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to retrieve. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) + + request = build_get_event_hub_consumer_group_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_event_hub_consumer_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}" + } + + @overload + def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: _models.EventHubConsumerGroupBodyDescription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Required. + :type consumer_group_body: + ~azure.mgmt.iothub.v2023_06_30_preview.models.EventHubConsumerGroupBodyDescription + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Required. + :type consumer_group_body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_event_hub_consumer_group( + self, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: Union[_models.EventHubConsumerGroupBodyDescription, IO], + **kwargs: Any + ) -> _models.EventHubConsumerGroupInfo: + """Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + Add a consumer group to an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to add. Required. + :type name: str + :param consumer_group_body: The consumer group to add. Is either a + EventHubConsumerGroupBodyDescription type or a IO type. Required. + :type consumer_group_body: + ~azure.mgmt.iothub.v2023_06_30_preview.models.EventHubConsumerGroupBodyDescription or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EventHubConsumerGroupInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.EventHubConsumerGroupInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(consumer_group_body, (IOBase, bytes)): + _content = consumer_group_body + else: + _json = self._serialize.body(consumer_group_body, "EventHubConsumerGroupBodyDescription") + + request = build_create_event_hub_consumer_group_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EventHubConsumerGroupInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_event_hub_consumer_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}" + } + + @distributed_trace + def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **kwargs: Any + ) -> None: + """Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + + Delete a consumer group from an Event Hub-compatible endpoint in an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint in the IoT hub. + Required. + :type event_hub_endpoint_name: str + :param name: The name of the consumer group to delete. Required. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_event_hub_consumer_group_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_event_hub_consumer_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_event_hub_consumer_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}" + } + + @distributed_trace + def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterable["_models.JobResponse"]: + """Get a list of all the jobs in an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + + Get a list of all the jobs in an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either JobResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2023_06_30_preview.models.JobResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_jobs_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_jobs.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("JobResponseListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_jobs.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs" + } + + @distributed_trace + def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **kwargs: Any) -> _models.JobResponse: + """Get the details of a job from an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + + Get the details of a job from an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param job_id: The job identifier. Required. + :type job_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) + + request = build_get_job_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_job.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("JobResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_job.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}" + } + + @distributed_trace + def get_quota_metrics( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfo"]: + """Get the quota metrics for an IoT hub. + + Get the quota metrics for an IoT hub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubQuotaMetricInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_get_quota_metrics_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_quota_metrics.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + get_quota_metrics.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics" + } + + @distributed_trace + def get_endpoint_health( + self, resource_group_name: str, iot_hub_name: str, **kwargs: Any + ) -> Iterable["_models.EndpointHealthData"]: + """Get the health for routing endpoints. + + Get the health for routing endpoints. + + :param resource_group_name: Required. + :type resource_group_name: str + :param iot_hub_name: Required. + :type iot_hub_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EndpointHealthData or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2023_06_30_preview.models.EndpointHealthData] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_get_endpoint_health_request( + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_endpoint_health.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("EndpointHealthDataListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + get_endpoint_health.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth" + } + + @overload + def check_name_availability( + self, operation_inputs: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2023_06_30_preview.models.OperationInputs + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, operation_inputs: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Required. + :type operation_inputs: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, operation_inputs: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.IotHubNameAvailabilityInfo: + """Check if an IoT hub name is available. + + Check if an IoT hub name is available. + + :param operation_inputs: Set the name parameter in the OperationInputs structure to the name of + the IoT hub to check. Is either a OperationInputs type or a IO type. Required. + :type operation_inputs: ~azure.mgmt.iothub.v2023_06_30_preview.models.OperationInputs or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IotHubNameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubNameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(operation_inputs, (IOBase, bytes)): + _content = operation_inputs + else: + _json = self._serialize.body(operation_inputs, "OperationInputs") + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("IotHubNameAvailabilityInfo", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability" + } + + @overload + def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: _models.TestAllRoutesInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestAllRoutesInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def test_all_routes( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def test_all_routes( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestAllRoutesInput, IO], **kwargs: Any + ) -> _models.TestAllRoutesResult: + """Test all routes. + + Test all routes configured in this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Input for testing all routes. Is either a TestAllRoutesInput type or a IO type. + Required. + :type input: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestAllRoutesInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestAllRoutesResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestAllRoutesResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IOBase, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestAllRoutesInput") + + request = build_test_all_routes_request( + iot_hub_name=iot_hub_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.test_all_routes.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestAllRoutesResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + test_all_routes.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall" + } + + @overload + def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: _models.TestRouteInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestRouteInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def test_route( + self, + iot_hub_name: str, + resource_group_name: str, + input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Required. + :type input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def test_route( + self, iot_hub_name: str, resource_group_name: str, input: Union[_models.TestRouteInput, IO], **kwargs: Any + ) -> _models.TestRouteResult: + """Test the new route. + + Test the new route for this Iot Hub. + + :param iot_hub_name: IotHub to be tested. Required. + :type iot_hub_name: str + :param resource_group_name: resource group which Iot Hub belongs to. Required. + :type resource_group_name: str + :param input: Route that needs to be tested. Is either a TestRouteInput type or a IO type. + Required. + :type input: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestRouteInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestRouteResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestRouteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(input, (IOBase, bytes)): + _content = input + else: + _json = self._serialize.body(input, "TestRouteInput") + + request = build_test_route_request( + iot_hub_name=iot_hub_name, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.test_route.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TestRouteResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + test_route.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew" + } + + @distributed_trace + def list_keys( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRule"]: + """Get the security metadata for an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + + Get the security metadata for an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2023_06_30_preview.models.SharedAccessSignatureAuthorizationRule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_keys_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys" + } + + @distributed_trace + def get_keys_for_key_name( + self, resource_group_name: str, resource_name: str, key_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRule: + """Get a shared access policy by name from an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + + Get a shared access policy by name from an IoT hub. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param key_name: The name of the shared access policy. Required. + :type key_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.SharedAccessSignatureAuthorizationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) + + request = build_get_keys_for_key_name_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRule", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_keys_for_key_name.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys" + } + + @overload + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: _models.ExportDevicesRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: + ~azure.mgmt.iothub.v2023_06_30_preview.models.ExportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. + Required. + :type export_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def export_devices( + self, + resource_group_name: str, + resource_name: str, + export_devices_parameters: Union[_models.ExportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Exports all the device identities in the IoT hub identity registry to an Azure Storage blob + container. For more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param export_devices_parameters: The parameters that specify the export devices operation. Is + either a ExportDevicesRequest type or a IO type. Required. + :type export_devices_parameters: + ~azure.mgmt.iothub.v2023_06_30_preview.models.ExportDevicesRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(export_devices_parameters, (IOBase, bytes)): + _content = export_devices_parameters + else: + _json = self._serialize.body(export_devices_parameters, "ExportDevicesRequest") + + request = build_export_devices_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.export_devices.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("JobResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + export_devices.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices" + } + + @overload + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: _models.ImportDevicesRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: + ~azure.mgmt.iothub.v2023_06_30_preview.models.ImportDevicesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. + Required. + :type import_devices_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def import_devices( + self, + resource_group_name: str, + resource_name: str, + import_devices_parameters: Union[_models.ImportDevicesRequest, IO], + **kwargs: Any + ) -> _models.JobResponse: + """Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + Import, update, or delete device identities in the IoT hub identity registry from a blob. For + more information, see: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-identity-registry#import-and-export-device-identities. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param import_devices_parameters: The parameters that specify the import devices operation. Is + either a ImportDevicesRequest type or a IO type. Required. + :type import_devices_parameters: + ~azure.mgmt.iothub.v2023_06_30_preview.models.ImportDevicesRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.JobResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(import_devices_parameters, (IOBase, bytes)): + _content = import_devices_parameters + else: + _json = self._serialize.body(import_devices_parameters, "ImportDevicesRequest") + + request = build_import_devices_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.import_devices.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("JobResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + import_devices.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices" + } diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_operations.py new file mode 100644 index 000000000000..e5156a94d1c6 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_operations.py @@ -0,0 +1,158 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Devices/operations") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30_preview.IotHubClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: + """Lists all of the available IoT Hub REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2023_06_30_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..4da84c57eb77 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,743 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30_preview.IotHubClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> List[_models.PrivateEndpointConnection]: + """List private endpoint connections. + + List private endpoint connection properties. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of PrivateEndpointConnection or the result of cls(response) + :rtype: list[~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + + request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("[PrivateEndpointConnection]", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections" + } + + @distributed_trace + def get( + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Get private endpoint connection. + + Get private endpoint connection properties. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + def _update_initial( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IOBase, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. + :type private_endpoint_connection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update private endpoint connection. + + Update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. Is + either a PrivateEndpointConnection type or a IO type. Required. + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateEndpointConnection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + private_endpoint_connection=private_endpoint_connection, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + def _delete_initial( + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Optional[_models.PrivateEndpointConnection]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Delete private endpoint connection. + + Delete private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..9a561337836d --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_private_link_resources_operations.py @@ -0,0 +1,255 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, resource_name: str, group_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "groupId": _SERIALIZER.url("group_id", group_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30_preview.IotHubClient`'s + :attr:`private_link_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: + """List private link resources. + + List private link resources for the given IotHub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkResources or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateLinkResources + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.PrivateLinkResources] = kwargs.pop("cls", None) + + request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResources", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources" + } + + @distributed_trace + def get( + self, resource_group_name: str, resource_name: str, group_id: str, **kwargs: Any + ) -> _models.GroupIdInformation: + """Get the specified private link resource. + + Get the specified private link resource for the given IotHub. + + :param resource_group_name: The name of the resource group that contains the IoT hub. Required. + :type resource_group_name: str + :param resource_name: The name of the IoT hub. Required. + :type resource_name: str + :param group_id: The name of the private link resource. Required. + :type group_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GroupIdInformation or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.GroupIdInformation + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + group_id=group_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GroupIdInformation", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}" + } diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_resource_provider_common_operations.py new file mode 100644 index 000000000000..d363e59799df --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_resource_provider_common_operations.py @@ -0,0 +1,137 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_subscription_quota_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ResourceProviderCommonOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothub.v2023_06_30_preview.IotHubClient`'s + :attr:`resource_provider_common` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: + """Get the number of iot hubs in the subscription. + + Get the number of free and paid iot hubs in the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UserSubscriptionQuotaListResult or the result of cls(response) + :rtype: ~azure.mgmt.iothub.v2023_06_30_preview.models.UserSubscriptionQuotaListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-06-30-preview") + ) + cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) + + request = build_get_subscription_quota_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_subscription_quota.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UserSubscriptionQuotaListResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_subscription_quota.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages"} diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/py.typed b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/check_name_availability.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/check_name_availability.py index 8b32af7ea0dc..114c1a6662fe 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/check_name_availability.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/check_name_availability.py @@ -35,6 +35,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/checkNameAvailability.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/checkNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iot_hub_manual_failover.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iot_hub_manual_failover.py index 071b2a1672d7..9e5457dd125b 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iot_hub_manual_failover.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iot_hub_manual_failover.py @@ -29,14 +29,13 @@ def main(): subscription_id="91d12660-3dec-467a-be2a-213b5544ddc0", ) - response = client.iot_hub.begin_manual_failover( + client.iot_hub.begin_manual_failover( iot_hub_name="testHub", resource_group_name="myResourceGroup", failover_input={"failoverRegion": "testHub"}, ).result() - print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/IotHub_ManualFailover.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/IotHub_ManualFailover.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_add_routing_cosmos_db_endpoint.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_add_routing_cosmos_db_endpoint.py new file mode 100644 index 000000000000..f18864e96dd2 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_add_routing_cosmos_db_endpoint.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.iothub import IotHubClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-iothub +# USAGE + python iothub_add_routing_cosmos_db_endpoint.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = IotHubClient( + credential=DefaultAzureCredential(), + subscription_id="91d12660-3dec-467a-be2a-213b5544ddc0", + ) + + response = client.iot_hub_resource.begin_create_or_update( + resource_group_name="myResourceGroup", + resource_name="testHub", + iot_hub_description={ + "etag": "AAAAAAFD6M4=", + "location": "centraluseuap", + "properties": { + "cloudToDevice": { + "defaultTtlAsIso8601": "PT1H", + "feedback": {"lockDurationAsIso8601": "PT1M", "maxDeliveryCount": 10, "ttlAsIso8601": "PT1H"}, + "maxDeliveryCount": 10, + }, + "enableDataResidency": False, + "enableFileUploadNotifications": False, + "eventHubEndpoints": {"events": {"partitionCount": 2, "retentionTimeInDays": 1}}, + "features": "None", + "ipFilterRules": [], + "messagingEndpoints": { + "fileNotifications": { + "lockDurationAsIso8601": "PT1M", + "maxDeliveryCount": 10, + "ttlAsIso8601": "PT1H", + } + }, + "minTlsVersion": "1.2", + "networkRuleSets": { + "applyToBuiltInEventHubEndpoint": True, + "defaultAction": "Deny", + "ipRules": [ + {"action": "Allow", "filterName": "rule1", "ipMask": "131.117.159.53"}, + {"action": "Allow", "filterName": "rule2", "ipMask": "157.55.59.128/25"}, + ], + }, + "routing": { + "endpoints": { + "cosmosDBSqlContainers": [ + { + "authenticationType": "keyBased", + "containerName": "test", + "databaseName": "systemstore", + "endpointUri": "https://test-systemstore-test2.documents.azure.com", + "name": "endpointcosmos", + "partitionKeyName": "keystamped", + "partitionKeyTemplate": "{deviceid}-{YYYY}-{MM}", + "primaryKey": "", + "resourceGroup": "rg-test", + "secondaryKey": "", + "subscriptionId": "", + } + ], + "eventHubs": [], + "serviceBusQueues": [], + "serviceBusTopics": [], + "storageContainers": [], + }, + "fallbackRoute": { + "condition": "true", + "endpointNames": ["events"], + "isEnabled": True, + "name": "$fallback", + "source": "DeviceMessages", + }, + "routes": [], + }, + "storageEndpoints": { + "$default": {"connectionString": "", "containerName": "", "sasTtlAsIso8601": "PT1H"} + }, + }, + "sku": {"capacity": 1, "name": "S1"}, + "tags": {}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_addRoutingCosmosDBEndpoint.json +if __name__ == "__main__": + main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_certificatescreateorupdate.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_certificatescreateorupdate.py index 36df11e9d706..d9b152b2e4ad 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_certificatescreateorupdate.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_certificatescreateorupdate.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_certificatescreateorupdate.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_certificatescreateorupdate.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_certificatesdelete.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_certificatesdelete.py index c08c1cf420da..f7ff1c6be92f 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_certificatesdelete.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_certificatesdelete.py @@ -29,15 +29,14 @@ def main(): subscription_id="91d12660-3dec-467a-be2a-213b5544ddc0", ) - response = client.certificates.delete( + client.certificates.delete( resource_group_name="myResourceGroup", resource_name="myhub", certificate_name="cert", if_match="AAAAAAAADGk=", ) - print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_certificatesdelete.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_certificatesdelete.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_certverify.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_certverify.py index 87093137fdea..35e822136bd9 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_certverify.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_certverify.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_certverify.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_certverify.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_create_or_update.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_create_or_update.py index 3534680fb04f..8850e01d7164 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_create_or_update.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_create_or_update.py @@ -89,6 +89,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_createOrUpdate.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_createOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_createconsumergroup.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_createconsumergroup.py index babdce6a4d9b..523c17733407 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_createconsumergroup.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_createconsumergroup.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_createconsumergroup.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_createconsumergroup.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_delete.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_delete.py index b34bb51968cb..93a3ccd4a16a 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_delete.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_delete.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_delete.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_delete.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_deleteconsumergroup.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_deleteconsumergroup.py index 031aa4c9f71f..5cafbccd9c3b 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_deleteconsumergroup.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_deleteconsumergroup.py @@ -29,15 +29,14 @@ def main(): subscription_id="91d12660-3dec-467a-be2a-213b5544ddc0", ) - response = client.iot_hub_resource.delete_event_hub_consumer_group( + client.iot_hub_resource.delete_event_hub_consumer_group( resource_group_name="myResourceGroup", resource_name="testHub", event_hub_endpoint_name="events", name="test", ) - print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_deleteconsumergroup.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_deleteconsumergroup.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_deleteprivateendpointconnection.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_deleteprivateendpointconnection.py index c5f4e8aeaef8..198f405bfefc 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_deleteprivateendpointconnection.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_deleteprivateendpointconnection.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_deleteprivateendpointconnection.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_deleteprivateendpointconnection.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_exportdevices.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_exportdevices.py index abc9c0349383..4c4768238548 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_exportdevices.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_exportdevices.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_exportdevices.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_exportdevices.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_generateverificationcode.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_generateverificationcode.py index 5d44b4b61573..7c316cec08f6 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_generateverificationcode.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_generateverificationcode.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_generateverificationcode.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_generateverificationcode.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_get.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_get.py index 00c26811be1a..7dab91c159d1 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_get.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_get.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_get.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_get.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getcertificate.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getcertificate.py index cdad38958279..191fe58b25cf 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getcertificate.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getcertificate.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getcertificate.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_getcertificate.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getconsumergroup.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getconsumergroup.py index ce8e6199c387..e41a5bcfcac9 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getconsumergroup.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getconsumergroup.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getconsumergroup.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_getconsumergroup.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getjob.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getjob.py index ebd558326d25..63e1261899ae 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getjob.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getjob.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getjob.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_getjob.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getkey.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getkey.py index d0f07c52c6e2..c79ea181457a 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getkey.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getkey.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getkey.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_getkey.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getprivateendpointconnection.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getprivateendpointconnection.py index 4eadb10b2e4e..7b16fca00cc8 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getprivateendpointconnection.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getprivateendpointconnection.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getprivateendpointconnection.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_getprivateendpointconnection.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getprivatelinkresources.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getprivatelinkresources.py index f3e3d8425198..36e3c8b08d0d 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getprivatelinkresources.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getprivatelinkresources.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getprivatelinkresources.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_getprivatelinkresources.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getskus.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getskus.py index dba99c55aa0e..b779c884a727 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getskus.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getskus.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_getskus.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_getskus.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_importdevices.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_importdevices.py index 0f6917bc5277..4370db56c5a2 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_importdevices.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_importdevices.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_importdevices.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_importdevices.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listbyrg.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listbyrg.py index 740402cf79a5..ca106c45d537 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listbyrg.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listbyrg.py @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listbyrg.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_listbyrg.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listbysubscription.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listbysubscription.py index a2c7e9d08916..3e92c5dc3b6a 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listbysubscription.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listbysubscription.py @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listbysubscription.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_listbysubscription.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listcertificates.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listcertificates.py index db5df711aade..9ba8601987a9 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listcertificates.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listcertificates.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listcertificates.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_listcertificates.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listehgroups.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listehgroups.py index 29677ea29956..801fb0a845f5 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listehgroups.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listehgroups.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listehgroups.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_listehgroups.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listjobs.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listjobs.py index 234d23a98594..a2cf5e26c6c5 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listjobs.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listjobs.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listjobs.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_listjobs.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listkeys.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listkeys.py index c2c4c25b1f4d..422e2d1123c3 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listkeys.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listkeys.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listkeys.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_listkeys.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listprivateendpointconnections.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listprivateendpointconnections.py index e7b27902fca3..e35022cb1bd6 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listprivateendpointconnections.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listprivateendpointconnections.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listprivateendpointconnections.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_listprivateendpointconnections.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listprivatelinkresources.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listprivatelinkresources.py index 164ca722de52..0191d622ddce 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listprivatelinkresources.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listprivatelinkresources.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_listprivatelinkresources.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_listprivatelinkresources.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_operations.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_operations.py index 3fa0bae22aa0..c17190bffb1a 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_operations.py @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_operations.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_operations.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_patch.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_patch.py new file mode 100644 index 000000000000..ad696fd65cb1 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_patch.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.iothub import IotHubClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-iothub +# USAGE + python iothub_patch.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = IotHubClient( + credential=DefaultAzureCredential(), + subscription_id="91d12660-3dec-467a-be2a-213b5544ddc0", + ) + + response = client.iot_hub_resource.begin_update( + resource_group_name="myResourceGroup", + resource_name="myHub", + iot_hub_tags={"tags": {"foo": "bar"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_patch.json +if __name__ == "__main__": + main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_quotametrics.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_quotametrics.py index fb4b96e5e2aa..b76bbf6676bd 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_quotametrics.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_quotametrics.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_quotametrics.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_quotametrics.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_routingendpointhealth.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_routingendpointhealth.py index 55fbcde54837..d91b6cfd2dd1 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_routingendpointhealth.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_routingendpointhealth.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_routingendpointhealth.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_routingendpointhealth.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_stats.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_stats.py index d67067f8cfbc..7607dff9774c 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_stats.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_stats.py @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_stats.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_stats.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_testallroutes.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_testallroutes.py index eb04dc7cfbf6..07883cf83743 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_testallroutes.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_testallroutes.py @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_testallroutes.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_testallroutes.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_testnewroute.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_testnewroute.py index b61ee216be97..367522de83ea 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_testnewroute.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_testnewroute.py @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_testnewroute.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_testnewroute.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_updateprivateendpointconnection.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_updateprivateendpointconnection.py index 08636d2fffae..5bd87d42bf8c 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_updateprivateendpointconnection.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_updateprivateendpointconnection.py @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_updateprivateendpointconnection.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_updateprivateendpointconnection.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_usages.py b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_usages.py index 03f74725cebe..0ed47146f70f 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_usages.py +++ b/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_usages.py @@ -33,6 +33,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2021-07-02/examples/iothub_usages.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_usages.json if __name__ == "__main__": main()