diff --git a/sdk/iothub/azure-mgmt-iothub/CHANGELOG.md b/sdk/iothub/azure-mgmt-iothub/CHANGELOG.md index a5e7d25d0ab6..b03545c2c825 100644 --- a/sdk/iothub/azure-mgmt-iothub/CHANGELOG.md +++ b/sdk/iothub/azure-mgmt-iothub/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 5.0.0b1 (2025-08-12) + + + ## 4.0.0 (2025-04-09) ### Breaking Changes diff --git a/sdk/iothub/azure-mgmt-iothub/MANIFEST.in b/sdk/iothub/azure-mgmt-iothub/MANIFEST.in index f74c68a95952..7414e4baf761 100644 --- a/sdk/iothub/azure-mgmt-iothub/MANIFEST.in +++ b/sdk/iothub/azure-mgmt-iothub/MANIFEST.in @@ -1,4 +1,3 @@ -include _meta.json recursive-include tests *.py *.json recursive-include samples *.py *.md include *.md diff --git a/sdk/iothub/azure-mgmt-iothub/README.md b/sdk/iothub/azure-mgmt-iothub/README.md index 51e35200cc93..28f28d0b0cea 100644 --- a/sdk/iothub/azure-mgmt-iothub/README.md +++ b/sdk/iothub/azure-mgmt-iothub/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure IoT Hub Management Client Library. -This package has been tested with Python 3.8+. +This package has been tested with Python 3.9+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.8+ is required to use this package. +- Python 3.9+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package diff --git a/sdk/iothub/azure-mgmt-iothub/_meta.json b/sdk/iothub/azure-mgmt-iothub/_meta.json deleted file mode 100644 index 98c69eebe492..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/_meta.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "commit": "abb839b726184aa10f8d1eaac8e9fe590833619c", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.10.2", - "use": [ - "@autorest/python@6.27.4", - "@autorest/modelerfour@4.27.0" - ], - "autorest_command": "autorest specification/iothub/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.27.4 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", - "readme": "specification/iothub/resource-manager/readme.md" -} \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/_metadata.json b/sdk/iothub/azure-mgmt-iothub/_metadata.json new file mode 100644 index 000000000000..4e7b9edb8084 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/_metadata.json @@ -0,0 +1,11 @@ +{ + "commit": "0307bdd430fe36619222da73db13030f3bc9ce38", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest": "3.10.2", + "use": [ + "@autorest/python@6.38.0", + "@autorest/modelerfour@4.27.0" + ], + "autorest_command": "autorest specification/iothub/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --keep-setup-py=True --python --python-sdks-folder=/mnt/vss/_work/1/azure-sdk-for-python/sdk --tag=package-preview-2023-06 --use=@autorest/python@6.38.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", + "readme": "specification/iothub/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/__init__.py index eb22ec618db9..ec710f27f0eb 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/__init__.py @@ -5,16 +5,28 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._iot_hub_client import IotHubClient -__all__ = ['IotHubClient'] +from typing import TYPE_CHECKING -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import +from ._iot_hub_client import IotHubClient # type: ignore from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch 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__]) # pyright: ignore + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_configuration.py index e9b1edc93207..e006dbc459b7 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_configuration.py @@ -1,13 +1,11 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- + from typing import Any, TYPE_CHECKING from azure.core.pipeline import policies @@ -16,10 +14,10 @@ from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class IotHubClientConfiguration: + +class IotHubClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. Note that all parameters used to create this instance are saved as instance @@ -29,14 +27,14 @@ class IotHubClientConfiguration: :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 - ): + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + 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: @@ -44,23 +42,23 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'azure-mgmt-iothub/{}'.format(VERSION)) + 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.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ): - 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') + 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**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) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) 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 e54fb3c2a83f..36f1823e3e7a 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 @@ -1,82 +1,83 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING, cast from typing_extensions import Self from azure.core.pipeline import policies +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.settings import settings from azure.mgmt.core import ARMPipelineClient from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy -from azure.profiles import KnownProfiles, ProfileDefinition -from azure.profiles.multiapiclient import MultiApiClientMixin +from azure.mgmt.core.tools import get_arm_endpoints +from . import models as _models from ._configuration import IotHubClientConfiguration -from ._serialization import Deserializer, Serializer +from ._utils.serialization import Deserializer, Serializer +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 _SDKClient(object): - def __init__(self, *args, **kwargs): - """This is a fake class to support current implemetation of MultiApiClientMixin." - Will be removed in final version of multiapi azure-core based client - """ - pass -class IotHubClient(MultiApiClientMixin, _SDKClient): +class IotHubClient: # pylint: disable=too-many-instance-attributes """Use this API to manage the IoT hubs in your Azure subscription. - This ready contains multiple API versions, to help you deal with all of the Azure clouds - (Azure Stack, Azure Government, Azure China, etc.). - By default, it uses the latest API version available on public Azure. - For production, you should stick to a particular api-version and/or profile. - The profile sets a mapping between an operation group and its API version. - The api-version parameter sets the default API version if the operation - group is not described in the profile. - + :ivar operations: Operations operations + :vartype operations: azure.mgmt.iothub.operations.Operations + :ivar iot_hub_resource: IotHubResourceOperations operations + :vartype iot_hub_resource: azure.mgmt.iothub.operations.IotHubResourceOperations + :ivar resource_provider_common: ResourceProviderCommonOperations operations + :vartype resource_provider_common: + azure.mgmt.iothub.operations.ResourceProviderCommonOperations + :ivar certificates: CertificatesOperations operations + :vartype certificates: azure.mgmt.iothub.operations.CertificatesOperations + :ivar iot_hub: IotHubOperations operations + :vartype iot_hub: azure.mgmt.iothub.operations.IotHubOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: azure.mgmt.iothub.operations.PrivateLinkResourcesOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.iothub.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 api_version: API version to use if no profile is provided, or if missing in profile. - :type api_version: str - :param base_url: Service URL + :param base_url: Service URL. Default value is None. :type base_url: str - :param profile: A profile definition, from KnownProfiles to dict. - :type profile: azure.profiles.KnownProfiles - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :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. """ - DEFAULT_API_VERSION = '2023-06-30' - _PROFILE_TAG = "azure.mgmt.iothub.IotHubClient" - LATEST_PROFILE = ProfileDefinition({ - _PROFILE_TAG: { - None: DEFAULT_API_VERSION, - }}, - _PROFILE_TAG + " latest" - ) - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - api_version: Optional[str]=None, - base_url: str = "https://management.azure.com", - profile: KnownProfiles=KnownProfiles.default, - **kwargs: Any - ): - if api_version: - kwargs.setdefault('api_version', api_version) - self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) + self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any + ) -> None: + _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) + self._config = IotHubClientConfiguration( + credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs + ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -95,192 +96,54 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - super(IotHubClient, self).__init__( - api_version=api_version, - profile=profile + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **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) + self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_provider_common = ResourceProviderCommonOperations( + self._client, self._config, self._serialize, self._deserialize + ) + 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.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize ) - @classmethod - def _models_dict(cls, api_version): - return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} - - @classmethod - def models(cls, api_version=DEFAULT_API_VERSION): - """Module depends on the API version: - - * 2019-03-22: :mod:`v2019_03_22.models` - * 2019-07-01-preview: :mod:`v2019_07_01_preview.models` - * 2023-06-30: :mod:`v2023_06_30.models` - * 2023-06-30-preview: :mod:`v2023_06_30_preview.models` - """ - if api_version == '2019-03-22': - from .v2019_03_22 import models - return models - elif api_version == '2019-07-01-preview': - from .v2019_07_01_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 - def certificates(self): - """Instance depends on the API version: - - * 2019-03-22: :class:`CertificatesOperations` - * 2019-07-01-preview: :class:`CertificatesOperations` - * 2023-06-30: :class:`CertificatesOperations` - * 2023-06-30-preview: :class:`CertificatesOperations` - """ - api_version = self._get_api_version('certificates') - if api_version == '2019-03-22': - from .v2019_03_22.operations import CertificatesOperations as OperationClass - elif api_version == '2019-07-01-preview': - from .v2019_07_01_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)), api_version) - - @property - def iot_hub(self): - """Instance depends on the API version: - - * 2019-03-22: :class:`IotHubOperations` - * 2019-07-01-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': - from .v2019_03_22.operations import IotHubOperations as OperationClass - elif api_version == '2019-07-01-preview': - from .v2019_07_01_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)), api_version) - - @property - def iot_hub_resource(self): - """Instance depends on the API version: - - * 2019-03-22: :class:`IotHubResourceOperations` - * 2019-07-01-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 == '2019-03-22': - from .v2019_03_22.operations import IotHubResourceOperations as OperationClass - elif api_version == '2019-07-01-preview': - from .v2019_07_01_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)), api_version) - - @property - def operations(self): - """Instance depends on the API version: - - * 2019-03-22: :class:`Operations` - * 2019-07-01-preview: :class:`Operations` - * 2023-06-30: :class:`Operations` - * 2023-06-30-preview: :class:`Operations` - """ - api_version = self._get_api_version('operations') - if api_version == '2019-03-22': - from .v2019_03_22.operations import Operations as OperationClass - elif api_version == '2019-07-01-preview': - from .v2019_07_01_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)), api_version) - - @property - def private_endpoint_connections(self): - """Instance depends on the API version: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. - * 2023-06-30: :class:`PrivateEndpointConnectionsOperations` - * 2023-06-30-preview: :class:`PrivateEndpointConnectionsOperations` - """ - api_version = self._get_api_version('private_endpoint_connections') - if 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)), api_version) + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + - @property - def private_link_resources(self): - """Instance depends on the API version: + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - * 2023-06-30: :class:`PrivateLinkResourcesOperations` - * 2023-06-30-preview: :class:`PrivateLinkResourcesOperations` + :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 """ - api_version = self._get_api_version('private_link_resources') - if 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)), api_version) - @property - def resource_provider_common(self): - """Instance depends on the API version: + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - * 2019-03-22: :class:`ResourceProviderCommonOperations` - * 2019-07-01-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 == '2019-03-22': - from .v2019_03_22.operations import ResourceProviderCommonOperations as OperationClass - elif api_version == '2019-07-01-preview': - from .v2019_07_01_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)), api_version) - - def close(self): + def close(self) -> None: self._client.close() - def __enter__(self): + + def __enter__(self) -> Self: self._client.__enter__() return self - def __exit__(self, *exc_details): + + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_patch.py similarity index 61% rename from sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_patch.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize 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/_utils/__init__.py similarity index 93% rename from sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_version.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_utils/__init__.py index 77f53a3589c6..0af9b28f6607 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_utils/__init__.py @@ -1,9 +1,6 @@ -# 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 = "4.0.0" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_serialization.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_utils/serialization.py similarity index 94% rename from sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_serialization.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_utils/serialization.py index a94487cbf17a..f5187701d7be 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_serialization.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_utils/serialization.py @@ -1,27 +1,10 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# 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. # -------------------------------------------------------------------------- # pyright: reportUnnecessaryTypeIgnoreComment=false @@ -47,9 +30,7 @@ IO, Mapping, Callable, - TypeVar, MutableMapping, - Type, List, ) @@ -60,13 +41,13 @@ import xml.etree.ElementTree as ET import isodate # type: ignore +from typing_extensions import Self from azure.core.exceptions import DeserializationError, SerializationError from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") -ModelType = TypeVar("ModelType", bound="Model") JSON = MutableMapping[str, Any] @@ -184,73 +165,7 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], except NameError: _long_type = int - -class UTC(datetime.tzinfo): - """Time Zone info for handling UTC""" - - def utcoffset(self, dt): - """UTF offset for UTC is 0. - - :param datetime.datetime dt: The datetime - :returns: The offset - :rtype: datetime.timedelta - """ - return datetime.timedelta(0) - - def tzname(self, dt): - """Timestamp representation. - - :param datetime.datetime dt: The datetime - :returns: The timestamp representation - :rtype: str - """ - return "Z" - - def dst(self, dt): - """No daylight saving for UTC. - - :param datetime.datetime dt: The datetime - :returns: The daylight saving time - :rtype: datetime.timedelta - """ - return datetime.timedelta(hours=1) - - -try: - from datetime import timezone as _FixedOffset # type: ignore -except ImportError: # Python 2.7 - - class _FixedOffset(datetime.tzinfo): # type: ignore - """Fixed offset in minutes east from UTC. - Copy/pasted from Python doc - :param datetime.timedelta offset: offset in timedelta format - """ - - def __init__(self, offset) -> None: - self.__offset = offset - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return str(self.__offset.total_seconds() / 3600) - - def __repr__(self): - return "".format(self.tzname(None)) - - def dst(self, dt): - return datetime.timedelta(0) - - def __getinitargs__(self): - return (self.__offset,) - - -try: - from datetime import timezone - - TZ_UTC = timezone.utc -except ImportError: - TZ_UTC = UTC() # type: ignore +TZ_UTC = datetime.timezone.utc _FLATTEN = re.compile(r"(? ModelType: + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: """Parse a str using the RestAPI syntax and return a model. :param str data: A str using RestAPI structure. JSON by default. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong - :rtype: ModelType + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( - cls: Type[ModelType], + cls, data: Any, key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, content_type: Optional[str] = None, - ) -> ModelType: + ) -> Self: """Parse a dict using given key extractor return a model. By default consider key @@ -478,8 +393,8 @@ def from_dict( :param function key_extractors: A key extractor function. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong - :rtype: ModelType + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) deserializer.key_extractors = ( # type: ignore @@ -625,7 +540,7 @@ def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, to :param object target_obj: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, dict - :raises: SerializationError if serialization fails. + :raises SerializationError: if serialization fails. :returns: The serialized data. """ key_transformer = kwargs.get("key_transformer", self.key_transformer) @@ -735,8 +650,8 @@ def body(self, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: dict - :raises: SerializationError if serialization fails. - :raises: ValueError if data is None + :raises SerializationError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized request body """ @@ -780,8 +695,8 @@ def url(self, name, data, data_type, **kwargs): :param str data_type: The type to be serialized from. :rtype: str :returns: The serialized URL path - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None """ try: output = self.serialize_data(data, data_type, **kwargs) @@ -804,8 +719,8 @@ def query(self, name, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, list - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized query parameter """ try: @@ -834,8 +749,8 @@ def header(self, name, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized header """ try: @@ -854,9 +769,9 @@ def serialize_data(self, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :raises: AttributeError if required data is None. - :raises: ValueError if data is None - :raises: SerializationError if serialization fails. + :raises AttributeError: if required data is None. + :raises ValueError: if data is None + :raises SerializationError: if serialization fails. :returns: The serialized data. :rtype: str, int, float, bool, dict, list """ @@ -1191,7 +1106,7 @@ def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: str - :raises: TypeError if format invalid. + :raises TypeError: if format invalid. :return: serialized rfc """ try: @@ -1217,7 +1132,7 @@ def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: str - :raises: SerializationError if format invalid. + :raises SerializationError: if format invalid. :return: serialized iso """ if isinstance(attr, str): @@ -1250,7 +1165,7 @@ def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: int - :raises: SerializationError if format invalid + :raises SerializationError: if format invalid :return: serialied unix """ if isinstance(attr, int): @@ -1428,7 +1343,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) @@ -1487,7 +1402,7 @@ def __call__(self, target_obj, response_data, content_type=None): :param str target_obj: Target data type to deserialize to. :param requests.Response response_data: REST response object. :param str content_type: Swagger "produces" if available. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1501,7 +1416,7 @@ def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return :param str target_obj: Target data type to deserialize to. :param object data: Object to deserialize. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1716,7 +1631,7 @@ def deserialize_data(self, data, data_type): # pylint: disable=too-many-return- :param str data: The response string to be deserialized. :param str data_type: The type to deserialize to. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1798,7 +1713,7 @@ def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return :param dict attr: Dictionary to be deserialized. :return: Deserialized object. :rtype: dict - :raises: TypeError if non-builtin datatype encountered. + :raises TypeError: if non-builtin datatype encountered. """ if attr is None: return None @@ -1844,7 +1759,7 @@ def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return :param str data_type: deserialization data type. :return: Deserialized basic type. :rtype: str, int, float or bool - :raises: TypeError if string format is not valid. + :raises TypeError: if string format is not valid. """ # If we're here, data is supposed to be a basic type. # If it's still an XML node, take the text @@ -1935,7 +1850,7 @@ def deserialize_bytearray(attr): :param str attr: response string to be deserialized. :return: Deserialized bytearray :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1948,7 +1863,7 @@ def deserialize_base64(attr): :param str attr: response string to be deserialized. :return: Deserialized base64 string :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1963,7 +1878,7 @@ def deserialize_decimal(attr): :param str attr: response string to be deserialized. :return: Deserialized decimal - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. :rtype: decimal """ if isinstance(attr, ET.Element): @@ -1981,7 +1896,7 @@ def deserialize_long(attr): :param str attr: response string to be deserialized. :return: Deserialized int :rtype: long or int - :raises: ValueError if string format invalid. + :raises ValueError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1994,7 +1909,7 @@ def deserialize_duration(attr): :param str attr: response string to be deserialized. :return: Deserialized duration :rtype: TimeDelta - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2012,7 +1927,7 @@ def deserialize_date(attr): :param str attr: response string to be deserialized. :return: Deserialized date :rtype: Date - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2028,7 +1943,7 @@ def deserialize_time(attr): :param str attr: response string to be deserialized. :return: Deserialized time :rtype: datetime.time - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2043,14 +1958,14 @@ def deserialize_rfc(attr): :param str attr: response string to be deserialized. :return: Deserialized RFC datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text try: parsed_date = email.utils.parsedate_tz(attr) # type: ignore date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) ) if not date_obj.tzinfo: date_obj = date_obj.astimezone(tz=TZ_UTC) @@ -2066,7 +1981,7 @@ def deserialize_iso(attr): :param str attr: response string to be deserialized. :return: Deserialized ISO datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2104,7 +2019,7 @@ def deserialize_unix(attr): :param int attr: Object to be serialized. :return: Deserialized datetime :rtype: Datetime - :raises: DeserializationError if format invalid + :raises DeserializationError: if format invalid """ if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_version.py index 5a310ec590fb..3f948557870d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_version.py @@ -5,4 +5,4 @@ # license information. # -------------------------------------------------------------------------- -VERSION = "4.0.0" +VERSION = "5.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/__init__.py index a84cf700a930..df18749d0db3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/__init__.py @@ -5,6 +5,25 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._iot_hub_client import IotHubClient -__all__ = ['IotHubClient'] +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._iot_hub_client import IotHubClient # type: ignore + +try: + from ._patch import __all__ as _patch_all + from ._patch 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__]) # pyright: ignore + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/_configuration.py index f78a0184b071..3d6cfa29acf1 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/_configuration.py @@ -1,13 +1,11 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- + from typing import Any, TYPE_CHECKING from azure.core.pipeline import policies @@ -16,10 +14,10 @@ from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class IotHubClientConfiguration: + +class IotHubClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for IotHubClient. Note that all parameters used to create this instance are saved as instance @@ -29,14 +27,14 @@ class IotHubClientConfiguration: :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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + 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: @@ -44,23 +42,23 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'azure-mgmt-iothub/{}'.format(VERSION)) + 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.polling_interval = kwargs.get("polling_interval", 30) 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') + 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**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) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) 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 4b41d2eb92c1..580e000ef8df 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 @@ -1,82 +1,84 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast from typing_extensions import Self from azure.core.pipeline import policies +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.settings import settings from azure.mgmt.core import AsyncARMPipelineClient from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy -from azure.profiles import KnownProfiles, ProfileDefinition -from azure.profiles.multiapiclient import MultiApiClientMixin +from azure.mgmt.core.tools import get_arm_endpoints -from .._serialization import Deserializer, Serializer +from .. import models as _models +from .._utils.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 _SDKClient(object): - def __init__(self, *args, **kwargs): - """This is a fake class to support current implemetation of MultiApiClientMixin." - Will be removed in final version of multiapi azure-core based client - """ - pass -class IotHubClient(MultiApiClientMixin, _SDKClient): +class IotHubClient: # pylint: disable=too-many-instance-attributes """Use this API to manage the IoT hubs in your Azure subscription. - This ready contains multiple API versions, to help you deal with all of the Azure clouds - (Azure Stack, Azure Government, Azure China, etc.). - By default, it uses the latest API version available on public Azure. - For production, you should stick to a particular api-version and/or profile. - The profile sets a mapping between an operation group and its API version. - The api-version parameter sets the default API version if the operation - group is not described in the profile. - + :ivar operations: Operations operations + :vartype operations: azure.mgmt.iothub.aio.operations.Operations + :ivar iot_hub_resource: IotHubResourceOperations operations + :vartype iot_hub_resource: azure.mgmt.iothub.aio.operations.IotHubResourceOperations + :ivar resource_provider_common: ResourceProviderCommonOperations operations + :vartype resource_provider_common: + azure.mgmt.iothub.aio.operations.ResourceProviderCommonOperations + :ivar certificates: CertificatesOperations operations + :vartype certificates: azure.mgmt.iothub.aio.operations.CertificatesOperations + :ivar iot_hub: IotHubOperations operations + :vartype iot_hub: azure.mgmt.iothub.aio.operations.IotHubOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.iothub.aio.operations.PrivateLinkResourcesOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.iothub.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 api_version: API version to use if no profile is provided, or if missing in profile. - :type api_version: str - :param base_url: Service URL + :param base_url: Service URL. Default value is None. :type base_url: str - :param profile: A profile definition, from KnownProfiles to dict. - :type profile: azure.profiles.KnownProfiles - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :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. """ - DEFAULT_API_VERSION = '2023-06-30' - _PROFILE_TAG = "azure.mgmt.iothub.IotHubClient" - LATEST_PROFILE = ProfileDefinition({ - _PROFILE_TAG: { - None: DEFAULT_API_VERSION, - }}, - _PROFILE_TAG + " latest" - ) - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - api_version: Optional[str] = None, - base_url: str = "https://management.azure.com", - profile: KnownProfiles = KnownProfiles.default, - **kwargs: Any + self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any ) -> None: - if api_version: - kwargs.setdefault('api_version', api_version) - self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) + _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) + self._config = IotHubClientConfiguration( + credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs + ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -95,192 +97,58 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) - super(IotHubClient, self).__init__( - api_version=api_version, - profile=profile + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( + base_url=cast(str, base_url), policies=_policies, **kwargs ) - @classmethod - def _models_dict(cls, api_version): - return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} - - @classmethod - def models(cls, api_version=DEFAULT_API_VERSION): - """Module depends on the API version: - - * 2019-03-22: :mod:`v2019_03_22.models` - * 2019-07-01-preview: :mod:`v2019_07_01_preview.models` - * 2023-06-30: :mod:`v2023_06_30.models` - * 2023-06-30-preview: :mod:`v2023_06_30_preview.models` - """ - if api_version == '2019-03-22': - from ..v2019_03_22 import models - return models - elif api_version == '2019-07-01-preview': - from ..v2019_07_01_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 - def certificates(self): - """Instance depends on the API version: - - * 2019-03-22: :class:`CertificatesOperations` - * 2019-07-01-preview: :class:`CertificatesOperations` - * 2023-06-30: :class:`CertificatesOperations` - * 2023-06-30-preview: :class:`CertificatesOperations` - """ - api_version = self._get_api_version('certificates') - if api_version == '2019-03-22': - from ..v2019_03_22.aio.operations import CertificatesOperations as OperationClass - elif api_version == '2019-07-01-preview': - from ..v2019_07_01_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)), api_version) - - @property - def iot_hub(self): - """Instance depends on the API version: - - * 2019-03-22: :class:`IotHubOperations` - * 2019-07-01-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': - from ..v2019_03_22.aio.operations import IotHubOperations as OperationClass - elif api_version == '2019-07-01-preview': - from ..v2019_07_01_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)), api_version) - - @property - def iot_hub_resource(self): - """Instance depends on the API version: - - * 2019-03-22: :class:`IotHubResourceOperations` - * 2019-07-01-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 == '2019-03-22': - from ..v2019_03_22.aio.operations import IotHubResourceOperations as OperationClass - elif api_version == '2019-07-01-preview': - from ..v2019_07_01_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)), api_version) - - @property - def operations(self): - """Instance depends on the API version: - - * 2019-03-22: :class:`Operations` - * 2019-07-01-preview: :class:`Operations` - * 2023-06-30: :class:`Operations` - * 2023-06-30-preview: :class:`Operations` - """ - api_version = self._get_api_version('operations') - if api_version == '2019-03-22': - from ..v2019_03_22.aio.operations import Operations as OperationClass - elif api_version == '2019-07-01-preview': - from ..v2019_07_01_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)), api_version) + 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) + self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_provider_common = ResourceProviderCommonOperations( + self._client, self._config, self._serialize, self._deserialize + ) + 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.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - @property - def private_endpoint_connections(self): - """Instance depends on the API version: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. - * 2023-06-30: :class:`PrivateEndpointConnectionsOperations` - * 2023-06-30-preview: :class:`PrivateEndpointConnectionsOperations` - """ - api_version = self._get_api_version('private_endpoint_connections') - if 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)), api_version) + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + - @property - def private_link_resources(self): - """Instance depends on the API version: + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - * 2023-06-30: :class:`PrivateLinkResourcesOperations` - * 2023-06-30-preview: :class:`PrivateLinkResourcesOperations` + :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 """ - api_version = self._get_api_version('private_link_resources') - if 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)), api_version) - @property - def resource_provider_common(self): - """Instance depends on the API version: + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - * 2019-03-22: :class:`ResourceProviderCommonOperations` - * 2019-07-01-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 == '2019-03-22': - from ..v2019_03_22.aio.operations import ResourceProviderCommonOperations as OperationClass - elif api_version == '2019-07-01-preview': - from ..v2019_07_01_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)), api_version) - - async def close(self): + async def close(self) -> None: await self._client.close() - async def __aenter__(self): + + async def __aenter__(self) -> Self: await self._client.__aenter__() return self - async def __aexit__(self, *exc_details): + + 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/v2019_03_22/models/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/_patch.py similarity index 61% rename from sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_patch.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: 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/aio/operations/__init__.py similarity index 100% rename from sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/__init__.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/operations/__init__.py 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/aio/operations/_certificates_operations.py similarity index 92% rename from sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_certificates_operations.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/operations/_certificates_operations.py index 3253f63477d8..43db983b25e2 100644 --- 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/aio/operations/_certificates_operations.py @@ -5,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -24,6 +25,7 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer from ...operations._certificates_operations import ( build_create_or_update_request, build_delete_request, @@ -32,11 +34,8 @@ build_list_by_iot_hub_request, build_verify_request, ) +from .._configuration import IotHubClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +46,7 @@ class CertificatesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.iothub.v2023_06_30.aio.IotHubClient`'s + :class:`~azure.mgmt.iothub.aio.IotHubClient`'s :attr:`certificates` attribute. """ @@ -55,11 +54,10 @@ class CertificatesOperations: 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: IotHubClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def list_by_iot_hub( @@ -74,7 +72,7 @@ async def list_by_iot_hub( :param resource_name: The name of the IoT hub. Required. :type resource_name: str :return: CertificateListDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateListDescription + :rtype: ~azure.mgmt.iothub.models.CertificateListDescription :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -88,7 +86,7 @@ async def list_by_iot_hub( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) _request = build_list_by_iot_hub_request( @@ -135,7 +133,7 @@ async def get( :param certificate_name: The name of the certificate. Required. :type certificate_name: str :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :rtype: ~azure.mgmt.iothub.models.CertificateDescription :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -149,7 +147,7 @@ async def get( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) _request = build_get_request( @@ -205,7 +203,7 @@ async def create_or_update( :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 + :type certificate_description: ~azure.mgmt.iothub.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 @@ -213,7 +211,7 @@ async def create_or_update( Default value is "application/json". :paramtype content_type: str :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :rtype: ~azure.mgmt.iothub.models.CertificateDescription :raises ~azure.core.exceptions.HttpResponseError: """ @@ -248,7 +246,7 @@ async def create_or_update( Default value is "application/json". :paramtype content_type: str :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :rtype: ~azure.mgmt.iothub.models.CertificateDescription :raises ~azure.core.exceptions.HttpResponseError: """ @@ -274,13 +272,12 @@ async def create_or_update( :type certificate_name: str :param certificate_description: The certificate body. Is either a CertificateDescription type or a IO[bytes] type. Required. - :type certificate_description: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription or - IO[bytes] + :type certificate_description: ~azure.mgmt.iothub.models.CertificateDescription or IO[bytes] :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 :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :rtype: ~azure.mgmt.iothub.models.CertificateDescription :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -294,7 +291,7 @@ async def create_or_update( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) @@ -371,7 +368,7 @@ async def delete( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) _request = build_delete_request( @@ -419,7 +416,7 @@ async def generate_verification_code( :param if_match: ETag of the Certificate. Required. :type if_match: str :return: CertificateWithNonceDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateWithNonceDescription + :rtype: ~azure.mgmt.iothub.models.CertificateWithNonceDescription :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -433,7 +430,7 @@ async def generate_verification_code( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) _request = build_generate_verification_code_request( @@ -494,12 +491,12 @@ async def verify( :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 + ~azure.mgmt.iothub.models.CertificateVerificationDescription :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :rtype: ~azure.mgmt.iothub.models.CertificateDescription :raises ~azure.core.exceptions.HttpResponseError: """ @@ -534,7 +531,7 @@ async def verify( Default value is "application/json". :paramtype content_type: str :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :rtype: ~azure.mgmt.iothub.models.CertificateDescription :raises ~azure.core.exceptions.HttpResponseError: """ @@ -564,9 +561,9 @@ async def verify( :param certificate_verification_body: The name of the certificate. Is either a CertificateVerificationDescription type or a IO[bytes] type. Required. :type certificate_verification_body: - ~azure.mgmt.iothub.v2023_06_30.models.CertificateVerificationDescription or IO[bytes] + ~azure.mgmt.iothub.models.CertificateVerificationDescription or IO[bytes] :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :rtype: ~azure.mgmt.iothub.models.CertificateDescription :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -580,7 +577,7 @@ async def verify( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) 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/aio/operations/_iot_hub_operations.py similarity index 92% rename from sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_iot_hub_operations.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/operations/_iot_hub_operations.py index 6b740ce048f6..c088c1470132 100644 --- 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/aio/operations/_iot_hub_operations.py @@ -5,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -import sys from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -28,12 +29,10 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer from ...operations._iot_hub_operations import build_manual_failover_request +from .._configuration import IotHubClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -44,7 +43,7 @@ class IotHubOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.iothub.v2023_06_30.aio.IotHubClient`'s + :class:`~azure.mgmt.iothub.aio.IotHubClient`'s :attr:`iot_hub` attribute. """ @@ -52,11 +51,10 @@ class IotHubOperations: 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: IotHubClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _manual_failover_initial( self, @@ -76,7 +74,7 @@ async def _manual_failover_initial( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) @@ -155,7 +153,7 @@ async def begin_manual_failover( :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 + :type failover_input: ~azure.mgmt.iothub.models.FailoverInput :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -218,7 +216,7 @@ async def begin_manual_failover( 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[bytes] type. Required. - :type failover_input: ~azure.mgmt.iothub.v2023_06_30.models.FailoverInput or IO[bytes] + :type failover_input: ~azure.mgmt.iothub.models.FailoverInput or IO[bytes] :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: @@ -226,7 +224,7 @@ async def begin_manual_failover( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) 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/v2023_06_30/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/operations/_iot_hub_resource_operations.py similarity index 91% rename from sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_iot_hub_resource_operations.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/operations/_iot_hub_resource_operations.py index 0dec2d75c405..6552f574db70 100644 --- 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/aio/operations/_iot_hub_resource_operations.py @@ -6,11 +6,12 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +33,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer from ...operations._iot_hub_resource_operations import ( build_check_name_availability_request, build_create_event_hub_consumer_group_request, @@ -57,11 +59,8 @@ build_test_route_request, build_update_request, ) +from .._configuration import IotHubClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,7 +71,7 @@ class IotHubResourceOperations: # pylint: disable=too-many-public-methods **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.iothub.v2023_06_30.aio.IotHubClient`'s + :class:`~azure.mgmt.iothub.aio.IotHubClient`'s :attr:`iot_hub_resource` attribute. """ @@ -80,11 +79,10 @@ class IotHubResourceOperations: # pylint: disable=too-many-public-methods 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: IotHubClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -97,7 +95,7 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) :param resource_name: The name of the IoT hub. Required. :type resource_name: str :return: IotHubDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription + :rtype: ~azure.mgmt.iothub.models.IotHubDescription :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -111,7 +109,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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) _request = build_get_request( @@ -162,7 +160,7 @@ async def _create_or_update_initial( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) @@ -205,10 +203,16 @@ async def _create_or_update_initial( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -227,16 +231,14 @@ async def begin_create_or_update( 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. + 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.models.IotHubDescription + :type iot_hub_description: ~azure.mgmt.iothub.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 @@ -245,8 +247,7 @@ async def begin_create_or_update( :paramtype content_type: str :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] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.models.IotHubDescription] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -265,9 +266,7 @@ async def begin_create_or_update( 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. + 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 @@ -283,8 +282,7 @@ async def begin_create_or_update( :paramtype content_type: str :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] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.models.IotHubDescription] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -301,9 +299,7 @@ async def begin_create_or_update( 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. + 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 @@ -311,20 +307,19 @@ async def begin_create_or_update( :type resource_name: str :param iot_hub_description: The IoT hub metadata and security metadata. Is either a IotHubDescription type or a IO[bytes] type. Required. - :type iot_hub_description: ~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription or IO[bytes] + :type iot_hub_description: ~azure.mgmt.iothub.models.IotHubDescription or IO[bytes] :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 :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] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) 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) @@ -387,7 +382,7 @@ async def _update_initial( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) @@ -428,10 +423,15 @@ async def _update_initial( 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 = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -454,14 +454,13 @@ async def begin_update( :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 + :type iot_hub_tags: ~azure.mgmt.iothub.models.TagsResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :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] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.models.IotHubDescription] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -490,8 +489,7 @@ async def begin_update( :paramtype content_type: str :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] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.models.IotHubDescription] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -513,17 +511,16 @@ async def begin_update( :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[bytes] type. Required. - :type iot_hub_tags: ~azure.mgmt.iothub.v2023_06_30.models.TagsResource or IO[bytes] + :type iot_hub_tags: ~azure.mgmt.iothub.models.TagsResource or IO[bytes] :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] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) 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) @@ -545,9 +542,15 @@ async def begin_update( 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.http_response) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: @@ -581,7 +584,7 @@ async def _delete_initial( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( @@ -616,7 +619,6 @@ async def _delete_initial( response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -639,15 +641,14 @@ async def begin_delete( :type resource_name: str :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] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.models.IotHubDescription] or + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) 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) @@ -689,20 +690,19 @@ def get_long_running_output(pipeline_response): ) @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.IotHubDescription"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :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] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { @@ -733,7 +733,7 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._api_version + _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 ) @@ -769,7 +769,7 @@ async def get_next(next_link=None): @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.IotHubDescription"]: + ) -> AsyncItemPaged["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. @@ -777,14 +777,13 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str :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] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { @@ -816,7 +815,7 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._api_version + _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 ) @@ -862,7 +861,7 @@ async def get_stats( :param resource_name: The name of the IoT hub. Required. :type resource_name: str :return: RegistryStatistics or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.RegistryStatistics + :rtype: ~azure.mgmt.iothub.models.RegistryStatistics :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -876,7 +875,7 @@ async def get_stats( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) _request = build_get_stats_request( @@ -911,7 +910,7 @@ async def get_stats( @distributed_trace def get_valid_skus( self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.IotHubSkuDescription"]: + ) -> AsyncItemPaged["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. @@ -922,14 +921,13 @@ def get_valid_skus( :type resource_name: str :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] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { @@ -962,7 +960,7 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._api_version + _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 ) @@ -998,7 +996,7 @@ async def get_next(next_link=None): @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"]: + ) -> AsyncItemPaged["_models.EventHubConsumerGroupInfo"]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. @@ -1014,13 +1012,13 @@ def list_event_hub_consumer_groups( :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] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { @@ -1054,7 +1052,7 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._api_version + _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 ) @@ -1105,7 +1103,7 @@ async def get_event_hub_consumer_group( :param name: The name of the consumer group to retrieve. Required. :type name: str :return: EventHubConsumerGroupInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupInfo + :rtype: ~azure.mgmt.iothub.models.EventHubConsumerGroupInfo :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1119,7 +1117,7 @@ async def get_event_hub_consumer_group( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) _request = build_get_event_hub_consumer_group_request( @@ -1179,13 +1177,12 @@ async def create_event_hub_consumer_group( :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 + :type consumer_group_body: ~azure.mgmt.iothub.models.EventHubConsumerGroupBodyDescription :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: EventHubConsumerGroupInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupInfo + :rtype: ~azure.mgmt.iothub.models.EventHubConsumerGroupInfo :raises ~azure.core.exceptions.HttpResponseError: """ @@ -1220,7 +1217,7 @@ async def create_event_hub_consumer_group( Default value is "application/json". :paramtype content_type: str :return: EventHubConsumerGroupInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupInfo + :rtype: ~azure.mgmt.iothub.models.EventHubConsumerGroupInfo :raises ~azure.core.exceptions.HttpResponseError: """ @@ -1249,10 +1246,10 @@ async def create_event_hub_consumer_group( :type name: str :param consumer_group_body: The consumer group to add. Is either a EventHubConsumerGroupBodyDescription type or a IO[bytes] type. Required. - :type consumer_group_body: - ~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupBodyDescription or IO[bytes] + :type consumer_group_body: ~azure.mgmt.iothub.models.EventHubConsumerGroupBodyDescription or + IO[bytes] :return: EventHubConsumerGroupInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupInfo + :rtype: ~azure.mgmt.iothub.models.EventHubConsumerGroupInfo :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1266,7 +1263,7 @@ 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) @@ -1344,7 +1341,7 @@ async def delete_event_hub_consumer_group( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) _request = build_delete_event_hub_consumer_group_request( @@ -1377,7 +1374,7 @@ async def delete_event_hub_consumer_group( @distributed_trace def list_jobs( self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.JobResponse"]: + ) -> AsyncItemPaged["_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. @@ -1389,14 +1386,13 @@ def list_jobs( :param resource_name: The name of the IoT hub. Required. :type resource_name: str :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] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { @@ -1429,7 +1425,7 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._api_version + _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 ) @@ -1479,7 +1475,7 @@ async def get_job( :param job_id: The job identifier. Required. :type job_id: str :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :rtype: ~azure.mgmt.iothub.models.JobResponse :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1493,7 +1489,7 @@ async def get_job( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) _request = build_get_job_request( @@ -1529,7 +1525,7 @@ async def get_job( @distributed_trace def get_quota_metrics( self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.IotHubQuotaMetricInfo"]: + ) -> AsyncItemPaged["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. @@ -1541,13 +1537,13 @@ def get_quota_metrics( :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] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { @@ -1580,7 +1576,7 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._api_version + _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 ) @@ -1616,7 +1612,7 @@ async def get_next(next_link=None): @distributed_trace def get_endpoint_health( self, resource_group_name: str, iot_hub_name: str, **kwargs: Any - ) -> AsyncIterable["_models.EndpointHealthData"]: + ) -> AsyncItemPaged["_models.EndpointHealthData"]: """Get the health for routing endpoints. Get the health for routing endpoints. @@ -1626,14 +1622,13 @@ def get_endpoint_health( :param iot_hub_name: Required. :type iot_hub_name: str :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] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { @@ -1666,7 +1661,7 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._api_version + _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 ) @@ -1709,12 +1704,12 @@ async def check_name_availability( :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 + :type operation_inputs: ~azure.mgmt.iothub.models.OperationInputs :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: IotHubNameAvailabilityInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.IotHubNameAvailabilityInfo + :rtype: ~azure.mgmt.iothub.models.IotHubNameAvailabilityInfo :raises ~azure.core.exceptions.HttpResponseError: """ @@ -1733,7 +1728,7 @@ async def check_name_availability( Default value is "application/json". :paramtype content_type: str :return: IotHubNameAvailabilityInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.IotHubNameAvailabilityInfo + :rtype: ~azure.mgmt.iothub.models.IotHubNameAvailabilityInfo :raises ~azure.core.exceptions.HttpResponseError: """ @@ -1747,9 +1742,9 @@ async def check_name_availability( :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[bytes] type. Required. - :type operation_inputs: ~azure.mgmt.iothub.v2023_06_30.models.OperationInputs or IO[bytes] + :type operation_inputs: ~azure.mgmt.iothub.models.OperationInputs or IO[bytes] :return: IotHubNameAvailabilityInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.IotHubNameAvailabilityInfo + :rtype: ~azure.mgmt.iothub.models.IotHubNameAvailabilityInfo :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1763,7 +1758,7 @@ async def check_name_availability( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) @@ -1824,12 +1819,12 @@ async def test_all_routes( :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 + :type input: ~azure.mgmt.iothub.models.TestAllRoutesInput :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: TestAllRoutesResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.TestAllRoutesResult + :rtype: ~azure.mgmt.iothub.models.TestAllRoutesResult :raises ~azure.core.exceptions.HttpResponseError: """ @@ -1857,7 +1852,7 @@ async def test_all_routes( Default value is "application/json". :paramtype content_type: str :return: TestAllRoutesResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.TestAllRoutesResult + :rtype: ~azure.mgmt.iothub.models.TestAllRoutesResult :raises ~azure.core.exceptions.HttpResponseError: """ @@ -1879,9 +1874,9 @@ async def test_all_routes( :type resource_group_name: str :param input: Input for testing all routes. Is either a TestAllRoutesInput type or a IO[bytes] type. Required. - :type input: ~azure.mgmt.iothub.v2023_06_30.models.TestAllRoutesInput or IO[bytes] + :type input: ~azure.mgmt.iothub.models.TestAllRoutesInput or IO[bytes] :return: TestAllRoutesResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.TestAllRoutesResult + :rtype: ~azure.mgmt.iothub.models.TestAllRoutesResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1895,7 +1890,7 @@ async def test_all_routes( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) @@ -1958,12 +1953,12 @@ async def test_route( :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 + :type input: ~azure.mgmt.iothub.models.TestRouteInput :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: TestRouteResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.TestRouteResult + :rtype: ~azure.mgmt.iothub.models.TestRouteResult :raises ~azure.core.exceptions.HttpResponseError: """ @@ -1991,7 +1986,7 @@ async def test_route( Default value is "application/json". :paramtype content_type: str :return: TestRouteResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.TestRouteResult + :rtype: ~azure.mgmt.iothub.models.TestRouteResult :raises ~azure.core.exceptions.HttpResponseError: """ @@ -2013,9 +2008,9 @@ async def test_route( :type resource_group_name: str :param input: Route that needs to be tested. Is either a TestRouteInput type or a IO[bytes] type. Required. - :type input: ~azure.mgmt.iothub.v2023_06_30.models.TestRouteInput or IO[bytes] + :type input: ~azure.mgmt.iothub.models.TestRouteInput or IO[bytes] :return: TestRouteResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.TestRouteResult + :rtype: ~azure.mgmt.iothub.models.TestRouteResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2029,7 +2024,7 @@ async def test_route( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) @@ -2076,8 +2071,7 @@ async def test_route( @distributed_trace def list_keys( self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRule"]: - # pylint: disable=line-too-long + ) -> AsyncItemPaged["_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. @@ -2091,13 +2085,13 @@ def list_keys( :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] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { @@ -2130,7 +2124,7 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._api_version + _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 ) @@ -2180,7 +2174,7 @@ async def get_keys_for_key_name( :param key_name: The name of the shared access policy. Required. :type key_name: str :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.SharedAccessSignatureAuthorizationRule + :rtype: ~azure.mgmt.iothub.models.SharedAccessSignatureAuthorizationRule :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2194,7 +2188,7 @@ async def get_keys_for_key_name( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) _request = build_get_keys_for_key_name_request( @@ -2251,12 +2245,12 @@ async def export_devices( :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 + :type export_devices_parameters: ~azure.mgmt.iothub.models.ExportDevicesRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :rtype: ~azure.mgmt.iothub.models.JobResponse :raises ~azure.core.exceptions.HttpResponseError: """ @@ -2289,7 +2283,7 @@ async def export_devices( Default value is "application/json". :paramtype content_type: str :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :rtype: ~azure.mgmt.iothub.models.JobResponse :raises ~azure.core.exceptions.HttpResponseError: """ @@ -2315,10 +2309,9 @@ async def export_devices( :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. Is either a ExportDevicesRequest type or a IO[bytes] type. Required. - :type export_devices_parameters: ~azure.mgmt.iothub.v2023_06_30.models.ExportDevicesRequest or - IO[bytes] + :type export_devices_parameters: ~azure.mgmt.iothub.models.ExportDevicesRequest or IO[bytes] :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :rtype: ~azure.mgmt.iothub.models.JobResponse :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2332,7 +2325,7 @@ async def export_devices( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) @@ -2400,12 +2393,12 @@ async def import_devices( :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 + :type import_devices_parameters: ~azure.mgmt.iothub.models.ImportDevicesRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :rtype: ~azure.mgmt.iothub.models.JobResponse :raises ~azure.core.exceptions.HttpResponseError: """ @@ -2438,7 +2431,7 @@ async def import_devices( Default value is "application/json". :paramtype content_type: str :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :rtype: ~azure.mgmt.iothub.models.JobResponse :raises ~azure.core.exceptions.HttpResponseError: """ @@ -2464,10 +2457,9 @@ async def import_devices( :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. Is either a ImportDevicesRequest type or a IO[bytes] type. Required. - :type import_devices_parameters: ~azure.mgmt.iothub.v2023_06_30.models.ImportDevicesRequest or - IO[bytes] + :type import_devices_parameters: ~azure.mgmt.iothub.models.ImportDevicesRequest or IO[bytes] :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :rtype: ~azure.mgmt.iothub.models.JobResponse :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2481,7 +2473,7 @@ async def import_devices( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) 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/aio/operations/_operations.py similarity index 81% rename from sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_operations.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/operations/_operations.py index 06e9caecd335..26ab1660f69d 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/aio/operations/_operations.py @@ -5,10 +5,11 @@ # 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 +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -25,12 +26,10 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer from ...operations._operations import build_list_request +from .._configuration import IotHubClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,7 +40,7 @@ class Operations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.iothub.v2019_03_22.aio.IotHubClient`'s + :class:`~azure.mgmt.iothub.aio.IotHubClient`'s :attr:`operations` attribute. """ @@ -49,25 +48,23 @@ class Operations: 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: IotHubClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Operation"]: """Lists all of the available IoT Hub REST API operations. :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.Operation] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.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 "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { @@ -97,7 +94,7 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._api_version + _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 ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/operations/_patch.py similarity index 61% rename from sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_patch.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/operations/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/operations/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: 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/aio/operations/_private_endpoint_connections_operations.py similarity index 91% rename from sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_private_endpoint_connections_operations.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/operations/_private_endpoint_connections_operations.py index eebaccd3b249..88ddbe0e6b55 100644 --- 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/aio/operations/_private_endpoint_connections_operations.py @@ -5,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -import sys from typing import Any, AsyncIterator, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -28,17 +29,15 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer from ...operations._private_endpoint_connections_operations import ( build_delete_request, build_get_request, build_list_request, build_update_request, ) +from .._configuration import IotHubClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +48,7 @@ class PrivateEndpointConnectionsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.iothub.v2023_06_30.aio.IotHubClient`'s + :class:`~azure.mgmt.iothub.aio.IotHubClient`'s :attr:`private_endpoint_connections` attribute. """ @@ -57,11 +56,10 @@ class PrivateEndpointConnectionsOperations: 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: IotHubClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def list( @@ -76,7 +74,7 @@ async def list( :param resource_name: The name of the IoT hub. Required. :type resource_name: str :return: list of PrivateEndpointConnection or the result of cls(response) - :rtype: list[~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpointConnection] + :rtype: list[~azure.mgmt.iothub.models.PrivateEndpointConnection] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -90,7 +88,7 @@ async def list( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) _request = build_list_request( @@ -137,7 +135,7 @@ async def get( :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpointConnection + :rtype: ~azure.mgmt.iothub.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -151,7 +149,7 @@ async def get( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) _request = build_get_request( @@ -203,7 +201,7 @@ async def _update_initial( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) @@ -246,10 +244,16 @@ async def _update_initial( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -276,15 +280,13 @@ async def begin_update( :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 + :type private_endpoint_connection: ~azure.mgmt.iothub.models.PrivateEndpointConnection :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :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] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.models.PrivateEndpointConnection] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -317,8 +319,7 @@ async def begin_update( :paramtype content_type: str :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] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.models.PrivateEndpointConnection] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -343,18 +344,17 @@ async def begin_update( :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[bytes] type. Required. - :type private_endpoint_connection: - ~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpointConnection or IO[bytes] + :type private_endpoint_connection: ~azure.mgmt.iothub.models.PrivateEndpointConnection or + IO[bytes] :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] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) 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) @@ -413,7 +413,7 @@ async def _delete_initial( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( @@ -449,7 +449,6 @@ async def _delete_initial( response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -474,14 +473,13 @@ async def begin_delete( :type private_endpoint_connection_name: str :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] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) 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/v2023_06_30/aio/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/operations/_private_link_resources_operations.py similarity index 87% rename from sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_private_link_resources_operations.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/operations/_private_link_resources_operations.py index 021043f5a02e..fffad25249d0 100644 --- 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/aio/operations/_private_link_resources_operations.py @@ -5,9 +5,10 @@ # 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 collections.abc import MutableMapping from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -23,12 +24,10 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer from ...operations._private_link_resources_operations import build_get_request, build_list_request +from .._configuration import IotHubClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -39,7 +38,7 @@ class PrivateLinkResourcesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.iothub.v2023_06_30.aio.IotHubClient`'s + :class:`~azure.mgmt.iothub.aio.IotHubClient`'s :attr:`private_link_resources` attribute. """ @@ -47,11 +46,10 @@ class PrivateLinkResourcesOperations: 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: IotHubClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: @@ -64,7 +62,7 @@ async def list(self, resource_group_name: str, resource_name: str, **kwargs: Any :param resource_name: The name of the IoT hub. Required. :type resource_name: str :return: PrivateLinkResources or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.PrivateLinkResources + :rtype: ~azure.mgmt.iothub.models.PrivateLinkResources :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -78,7 +76,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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkResources] = kwargs.pop("cls", None) _request = build_list_request( @@ -125,7 +123,7 @@ async def get( :param group_id: The name of the private link resource. Required. :type group_id: str :return: GroupIdInformation or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.GroupIdInformation + :rtype: ~azure.mgmt.iothub.models.GroupIdInformation :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -139,7 +137,7 @@ async def get( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) _request = build_get_request( 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/aio/operations/_resource_provider_common_operations.py similarity index 82% rename from sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_resource_provider_common_operations.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/aio/operations/_resource_provider_common_operations.py index 4580c91e27d3..469d914865f8 100644 --- 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/aio/operations/_resource_provider_common_operations.py @@ -5,9 +5,10 @@ # 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 collections.abc import MutableMapping from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -23,12 +24,10 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer from ...operations._resource_provider_common_operations import build_get_subscription_quota_request +from .._configuration import IotHubClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -39,7 +38,7 @@ class ResourceProviderCommonOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.iothub.v2023_06_30.aio.IotHubClient`'s + :class:`~azure.mgmt.iothub.aio.IotHubClient`'s :attr:`resource_provider_common` attribute. """ @@ -47,11 +46,10 @@ class ResourceProviderCommonOperations: 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: IotHubClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: @@ -60,7 +58,7 @@ async def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptio Get the number of free and paid iot hubs in the subscription. :return: UserSubscriptionQuotaListResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.UserSubscriptionQuotaListResult + :rtype: ~azure.mgmt.iothub.models.UserSubscriptionQuotaListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -74,7 +72,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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) 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/apiview-properties.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/apiview-properties.json new file mode 100644 index 000000000000..4d5d9ef96300 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/apiview-properties.json @@ -0,0 +1,191 @@ +{ + "CrossLanguagePackageId": null, + "CrossLanguageDefinitionId": { + "azure.mgmt.iothub.models.ArmIdentity": null, + "azure.mgmt.iothub.models.ArmUserIdentity": null, + "azure.mgmt.iothub.models.CertificateBodyDescription": null, + "azure.mgmt.iothub.models.CertificateDescription": null, + "azure.mgmt.iothub.models.CertificateListDescription": null, + "azure.mgmt.iothub.models.CertificateProperties": null, + "azure.mgmt.iothub.models.CertificatePropertiesWithNonce": null, + "azure.mgmt.iothub.models.CertificateVerificationDescription": null, + "azure.mgmt.iothub.models.CertificateWithNonceDescription": null, + "azure.mgmt.iothub.models.CloudToDeviceProperties": null, + "azure.mgmt.iothub.models.EncryptionPropertiesDescription": null, + "azure.mgmt.iothub.models.EndpointHealthData": null, + "azure.mgmt.iothub.models.EndpointHealthDataListResult": null, + "azure.mgmt.iothub.models.EnrichmentProperties": null, + "azure.mgmt.iothub.models.ErrorDetails": null, + "azure.mgmt.iothub.models.EventHubConsumerGroupBodyDescription": null, + "azure.mgmt.iothub.models.EventHubConsumerGroupInfo": null, + "azure.mgmt.iothub.models.EventHubConsumerGroupName": null, + "azure.mgmt.iothub.models.EventHubConsumerGroupsListResult": null, + "azure.mgmt.iothub.models.EventHubProperties": null, + "azure.mgmt.iothub.models.ExportDevicesRequest": null, + "azure.mgmt.iothub.models.FailoverInput": null, + "azure.mgmt.iothub.models.FallbackRouteProperties": null, + "azure.mgmt.iothub.models.FeedbackProperties": null, + "azure.mgmt.iothub.models.GroupIdInformation": null, + "azure.mgmt.iothub.models.GroupIdInformationProperties": null, + "azure.mgmt.iothub.models.ImportDevicesRequest": null, + "azure.mgmt.iothub.models.IotHubCapacity": null, + "azure.mgmt.iothub.models.Resource": null, + "azure.mgmt.iothub.models.IotHubDescription": null, + "azure.mgmt.iothub.models.IotHubDescriptionListResult": null, + "azure.mgmt.iothub.models.IotHubLocationDescription": null, + "azure.mgmt.iothub.models.IotHubNameAvailabilityInfo": null, + "azure.mgmt.iothub.models.IotHubProperties": null, + "azure.mgmt.iothub.models.IotHubPropertiesDeviceStreams": null, + "azure.mgmt.iothub.models.IotHubQuotaMetricInfo": null, + "azure.mgmt.iothub.models.IotHubQuotaMetricInfoListResult": null, + "azure.mgmt.iothub.models.IotHubSkuDescription": null, + "azure.mgmt.iothub.models.IotHubSkuDescriptionListResult": null, + "azure.mgmt.iothub.models.IotHubSkuInfo": null, + "azure.mgmt.iothub.models.IpFilterRule": null, + "azure.mgmt.iothub.models.JobResponse": null, + "azure.mgmt.iothub.models.JobResponseListResult": null, + "azure.mgmt.iothub.models.KeyVaultKeyProperties": null, + "azure.mgmt.iothub.models.ManagedIdentity": null, + "azure.mgmt.iothub.models.MatchedRoute": null, + "azure.mgmt.iothub.models.MessagingEndpointProperties": null, + "azure.mgmt.iothub.models.Name": null, + "azure.mgmt.iothub.models.NetworkRuleSetIpRule": null, + "azure.mgmt.iothub.models.NetworkRuleSetProperties": null, + "azure.mgmt.iothub.models.Operation": null, + "azure.mgmt.iothub.models.OperationDisplay": null, + "azure.mgmt.iothub.models.OperationInputs": null, + "azure.mgmt.iothub.models.OperationListResult": null, + "azure.mgmt.iothub.models.PrivateEndpoint": null, + "azure.mgmt.iothub.models.PrivateEndpointConnection": null, + "azure.mgmt.iothub.models.PrivateEndpointConnectionProperties": null, + "azure.mgmt.iothub.models.PrivateLinkResources": null, + "azure.mgmt.iothub.models.PrivateLinkServiceConnectionState": null, + "azure.mgmt.iothub.models.RegistryStatistics": null, + "azure.mgmt.iothub.models.RootCertificateProperties": null, + "azure.mgmt.iothub.models.RouteCompilationError": null, + "azure.mgmt.iothub.models.RouteErrorPosition": null, + "azure.mgmt.iothub.models.RouteErrorRange": null, + "azure.mgmt.iothub.models.RouteProperties": null, + "azure.mgmt.iothub.models.RoutingCosmosDBSqlApiProperties": null, + "azure.mgmt.iothub.models.RoutingEndpoints": null, + "azure.mgmt.iothub.models.RoutingEventHubProperties": null, + "azure.mgmt.iothub.models.RoutingMessage": null, + "azure.mgmt.iothub.models.RoutingProperties": null, + "azure.mgmt.iothub.models.RoutingServiceBusQueueEndpointProperties": null, + "azure.mgmt.iothub.models.RoutingServiceBusTopicEndpointProperties": null, + "azure.mgmt.iothub.models.RoutingStorageContainerProperties": null, + "azure.mgmt.iothub.models.RoutingTwin": null, + "azure.mgmt.iothub.models.RoutingTwinProperties": null, + "azure.mgmt.iothub.models.SharedAccessSignatureAuthorizationRule": null, + "azure.mgmt.iothub.models.SharedAccessSignatureAuthorizationRuleListResult": null, + "azure.mgmt.iothub.models.StorageEndpointProperties": null, + "azure.mgmt.iothub.models.SystemData": null, + "azure.mgmt.iothub.models.TagsResource": null, + "azure.mgmt.iothub.models.TestAllRoutesInput": null, + "azure.mgmt.iothub.models.TestAllRoutesResult": null, + "azure.mgmt.iothub.models.TestRouteInput": null, + "azure.mgmt.iothub.models.TestRouteResult": null, + "azure.mgmt.iothub.models.TestRouteResultDetails": null, + "azure.mgmt.iothub.models.UserSubscriptionQuota": null, + "azure.mgmt.iothub.models.UserSubscriptionQuotaListResult": null, + "azure.mgmt.iothub.models.AccessRights": null, + "azure.mgmt.iothub.models.IpFilterActionType": null, + "azure.mgmt.iothub.models.NetworkRuleIPAction": null, + "azure.mgmt.iothub.models.PrivateLinkServiceConnectionStatus": null, + "azure.mgmt.iothub.models.AuthenticationType": null, + "azure.mgmt.iothub.models.RoutingStorageContainerPropertiesEncoding": null, + "azure.mgmt.iothub.models.RoutingSource": null, + "azure.mgmt.iothub.models.IotHubReplicaRoleType": null, + "azure.mgmt.iothub.models.PublicNetworkAccess": null, + "azure.mgmt.iothub.models.DefaultAction": null, + "azure.mgmt.iothub.models.Capabilities": null, + "azure.mgmt.iothub.models.IpVersion": null, + "azure.mgmt.iothub.models.IotHubSku": null, + "azure.mgmt.iothub.models.IotHubSkuTier": null, + "azure.mgmt.iothub.models.ResourceIdentityType": null, + "azure.mgmt.iothub.models.CreatedByType": null, + "azure.mgmt.iothub.models.IotHubScaleType": null, + "azure.mgmt.iothub.models.JobType": null, + "azure.mgmt.iothub.models.JobStatus": null, + "azure.mgmt.iothub.models.EndpointHealthStatus": null, + "azure.mgmt.iothub.models.RouteErrorSeverity": null, + "azure.mgmt.iothub.models.TestResultStatus": null, + "azure.mgmt.iothub.models.IotHubNameUnavailabilityReason": null, + "azure.mgmt.iothub.operations.Operations.list": null, + "azure.mgmt.iothub.aio.operations.Operations.list": null, + "azure.mgmt.iothub.operations.IotHubResourceOperations.get": null, + "azure.mgmt.iothub.aio.operations.IotHubResourceOperations.get": null, + "azure.mgmt.iothub.operations.IotHubResourceOperations.begin_create_or_update": null, + "azure.mgmt.iothub.aio.operations.IotHubResourceOperations.begin_create_or_update": null, + "azure.mgmt.iothub.operations.IotHubResourceOperations.begin_update": null, + "azure.mgmt.iothub.aio.operations.IotHubResourceOperations.begin_update": null, + "azure.mgmt.iothub.operations.IotHubResourceOperations.begin_delete": null, + "azure.mgmt.iothub.aio.operations.IotHubResourceOperations.begin_delete": null, + "azure.mgmt.iothub.operations.IotHubResourceOperations.list_by_subscription": null, + "azure.mgmt.iothub.aio.operations.IotHubResourceOperations.list_by_subscription": null, + "azure.mgmt.iothub.operations.IotHubResourceOperations.list_by_resource_group": null, + "azure.mgmt.iothub.aio.operations.IotHubResourceOperations.list_by_resource_group": null, + "azure.mgmt.iothub.operations.IotHubResourceOperations.get_stats": null, + "azure.mgmt.iothub.aio.operations.IotHubResourceOperations.get_stats": null, + "azure.mgmt.iothub.operations.IotHubResourceOperations.get_valid_skus": null, + "azure.mgmt.iothub.aio.operations.IotHubResourceOperations.get_valid_skus": null, + "azure.mgmt.iothub.operations.IotHubResourceOperations.list_event_hub_consumer_groups": null, + "azure.mgmt.iothub.aio.operations.IotHubResourceOperations.list_event_hub_consumer_groups": null, + "azure.mgmt.iothub.operations.IotHubResourceOperations.get_event_hub_consumer_group": null, + "azure.mgmt.iothub.aio.operations.IotHubResourceOperations.get_event_hub_consumer_group": null, + "azure.mgmt.iothub.operations.IotHubResourceOperations.create_event_hub_consumer_group": null, + "azure.mgmt.iothub.aio.operations.IotHubResourceOperations.create_event_hub_consumer_group": null, + "azure.mgmt.iothub.operations.IotHubResourceOperations.delete_event_hub_consumer_group": null, + "azure.mgmt.iothub.aio.operations.IotHubResourceOperations.delete_event_hub_consumer_group": null, + "azure.mgmt.iothub.operations.IotHubResourceOperations.list_jobs": null, + "azure.mgmt.iothub.aio.operations.IotHubResourceOperations.list_jobs": null, + "azure.mgmt.iothub.operations.IotHubResourceOperations.get_job": null, + "azure.mgmt.iothub.aio.operations.IotHubResourceOperations.get_job": null, + "azure.mgmt.iothub.operations.IotHubResourceOperations.get_quota_metrics": null, + "azure.mgmt.iothub.aio.operations.IotHubResourceOperations.get_quota_metrics": null, + "azure.mgmt.iothub.operations.IotHubResourceOperations.get_endpoint_health": null, + "azure.mgmt.iothub.aio.operations.IotHubResourceOperations.get_endpoint_health": null, + "azure.mgmt.iothub.operations.IotHubResourceOperations.check_name_availability": null, + "azure.mgmt.iothub.aio.operations.IotHubResourceOperations.check_name_availability": null, + "azure.mgmt.iothub.operations.IotHubResourceOperations.test_all_routes": null, + "azure.mgmt.iothub.aio.operations.IotHubResourceOperations.test_all_routes": null, + "azure.mgmt.iothub.operations.IotHubResourceOperations.test_route": null, + "azure.mgmt.iothub.aio.operations.IotHubResourceOperations.test_route": null, + "azure.mgmt.iothub.operations.IotHubResourceOperations.list_keys": null, + "azure.mgmt.iothub.aio.operations.IotHubResourceOperations.list_keys": null, + "azure.mgmt.iothub.operations.IotHubResourceOperations.get_keys_for_key_name": null, + "azure.mgmt.iothub.aio.operations.IotHubResourceOperations.get_keys_for_key_name": null, + "azure.mgmt.iothub.operations.IotHubResourceOperations.export_devices": null, + "azure.mgmt.iothub.aio.operations.IotHubResourceOperations.export_devices": null, + "azure.mgmt.iothub.operations.IotHubResourceOperations.import_devices": null, + "azure.mgmt.iothub.aio.operations.IotHubResourceOperations.import_devices": null, + "azure.mgmt.iothub.operations.ResourceProviderCommonOperations.get_subscription_quota": null, + "azure.mgmt.iothub.aio.operations.ResourceProviderCommonOperations.get_subscription_quota": null, + "azure.mgmt.iothub.operations.CertificatesOperations.list_by_iot_hub": null, + "azure.mgmt.iothub.aio.operations.CertificatesOperations.list_by_iot_hub": null, + "azure.mgmt.iothub.operations.CertificatesOperations.get": null, + "azure.mgmt.iothub.aio.operations.CertificatesOperations.get": null, + "azure.mgmt.iothub.operations.CertificatesOperations.create_or_update": null, + "azure.mgmt.iothub.aio.operations.CertificatesOperations.create_or_update": null, + "azure.mgmt.iothub.operations.CertificatesOperations.delete": null, + "azure.mgmt.iothub.aio.operations.CertificatesOperations.delete": null, + "azure.mgmt.iothub.operations.CertificatesOperations.generate_verification_code": null, + "azure.mgmt.iothub.aio.operations.CertificatesOperations.generate_verification_code": null, + "azure.mgmt.iothub.operations.CertificatesOperations.verify": null, + "azure.mgmt.iothub.aio.operations.CertificatesOperations.verify": null, + "azure.mgmt.iothub.operations.IotHubOperations.begin_manual_failover": null, + "azure.mgmt.iothub.aio.operations.IotHubOperations.begin_manual_failover": null, + "azure.mgmt.iothub.operations.PrivateLinkResourcesOperations.list": null, + "azure.mgmt.iothub.aio.operations.PrivateLinkResourcesOperations.list": null, + "azure.mgmt.iothub.operations.PrivateLinkResourcesOperations.get": null, + "azure.mgmt.iothub.aio.operations.PrivateLinkResourcesOperations.get": null, + "azure.mgmt.iothub.operations.PrivateEndpointConnectionsOperations.list": null, + "azure.mgmt.iothub.aio.operations.PrivateEndpointConnectionsOperations.list": null, + "azure.mgmt.iothub.operations.PrivateEndpointConnectionsOperations.get": null, + "azure.mgmt.iothub.aio.operations.PrivateEndpointConnectionsOperations.get": null, + "azure.mgmt.iothub.operations.PrivateEndpointConnectionsOperations.begin_update": null, + "azure.mgmt.iothub.aio.operations.PrivateEndpointConnectionsOperations.begin_update": null, + "azure.mgmt.iothub.operations.PrivateEndpointConnectionsOperations.begin_delete": null, + "azure.mgmt.iothub.aio.operations.PrivateEndpointConnectionsOperations.begin_delete": null + } +} \ 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/azure/mgmt/iothub/generated_samples/mgmt/iothub/check_name_availability.py similarity index 91% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/check_name_availability.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/check_name_availability.py index 789aa3a55ef9..2e1b523ca2d1 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/check_name_availability.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/check_name_availability.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/checkNameAvailability.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iot_hub_manual_failover.py similarity index 92% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iot_hub_manual_failover.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iot_hub_manual_failover.py index f5775b72e10f..7cec2cc0e9c9 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iot_hub_manual_failover.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iot_hub_manual_failover.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/IotHub_ManualFailover.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/examples/IotHub_ManualFailover.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_certificatescreateorupdate.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_certificatescreateorupdate.py similarity index 92% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_certificatescreateorupdate.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_certificatescreateorupdate.py index 575a1006c188..96038652967a 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_certificatescreateorupdate.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_certificatescreateorupdate.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_certificatescreateorupdate.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_certificatesdelete.py similarity index 91% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_certificatesdelete.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_certificatesdelete.py index 5665ccc0e1a1..35d3301450ed 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_certificatesdelete.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_certificatesdelete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_certificatesdelete.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_certverify.py similarity index 92% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_certverify.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_certverify.py index c08e4567ac08..c6ffec1a5389 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_certverify.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_certverify.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -40,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_certverify.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_create_or_update.py similarity index 92% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_create_or_update.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_create_or_update.py index 12e892313a26..b63f246b9121 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_create_or_update.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_create_or_update.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -42,11 +43,12 @@ def main(): "feedback": {"lockDurationAsIso8601": "PT1M", "maxDeliveryCount": 10, "ttlAsIso8601": "PT1H"}, "maxDeliveryCount": 10, }, - "enableDataResidency": False, + "enableDataResidency": True, "enableFileUploadNotifications": False, "eventHubEndpoints": {"events": {"partitionCount": 2, "retentionTimeInDays": 1}}, "features": "None", "ipFilterRules": [], + "ipVersion": "ipv4ipv6", "messagingEndpoints": { "fileNotifications": { "lockDurationAsIso8601": "PT1M", @@ -63,6 +65,7 @@ def main(): {"action": "Allow", "filterName": "rule2", "ipMask": "157.55.59.128/25"}, ], }, + "rootCertificate": {"enableRootCertificateV2": True}, "routing": { "endpoints": { "eventHubs": [], @@ -90,6 +93,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_createOrUpdate.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_createconsumergroup.py similarity index 92% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_createconsumergroup.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_createconsumergroup.py index 66a67aa5cdf4..62d941c9b344 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_createconsumergroup.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_createconsumergroup.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -40,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_createconsumergroup.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_delete.py similarity index 92% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_delete.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_delete.py index 49de02061ce9..1ae3622c22fc 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_delete.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_delete.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_delete.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_deleteconsumergroup.py similarity index 91% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_deleteconsumergroup.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_deleteconsumergroup.py index 8af38c3decc8..7af9962988e8 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_deleteconsumergroup.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_deleteconsumergroup.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_deleteconsumergroup.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_deleteprivateendpointconnection.py similarity index 91% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_deleteprivateendpointconnection.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_deleteprivateendpointconnection.py index 177ba05574d6..20fb8d5006fb 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_deleteprivateendpointconnection.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_deleteprivateendpointconnection.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_deleteprivateendpointconnection.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_exportdevices.py similarity index 73% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_exportdevices.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_exportdevices.py index 54076b51606a..4cbc19bb86d7 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_exportdevices.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_exportdevices.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -33,11 +34,18 @@ def main(): response = client.iot_hub_resource.export_devices( resource_group_name="myResourceGroup", resource_name="testHub", - export_devices_parameters={"excludeKeys": True, "exportBlobContainerUri": "testBlob"}, + export_devices_parameters={ + "authenticationType": "identityBased", + "excludeKeys": True, + "exportBlobContainerUri": "testBlob", + "identity": { + "userAssignedIdentity": "/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1" + }, + }, ) print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_exportdevices.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_generateverificationcode.py similarity index 91% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_generateverificationcode.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_generateverificationcode.py index 1b59a5b7419d..256e85cd6a3d 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_generateverificationcode.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_generateverificationcode.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_generateverificationcode.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_get.py similarity index 92% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_get.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_get.py index ea4f00b33428..71caa8c1ee26 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_get.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_get.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_get.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_getcertificate.py similarity index 92% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getcertificate.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_getcertificate.py index 07a346f6bccb..cd87bc25376a 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getcertificate.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_getcertificate.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_getcertificate.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_getconsumergroup.py similarity index 92% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getconsumergroup.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_getconsumergroup.py index 2a8344101a4f..a0df04338f2c 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getconsumergroup.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_getconsumergroup.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_getconsumergroup.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_getjob.py similarity index 92% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getjob.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_getjob.py index f0cae1edd8ac..b93b10b85472 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getjob.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_getjob.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_getjob.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_getkey.py similarity index 92% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getkey.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_getkey.py index 2a34f85afd2c..fdc6481605e6 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getkey.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_getkey.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_getkey.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_getprivateendpointconnection.py similarity index 91% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getprivateendpointconnection.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_getprivateendpointconnection.py index 16bba8c1455d..d0cad845fadd 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getprivateendpointconnection.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_getprivateendpointconnection.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_getprivateendpointconnection.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_getprivatelinkresources.py similarity index 91% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getprivatelinkresources.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_getprivatelinkresources.py index e2e0df74eb69..eabaae754c2c 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getprivatelinkresources.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_getprivatelinkresources.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_getprivatelinkresources.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_getskus.py similarity index 92% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getskus.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_getskus.py index b2bbd5980553..3137b2c1dbb5 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_getskus.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_getskus.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_getskus.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_importdevices.py similarity index 92% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_importdevices.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_importdevices.py index d711d02401f1..ab10ec192c82 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_importdevices.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_importdevices.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_importdevices.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_listbyrg.py similarity index 92% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listbyrg.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_listbyrg.py index 93aa05547cd5..9879d0d4d9e0 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listbyrg.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_listbyrg.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_listbyrg.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_listbysubscription.py similarity index 91% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listbysubscription.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_listbysubscription.py index 4931ca3f8bae..84a92c965fd0 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listbysubscription.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_listbysubscription.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -35,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_listbysubscription.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_listcertificates.py similarity index 91% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listcertificates.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_listcertificates.py index 7b7d40c1658a..cf33107ae941 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listcertificates.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_listcertificates.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_listcertificates.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_listehgroups.py similarity index 92% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listehgroups.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_listehgroups.py index f35a76508df7..42291aae9b5c 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listehgroups.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_listehgroups.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_listehgroups.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_listjobs.py similarity index 92% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listjobs.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_listjobs.py index cbff941eeae3..9ce4fd0c1ce0 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listjobs.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_listjobs.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_listjobs.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_listkeys.py similarity index 92% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listkeys.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_listkeys.py index 4d356454be61..d4869ec65dc2 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listkeys.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_listkeys.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_listkeys.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_listprivateendpointconnections.py similarity index 91% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listprivateendpointconnections.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_listprivateendpointconnections.py index 1d870e1cf4ea..72c5c197a3b1 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listprivateendpointconnections.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_listprivateendpointconnections.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_listprivateendpointconnections.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_listprivatelinkresources.py similarity index 91% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listprivatelinkresources.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_listprivatelinkresources.py index 160cec4e31fa..c69b54ff2da1 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_listprivatelinkresources.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_listprivatelinkresources.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_listprivatelinkresources.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_operations.py similarity index 91% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_operations.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_operations.py index 37e7d346543e..63dfd4d2f795 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -35,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_operations.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/examples/iothub_operations.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_quotametrics.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_quotametrics.py similarity index 92% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_quotametrics.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_quotametrics.py index 1be837b7b9f8..84cdd065c5f8 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_quotametrics.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_quotametrics.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_quotametrics.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_routingendpointhealth.py similarity index 91% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_routingendpointhealth.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_routingendpointhealth.py index d0fdc33db4d9..c60af95aefbc 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_routingendpointhealth.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_routingendpointhealth.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_routingendpointhealth.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_stats.py similarity index 92% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_stats.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_stats.py index 797bc1079e85..f7a43a171238 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_stats.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_stats.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_stats.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_testallroutes.py similarity index 93% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_testallroutes.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_testallroutes.py index d2d7b67a8008..acfcd5b29a49 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_testallroutes.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_testallroutes.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -45,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_testallroutes.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_testnewroute.py similarity index 93% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_testnewroute.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_testnewroute.py index ff073bcf2a96..ce0728cebaf0 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_testnewroute.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_testnewroute.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -45,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_testnewroute.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_updateprivateendpointconnection.py similarity index 92% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_updateprivateendpointconnection.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_updateprivateendpointconnection.py index 147e6bb94c1c..e23fdaacfb62 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_updateprivateendpointconnection.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_updateprivateendpointconnection.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -46,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_updateprivateendpointconnection.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/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/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_usages.py similarity index 92% rename from sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_usages.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_usages.py index 60f6e67766d9..8a85f1d9448a 100644 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_usages.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_samples/mgmt/iothub/iothub_usages.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -34,6 +35,6 @@ def main(): print(response) -# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_usages.json +# x-ms-original-file: specification/iothub/resource-manager/Microsoft.Devices/preview/2023-06-30-preview/examples/iothub_usages.json if __name__ == "__main__": main() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/conftest.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/conftest.py new file mode 100644 index 000000000000..9295eb6a84ee --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/conftest.py @@ -0,0 +1,35 @@ +# 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. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# For security, please avoid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + iothub_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + iothub_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + iothub_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + iothub_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=iothub_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=iothub_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=iothub_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=iothub_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_certificates_operations.py new file mode 100644 index 000000000000..e1c354797bef --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_certificates_operations.py @@ -0,0 +1,115 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.iothub import IotHubClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestIotHubCertificatesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(IotHubClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_certificates_list_by_iot_hub(self, resource_group): + response = self.client.certificates.list_by_iot_hub( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_certificates_get(self, resource_group): + response = self.client.certificates.get( + resource_group_name=resource_group.name, + resource_name="str", + certificate_name="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_certificates_create_or_update(self, resource_group): + response = self.client.certificates.create_or_update( + resource_group_name=resource_group.name, + resource_name="str", + certificate_name="str", + certificate_description={ + "etag": "str", + "id": "str", + "name": "str", + "properties": { + "certificate": "str", + "created": "2020-02-20 00:00:00", + "expiry": "2020-02-20 00:00:00", + "isVerified": bool, + "subject": "str", + "thumbprint": "str", + "updated": "2020-02-20 00:00:00", + }, + "type": "str", + }, + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_certificates_delete(self, resource_group): + response = self.client.certificates.delete( + resource_group_name=resource_group.name, + resource_name="str", + certificate_name="str", + if_match="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_certificates_generate_verification_code(self, resource_group): + response = self.client.certificates.generate_verification_code( + resource_group_name=resource_group.name, + resource_name="str", + certificate_name="str", + if_match="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_certificates_verify(self, resource_group): + response = self.client.certificates.verify( + resource_group_name=resource_group.name, + resource_name="str", + certificate_name="str", + if_match="str", + certificate_verification_body={"certificate": "str"}, + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_certificates_operations_async.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_certificates_operations_async.py new file mode 100644 index 000000000000..02f55b70a88d --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_certificates_operations_async.py @@ -0,0 +1,116 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.iothub.aio import IotHubClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestIotHubCertificatesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(IotHubClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_certificates_list_by_iot_hub(self, resource_group): + response = await self.client.certificates.list_by_iot_hub( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_certificates_get(self, resource_group): + response = await self.client.certificates.get( + resource_group_name=resource_group.name, + resource_name="str", + certificate_name="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_certificates_create_or_update(self, resource_group): + response = await self.client.certificates.create_or_update( + resource_group_name=resource_group.name, + resource_name="str", + certificate_name="str", + certificate_description={ + "etag": "str", + "id": "str", + "name": "str", + "properties": { + "certificate": "str", + "created": "2020-02-20 00:00:00", + "expiry": "2020-02-20 00:00:00", + "isVerified": bool, + "subject": "str", + "thumbprint": "str", + "updated": "2020-02-20 00:00:00", + }, + "type": "str", + }, + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_certificates_delete(self, resource_group): + response = await self.client.certificates.delete( + resource_group_name=resource_group.name, + resource_name="str", + certificate_name="str", + if_match="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_certificates_generate_verification_code(self, resource_group): + response = await self.client.certificates.generate_verification_code( + resource_group_name=resource_group.name, + resource_name="str", + certificate_name="str", + if_match="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_certificates_verify(self, resource_group): + response = await self.client.certificates.verify( + resource_group_name=resource_group.name, + resource_name="str", + certificate_name="str", + if_match="str", + certificate_verification_body={"certificate": "str"}, + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_iot_hub_operations.py new file mode 100644 index 000000000000..1e6339c8e3ed --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_iot_hub_operations.py @@ -0,0 +1,32 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.iothub import IotHubClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestIotHubIotHubOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(IotHubClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_hub_begin_manual_failover(self, resource_group): + response = self.client.iot_hub.begin_manual_failover( + iot_hub_name="str", + resource_group_name=resource_group.name, + failover_input={"failoverRegion": "str"}, + api_version="2023-06-30-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_iot_hub_operations_async.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_iot_hub_operations_async.py new file mode 100644 index 000000000000..687c3c4e8bbf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_iot_hub_operations_async.py @@ -0,0 +1,35 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.iothub.aio import IotHubClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestIotHubIotHubOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(IotHubClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_hub_begin_manual_failover(self, resource_group): + response = await ( + await self.client.iot_hub.begin_manual_failover( + iot_hub_name="str", + resource_group_name=resource_group.name, + failover_input={"failoverRegion": "str"}, + api_version="2023-06-30-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_iot_hub_resource_operations.py new file mode 100644 index 000000000000..a162ddbdd499 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_iot_hub_resource_operations.py @@ -0,0 +1,536 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.iothub import IotHubClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestIotHubIotHubResourceOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(IotHubClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_hub_resource_get(self, resource_group): + response = self.client.iot_hub_resource.get( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_hub_resource_begin_create_or_update(self, resource_group): + response = self.client.iot_hub_resource.begin_create_or_update( + resource_group_name=resource_group.name, + resource_name="str", + iot_hub_description={ + "location": "str", + "sku": {"name": "str", "capacity": 0, "tier": "str"}, + "etag": "str", + "id": "str", + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "name": "str", + "properties": { + "allowedFqdnList": ["str"], + "authorizationPolicies": [ + {"keyName": "str", "rights": "str", "primaryKey": "str", "secondaryKey": "str"} + ], + "cloudToDevice": { + "defaultTtlAsIso8601": "1 day, 0:00:00", + "feedback": { + "lockDurationAsIso8601": "1 day, 0:00:00", + "maxDeliveryCount": 0, + "ttlAsIso8601": "1 day, 0:00:00", + }, + "maxDeliveryCount": 0, + }, + "comments": "str", + "deviceStreams": {"streamingEndpoints": ["str"]}, + "disableDeviceSAS": bool, + "disableLocalAuth": bool, + "disableModuleSAS": bool, + "enableDataResidency": bool, + "enableFileUploadNotifications": bool, + "encryption": { + "keySource": "str", + "keyVaultProperties": [{"identity": {"userAssignedIdentity": "str"}, "keyIdentifier": "str"}], + }, + "eventHubEndpoints": { + "str": { + "endpoint": "str", + "partitionCount": 0, + "partitionIds": ["str"], + "path": "str", + "retentionTimeInDays": 0, + } + }, + "features": "str", + "hostName": "str", + "ipFilterRules": [{"action": "str", "filterName": "str", "ipMask": "str"}], + "ipVersion": "str", + "locations": [{"location": "str", "role": "str"}], + "messagingEndpoints": { + "str": { + "lockDurationAsIso8601": "1 day, 0:00:00", + "maxDeliveryCount": 0, + "ttlAsIso8601": "1 day, 0:00:00", + } + }, + "minTlsVersion": "str", + "networkRuleSets": { + "applyToBuiltInEventHubEndpoint": bool, + "ipRules": [{"filterName": "str", "ipMask": "str", "action": "Allow"}], + "defaultAction": "Deny", + }, + "privateEndpointConnections": [ + { + "properties": { + "privateLinkServiceConnectionState": { + "description": "str", + "status": "str", + "actionsRequired": "str", + }, + "privateEndpoint": {"id": "str"}, + }, + "id": "str", + "name": "str", + "type": "str", + } + ], + "provisioningState": "str", + "publicNetworkAccess": "str", + "restrictOutboundNetworkAccess": bool, + "rootCertificate": {"enableRootCertificateV2": bool, "lastUpdatedTimeUtc": "2020-02-20 00:00:00"}, + "routing": { + "endpoints": { + "cosmosDBSqlContainers": [ + { + "containerName": "str", + "databaseName": "str", + "endpointUri": "str", + "name": "str", + "authenticationType": "str", + "id": "str", + "identity": {"userAssignedIdentity": "str"}, + "partitionKeyName": "str", + "partitionKeyTemplate": "str", + "primaryKey": "str", + "resourceGroup": "str", + "secondaryKey": "str", + "subscriptionId": "str", + } + ], + "eventHubs": [ + { + "name": "str", + "authenticationType": "str", + "connectionString": "str", + "endpointUri": "str", + "entityPath": "str", + "id": "str", + "identity": {"userAssignedIdentity": "str"}, + "resourceGroup": "str", + "subscriptionId": "str", + } + ], + "serviceBusQueues": [ + { + "name": "str", + "authenticationType": "str", + "connectionString": "str", + "endpointUri": "str", + "entityPath": "str", + "id": "str", + "identity": {"userAssignedIdentity": "str"}, + "resourceGroup": "str", + "subscriptionId": "str", + } + ], + "serviceBusTopics": [ + { + "name": "str", + "authenticationType": "str", + "connectionString": "str", + "endpointUri": "str", + "entityPath": "str", + "id": "str", + "identity": {"userAssignedIdentity": "str"}, + "resourceGroup": "str", + "subscriptionId": "str", + } + ], + "storageContainers": [ + { + "containerName": "str", + "name": "str", + "authenticationType": "str", + "batchFrequencyInSeconds": 0, + "connectionString": "str", + "encoding": "str", + "endpointUri": "str", + "fileNameFormat": "str", + "id": "str", + "identity": {"userAssignedIdentity": "str"}, + "maxChunkSizeInBytes": 0, + "resourceGroup": "str", + "subscriptionId": "str", + } + ], + }, + "enrichments": [{"endpointNames": ["str"], "key": "str", "value": "str"}], + "fallbackRoute": { + "endpointNames": ["str"], + "isEnabled": bool, + "source": "str", + "condition": "str", + "name": "str", + }, + "routes": [ + { + "endpointNames": ["str"], + "isEnabled": bool, + "name": "str", + "source": "str", + "condition": "str", + } + ], + }, + "state": "str", + "storageEndpoints": { + "str": { + "connectionString": "str", + "containerName": "str", + "authenticationType": "str", + "identity": {"userAssignedIdentity": "str"}, + "sasTtlAsIso8601": "1 day, 0:00:00", + } + }, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-06-30-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_hub_resource_begin_update(self, resource_group): + response = self.client.iot_hub_resource.begin_update( + resource_group_name=resource_group.name, + resource_name="str", + iot_hub_tags={"tags": {"str": "str"}}, + api_version="2023-06-30-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_hub_resource_begin_delete(self, resource_group): + response = self.client.iot_hub_resource.begin_delete( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-06-30-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_hub_resource_list_by_subscription(self, resource_group): + response = self.client.iot_hub_resource.list_by_subscription( + api_version="2023-06-30-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_hub_resource_list_by_resource_group(self, resource_group): + response = self.client.iot_hub_resource.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2023-06-30-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_hub_resource_get_stats(self, resource_group): + response = self.client.iot_hub_resource.get_stats( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_hub_resource_get_valid_skus(self, resource_group): + response = self.client.iot_hub_resource.get_valid_skus( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-06-30-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_hub_resource_list_event_hub_consumer_groups(self, resource_group): + response = self.client.iot_hub_resource.list_event_hub_consumer_groups( + resource_group_name=resource_group.name, + resource_name="str", + event_hub_endpoint_name="str", + api_version="2023-06-30-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_hub_resource_get_event_hub_consumer_group(self, resource_group): + response = self.client.iot_hub_resource.get_event_hub_consumer_group( + resource_group_name=resource_group.name, + resource_name="str", + event_hub_endpoint_name="str", + name="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_hub_resource_create_event_hub_consumer_group(self, resource_group): + response = self.client.iot_hub_resource.create_event_hub_consumer_group( + resource_group_name=resource_group.name, + resource_name="str", + event_hub_endpoint_name="str", + name="str", + consumer_group_body={"properties": {"name": "str"}}, + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_hub_resource_delete_event_hub_consumer_group(self, resource_group): + response = self.client.iot_hub_resource.delete_event_hub_consumer_group( + resource_group_name=resource_group.name, + resource_name="str", + event_hub_endpoint_name="str", + name="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_hub_resource_list_jobs(self, resource_group): + response = self.client.iot_hub_resource.list_jobs( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-06-30-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_hub_resource_get_job(self, resource_group): + response = self.client.iot_hub_resource.get_job( + resource_group_name=resource_group.name, + resource_name="str", + job_id="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_hub_resource_get_quota_metrics(self, resource_group): + response = self.client.iot_hub_resource.get_quota_metrics( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-06-30-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_hub_resource_get_endpoint_health(self, resource_group): + response = self.client.iot_hub_resource.get_endpoint_health( + resource_group_name=resource_group.name, + iot_hub_name="str", + api_version="2023-06-30-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_hub_resource_check_name_availability(self, resource_group): + response = self.client.iot_hub_resource.check_name_availability( + operation_inputs={"name": "str"}, + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_hub_resource_test_all_routes(self, resource_group): + response = self.client.iot_hub_resource.test_all_routes( + iot_hub_name="str", + resource_group_name=resource_group.name, + input={ + "message": {"appProperties": {"str": "str"}, "body": "str", "systemProperties": {"str": "str"}}, + "routingSource": "str", + "twin": {"properties": {"desired": {}, "reported": {}}, "tags": {}}, + }, + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_hub_resource_test_route(self, resource_group): + response = self.client.iot_hub_resource.test_route( + iot_hub_name="str", + resource_group_name=resource_group.name, + input={ + "route": { + "endpointNames": ["str"], + "isEnabled": bool, + "name": "str", + "source": "str", + "condition": "str", + }, + "message": {"appProperties": {"str": "str"}, "body": "str", "systemProperties": {"str": "str"}}, + "twin": {"properties": {"desired": {}, "reported": {}}, "tags": {}}, + }, + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_hub_resource_list_keys(self, resource_group): + response = self.client.iot_hub_resource.list_keys( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-06-30-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_hub_resource_get_keys_for_key_name(self, resource_group): + response = self.client.iot_hub_resource.get_keys_for_key_name( + resource_group_name=resource_group.name, + resource_name="str", + key_name="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_hub_resource_export_devices(self, resource_group): + response = self.client.iot_hub_resource.export_devices( + resource_group_name=resource_group.name, + resource_name="str", + export_devices_parameters={ + "excludeKeys": bool, + "exportBlobContainerUri": "str", + "authenticationType": "str", + "configurationsBlobName": "str", + "exportBlobName": "str", + "identity": {"userAssignedIdentity": "str"}, + "includeConfigurations": bool, + }, + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_iot_hub_resource_import_devices(self, resource_group): + response = self.client.iot_hub_resource.import_devices( + resource_group_name=resource_group.name, + resource_name="str", + import_devices_parameters={ + "inputBlobContainerUri": "str", + "outputBlobContainerUri": "str", + "authenticationType": "str", + "configurationsBlobName": "str", + "identity": {"userAssignedIdentity": "str"}, + "includeConfigurations": bool, + "inputBlobName": "str", + "outputBlobName": "str", + }, + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_iot_hub_resource_operations_async.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_iot_hub_resource_operations_async.py new file mode 100644 index 000000000000..9b102520a9dd --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_iot_hub_resource_operations_async.py @@ -0,0 +1,548 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.iothub.aio import IotHubClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestIotHubIotHubResourceOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(IotHubClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_hub_resource_get(self, resource_group): + response = await self.client.iot_hub_resource.get( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_hub_resource_begin_create_or_update(self, resource_group): + response = await ( + await self.client.iot_hub_resource.begin_create_or_update( + resource_group_name=resource_group.name, + resource_name="str", + iot_hub_description={ + "location": "str", + "sku": {"name": "str", "capacity": 0, "tier": "str"}, + "etag": "str", + "id": "str", + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "name": "str", + "properties": { + "allowedFqdnList": ["str"], + "authorizationPolicies": [ + {"keyName": "str", "rights": "str", "primaryKey": "str", "secondaryKey": "str"} + ], + "cloudToDevice": { + "defaultTtlAsIso8601": "1 day, 0:00:00", + "feedback": { + "lockDurationAsIso8601": "1 day, 0:00:00", + "maxDeliveryCount": 0, + "ttlAsIso8601": "1 day, 0:00:00", + }, + "maxDeliveryCount": 0, + }, + "comments": "str", + "deviceStreams": {"streamingEndpoints": ["str"]}, + "disableDeviceSAS": bool, + "disableLocalAuth": bool, + "disableModuleSAS": bool, + "enableDataResidency": bool, + "enableFileUploadNotifications": bool, + "encryption": { + "keySource": "str", + "keyVaultProperties": [ + {"identity": {"userAssignedIdentity": "str"}, "keyIdentifier": "str"} + ], + }, + "eventHubEndpoints": { + "str": { + "endpoint": "str", + "partitionCount": 0, + "partitionIds": ["str"], + "path": "str", + "retentionTimeInDays": 0, + } + }, + "features": "str", + "hostName": "str", + "ipFilterRules": [{"action": "str", "filterName": "str", "ipMask": "str"}], + "ipVersion": "str", + "locations": [{"location": "str", "role": "str"}], + "messagingEndpoints": { + "str": { + "lockDurationAsIso8601": "1 day, 0:00:00", + "maxDeliveryCount": 0, + "ttlAsIso8601": "1 day, 0:00:00", + } + }, + "minTlsVersion": "str", + "networkRuleSets": { + "applyToBuiltInEventHubEndpoint": bool, + "ipRules": [{"filterName": "str", "ipMask": "str", "action": "Allow"}], + "defaultAction": "Deny", + }, + "privateEndpointConnections": [ + { + "properties": { + "privateLinkServiceConnectionState": { + "description": "str", + "status": "str", + "actionsRequired": "str", + }, + "privateEndpoint": {"id": "str"}, + }, + "id": "str", + "name": "str", + "type": "str", + } + ], + "provisioningState": "str", + "publicNetworkAccess": "str", + "restrictOutboundNetworkAccess": bool, + "rootCertificate": { + "enableRootCertificateV2": bool, + "lastUpdatedTimeUtc": "2020-02-20 00:00:00", + }, + "routing": { + "endpoints": { + "cosmosDBSqlContainers": [ + { + "containerName": "str", + "databaseName": "str", + "endpointUri": "str", + "name": "str", + "authenticationType": "str", + "id": "str", + "identity": {"userAssignedIdentity": "str"}, + "partitionKeyName": "str", + "partitionKeyTemplate": "str", + "primaryKey": "str", + "resourceGroup": "str", + "secondaryKey": "str", + "subscriptionId": "str", + } + ], + "eventHubs": [ + { + "name": "str", + "authenticationType": "str", + "connectionString": "str", + "endpointUri": "str", + "entityPath": "str", + "id": "str", + "identity": {"userAssignedIdentity": "str"}, + "resourceGroup": "str", + "subscriptionId": "str", + } + ], + "serviceBusQueues": [ + { + "name": "str", + "authenticationType": "str", + "connectionString": "str", + "endpointUri": "str", + "entityPath": "str", + "id": "str", + "identity": {"userAssignedIdentity": "str"}, + "resourceGroup": "str", + "subscriptionId": "str", + } + ], + "serviceBusTopics": [ + { + "name": "str", + "authenticationType": "str", + "connectionString": "str", + "endpointUri": "str", + "entityPath": "str", + "id": "str", + "identity": {"userAssignedIdentity": "str"}, + "resourceGroup": "str", + "subscriptionId": "str", + } + ], + "storageContainers": [ + { + "containerName": "str", + "name": "str", + "authenticationType": "str", + "batchFrequencyInSeconds": 0, + "connectionString": "str", + "encoding": "str", + "endpointUri": "str", + "fileNameFormat": "str", + "id": "str", + "identity": {"userAssignedIdentity": "str"}, + "maxChunkSizeInBytes": 0, + "resourceGroup": "str", + "subscriptionId": "str", + } + ], + }, + "enrichments": [{"endpointNames": ["str"], "key": "str", "value": "str"}], + "fallbackRoute": { + "endpointNames": ["str"], + "isEnabled": bool, + "source": "str", + "condition": "str", + "name": "str", + }, + "routes": [ + { + "endpointNames": ["str"], + "isEnabled": bool, + "name": "str", + "source": "str", + "condition": "str", + } + ], + }, + "state": "str", + "storageEndpoints": { + "str": { + "connectionString": "str", + "containerName": "str", + "authenticationType": "str", + "identity": {"userAssignedIdentity": "str"}, + "sasTtlAsIso8601": "1 day, 0:00:00", + } + }, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2023-06-30-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_hub_resource_begin_update(self, resource_group): + response = await ( + await self.client.iot_hub_resource.begin_update( + resource_group_name=resource_group.name, + resource_name="str", + iot_hub_tags={"tags": {"str": "str"}}, + api_version="2023-06-30-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_hub_resource_begin_delete(self, resource_group): + response = await ( + await self.client.iot_hub_resource.begin_delete( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-06-30-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_hub_resource_list_by_subscription(self, resource_group): + response = self.client.iot_hub_resource.list_by_subscription( + api_version="2023-06-30-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_hub_resource_list_by_resource_group(self, resource_group): + response = self.client.iot_hub_resource.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2023-06-30-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_hub_resource_get_stats(self, resource_group): + response = await self.client.iot_hub_resource.get_stats( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_hub_resource_get_valid_skus(self, resource_group): + response = self.client.iot_hub_resource.get_valid_skus( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-06-30-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_hub_resource_list_event_hub_consumer_groups(self, resource_group): + response = self.client.iot_hub_resource.list_event_hub_consumer_groups( + resource_group_name=resource_group.name, + resource_name="str", + event_hub_endpoint_name="str", + api_version="2023-06-30-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_hub_resource_get_event_hub_consumer_group(self, resource_group): + response = await self.client.iot_hub_resource.get_event_hub_consumer_group( + resource_group_name=resource_group.name, + resource_name="str", + event_hub_endpoint_name="str", + name="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_hub_resource_create_event_hub_consumer_group(self, resource_group): + response = await self.client.iot_hub_resource.create_event_hub_consumer_group( + resource_group_name=resource_group.name, + resource_name="str", + event_hub_endpoint_name="str", + name="str", + consumer_group_body={"properties": {"name": "str"}}, + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_hub_resource_delete_event_hub_consumer_group(self, resource_group): + response = await self.client.iot_hub_resource.delete_event_hub_consumer_group( + resource_group_name=resource_group.name, + resource_name="str", + event_hub_endpoint_name="str", + name="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_hub_resource_list_jobs(self, resource_group): + response = self.client.iot_hub_resource.list_jobs( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-06-30-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_hub_resource_get_job(self, resource_group): + response = await self.client.iot_hub_resource.get_job( + resource_group_name=resource_group.name, + resource_name="str", + job_id="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_hub_resource_get_quota_metrics(self, resource_group): + response = self.client.iot_hub_resource.get_quota_metrics( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-06-30-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_hub_resource_get_endpoint_health(self, resource_group): + response = self.client.iot_hub_resource.get_endpoint_health( + resource_group_name=resource_group.name, + iot_hub_name="str", + api_version="2023-06-30-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_hub_resource_check_name_availability(self, resource_group): + response = await self.client.iot_hub_resource.check_name_availability( + operation_inputs={"name": "str"}, + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_hub_resource_test_all_routes(self, resource_group): + response = await self.client.iot_hub_resource.test_all_routes( + iot_hub_name="str", + resource_group_name=resource_group.name, + input={ + "message": {"appProperties": {"str": "str"}, "body": "str", "systemProperties": {"str": "str"}}, + "routingSource": "str", + "twin": {"properties": {"desired": {}, "reported": {}}, "tags": {}}, + }, + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_hub_resource_test_route(self, resource_group): + response = await self.client.iot_hub_resource.test_route( + iot_hub_name="str", + resource_group_name=resource_group.name, + input={ + "route": { + "endpointNames": ["str"], + "isEnabled": bool, + "name": "str", + "source": "str", + "condition": "str", + }, + "message": {"appProperties": {"str": "str"}, "body": "str", "systemProperties": {"str": "str"}}, + "twin": {"properties": {"desired": {}, "reported": {}}, "tags": {}}, + }, + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_hub_resource_list_keys(self, resource_group): + response = self.client.iot_hub_resource.list_keys( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-06-30-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_hub_resource_get_keys_for_key_name(self, resource_group): + response = await self.client.iot_hub_resource.get_keys_for_key_name( + resource_group_name=resource_group.name, + resource_name="str", + key_name="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_hub_resource_export_devices(self, resource_group): + response = await self.client.iot_hub_resource.export_devices( + resource_group_name=resource_group.name, + resource_name="str", + export_devices_parameters={ + "excludeKeys": bool, + "exportBlobContainerUri": "str", + "authenticationType": "str", + "configurationsBlobName": "str", + "exportBlobName": "str", + "identity": {"userAssignedIdentity": "str"}, + "includeConfigurations": bool, + }, + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_iot_hub_resource_import_devices(self, resource_group): + response = await self.client.iot_hub_resource.import_devices( + resource_group_name=resource_group.name, + resource_name="str", + import_devices_parameters={ + "inputBlobContainerUri": "str", + "outputBlobContainerUri": "str", + "authenticationType": "str", + "configurationsBlobName": "str", + "identity": {"userAssignedIdentity": "str"}, + "includeConfigurations": bool, + "inputBlobName": "str", + "outputBlobName": "str", + }, + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_operations.py new file mode 100644 index 000000000000..7f5b3ba6b425 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_operations.py @@ -0,0 +1,29 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.iothub import IotHubClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestIotHubOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(IotHubClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_operations_list(self, resource_group): + response = self.client.operations.list( + api_version="2023-06-30-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_operations_async.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_operations_async.py new file mode 100644 index 000000000000..889483d7c2e7 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_operations_async.py @@ -0,0 +1,30 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.iothub.aio import IotHubClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestIotHubOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(IotHubClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_operations_list(self, resource_group): + response = self.client.operations.list( + api_version="2023-06-30-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..29cf0cc9fb1b --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_private_endpoint_connections_operations.py @@ -0,0 +1,83 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.iothub import IotHubClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestIotHubPrivateEndpointConnectionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(IotHubClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_list(self, resource_group): + response = self.client.private_endpoint_connections.list( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_get(self, resource_group): + response = self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + resource_name="str", + private_endpoint_connection_name="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_begin_update(self, resource_group): + response = self.client.private_endpoint_connections.begin_update( + resource_group_name=resource_group.name, + resource_name="str", + private_endpoint_connection_name="str", + private_endpoint_connection={ + "properties": { + "privateLinkServiceConnectionState": { + "description": "str", + "status": "str", + "actionsRequired": "str", + }, + "privateEndpoint": {"id": "str"}, + }, + "id": "str", + "name": "str", + "type": "str", + }, + api_version="2023-06-30-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_begin_delete(self, resource_group): + response = self.client.private_endpoint_connections.begin_delete( + resource_group_name=resource_group.name, + resource_name="str", + private_endpoint_connection_name="str", + api_version="2023-06-30-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_private_endpoint_connections_operations_async.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_private_endpoint_connections_operations_async.py new file mode 100644 index 000000000000..d645161c9fcb --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_private_endpoint_connections_operations_async.py @@ -0,0 +1,88 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.iothub.aio import IotHubClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestIotHubPrivateEndpointConnectionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(IotHubClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_list(self, resource_group): + response = await self.client.private_endpoint_connections.list( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_get(self, resource_group): + response = await self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + resource_name="str", + private_endpoint_connection_name="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_begin_update(self, resource_group): + response = await ( + await self.client.private_endpoint_connections.begin_update( + resource_group_name=resource_group.name, + resource_name="str", + private_endpoint_connection_name="str", + private_endpoint_connection={ + "properties": { + "privateLinkServiceConnectionState": { + "description": "str", + "status": "str", + "actionsRequired": "str", + }, + "privateEndpoint": {"id": "str"}, + }, + "id": "str", + "name": "str", + "type": "str", + }, + api_version="2023-06-30-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_begin_delete(self, resource_group): + response = await ( + await self.client.private_endpoint_connections.begin_delete( + resource_group_name=resource_group.name, + resource_name="str", + private_endpoint_connection_name="str", + api_version="2023-06-30-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_private_link_resources_operations.py new file mode 100644 index 000000000000..a1e44f9fefa9 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_private_link_resources_operations.py @@ -0,0 +1,44 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.iothub import IotHubClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestIotHubPrivateLinkResourcesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(IotHubClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_resources_list(self, resource_group): + response = self.client.private_link_resources.list( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_resources_get(self, resource_group): + response = self.client.private_link_resources.get( + resource_group_name=resource_group.name, + resource_name="str", + group_id="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_private_link_resources_operations_async.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_private_link_resources_operations_async.py new file mode 100644 index 000000000000..99d07cbb0cdd --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_private_link_resources_operations_async.py @@ -0,0 +1,45 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.iothub.aio import IotHubClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestIotHubPrivateLinkResourcesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(IotHubClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_resources_list(self, resource_group): + response = await self.client.private_link_resources.list( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_resources_get(self, resource_group): + response = await self.client.private_link_resources.get( + resource_group_name=resource_group.name, + resource_name="str", + group_id="str", + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_resource_provider_common_operations.py new file mode 100644 index 000000000000..73a9368756e3 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_resource_provider_common_operations.py @@ -0,0 +1,29 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.iothub import IotHubClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestIotHubResourceProviderCommonOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(IotHubClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_resource_provider_common_get_subscription_quota(self, resource_group): + response = self.client.resource_provider_common.get_subscription_quota( + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_resource_provider_common_operations_async.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_resource_provider_common_operations_async.py new file mode 100644 index 000000000000..d8dc6b6cba97 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/generated_tests/test_iot_hub_resource_provider_common_operations_async.py @@ -0,0 +1,30 @@ +# 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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.iothub.aio import IotHubClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestIotHubResourceProviderCommonOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(IotHubClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_resource_provider_common_get_subscription_quota(self, resource_group): + response = await self.client.resource_provider_common.get_subscription_quota( + api_version="2023-06-30-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/models.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/models.py deleted file mode 100644 index a1be3842afe2..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/models.py +++ /dev/null @@ -1,7 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from .v2023_06_30.models import * 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/models/__init__.py similarity index 100% rename from sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/models/__init__.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/models/__init__.py 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/models/_iot_hub_client_enums.py similarity index 100% rename from sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/models/_iot_hub_client_enums.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/models/_iot_hub_client_enums.py 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/models/_models_py3.py similarity index 87% rename from sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/models/_models_py3.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/models/_models_py3.py index ad231136b487..c3b1dfed2363 100644 --- 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/models/_models_py3.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,20 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping 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 +from .._utils import serialization as _serialization if TYPE_CHECKING: from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +JSON = MutableMapping[str, Any] class ArmIdentity(_serialization.Model): @@ -36,10 +31,9 @@ class ArmIdentity(_serialization.Model): 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 + :vartype type: str or ~azure.mgmt.iothub.models.ResourceIdentityType :ivar user_assigned_identities: Dictionary of :code:``. - :vartype user_assigned_identities: dict[str, - ~azure.mgmt.iothub.v2023_06_30_preview.models.ArmUserIdentity] + :vartype user_assigned_identities: dict[str, ~azure.mgmt.iothub.models.ArmUserIdentity] """ _validation = { @@ -66,14 +60,13 @@ def __init__( '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 + :paramtype type: str or ~azure.mgmt.iothub.models.ResourceIdentityType :keyword user_assigned_identities: Dictionary of :code:``. - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.iothub.v2023_06_30_preview.models.ArmUserIdentity] + :paramtype user_assigned_identities: dict[str, ~azure.mgmt.iothub.models.ArmUserIdentity] """ super().__init__(**kwargs) - self.principal_id = None - self.tenant_id = None + self.principal_id: Optional[str] = None + self.tenant_id: Optional[str] = None self.type = type self.user_assigned_identities = user_assigned_identities @@ -102,8 +95,8 @@ class ArmUserIdentity(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.principal_id = None - self.client_id = None + self.principal_id: Optional[str] = None + self.client_id: Optional[str] = None class CertificateBodyDescription(_serialization.Model): @@ -142,7 +135,7 @@ class CertificateDescription(_serialization.Model): 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 + :vartype properties: ~azure.mgmt.iothub.models.CertificateProperties :ivar id: The resource identifier. :vartype id: str :ivar name: The name of the certificate. @@ -171,21 +164,21 @@ class CertificateDescription(_serialization.Model): 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 + :paramtype properties: ~azure.mgmt.iothub.models.CertificateProperties """ super().__init__(**kwargs) self.properties = properties - self.id = None - self.name = None - self.etag = None - self.type = None + self.id: Optional[str] = None + self.name: Optional[str] = None + self.etag: Optional[str] = None + self.type: Optional[str] = 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] + :vartype value: list[~azure.mgmt.iothub.models.CertificateDescription] """ _attribute_map = { @@ -195,7 +188,7 @@ class CertificateListDescription(_serialization.Model): 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] + :paramtype value: list[~azure.mgmt.iothub.models.CertificateDescription] """ super().__init__(**kwargs) self.value = value @@ -248,12 +241,12 @@ def __init__(self, *, is_verified: Optional[bool] = None, certificate: Optional[ :paramtype certificate: str """ super().__init__(**kwargs) - self.subject = None - self.expiry = None - self.thumbprint = None + self.subject: Optional[str] = None + self.expiry: Optional[datetime.datetime] = None + self.thumbprint: Optional[str] = None self.is_verified = is_verified - self.created = None - self.updated = None + self.created: Optional[datetime.datetime] = None + self.updated: Optional[datetime.datetime] = None self.certificate = certificate @@ -307,14 +300,14 @@ class CertificatePropertiesWithNonce(_serialization.Model): 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 + self.subject: Optional[str] = None + self.expiry: Optional[datetime.datetime] = None + self.thumbprint: Optional[str] = None + self.is_verified: Optional[bool] = None + self.created: Optional[datetime.datetime] = None + self.updated: Optional[datetime.datetime] = None + self.verification_code: Optional[str] = None + self.certificate: Optional[str] = None class CertificateVerificationDescription(_serialization.Model): @@ -346,8 +339,7 @@ class CertificateWithNonceDescription(_serialization.Model): :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 + :vartype properties: ~azure.mgmt.iothub.models.CertificatePropertiesWithNonce :ivar id: The resource identifier. :vartype id: str :ivar name: The name of the certificate. @@ -377,15 +369,14 @@ def __init__(self, *, properties: Optional["_models.CertificatePropertiesWithNon """ :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 + :paramtype properties: ~azure.mgmt.iothub.models.CertificatePropertiesWithNonce """ super().__init__(**kwargs) self.properties = properties - self.id = None - self.name = None - self.etag = None - self.type = None + self.id: Optional[str] = None + self.name: Optional[str] = None + self.etag: Optional[str] = None + self.type: Optional[str] = None class CloudToDeviceProperties(_serialization.Model): @@ -400,7 +391,7 @@ class CloudToDeviceProperties(_serialization.Model): 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 + :vartype feedback: ~azure.mgmt.iothub.models.FeedbackProperties """ _validation = { @@ -431,7 +422,7 @@ def __init__( 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 + :paramtype feedback: ~azure.mgmt.iothub.models.FeedbackProperties """ super().__init__(**kwargs) self.max_delivery_count = max_delivery_count @@ -445,8 +436,7 @@ class EncryptionPropertiesDescription(_serialization.Model): :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] + :vartype key_vault_properties: list[~azure.mgmt.iothub.models.KeyVaultKeyProperties] """ _attribute_map = { @@ -465,8 +455,7 @@ def __init__( :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] + :paramtype key_vault_properties: list[~azure.mgmt.iothub.models.KeyVaultKeyProperties] """ super().__init__(**kwargs) self.key_source = key_source @@ -488,8 +477,7 @@ class EndpointHealthData(_serialization.Model): 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 + :vartype health_status: str or ~azure.mgmt.iothub.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. @@ -534,8 +522,7 @@ def __init__( 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 + :paramtype health_status: str or ~azure.mgmt.iothub.models.EndpointHealthStatus :keyword last_known_error: Last error obtained when a message failed to be delivered to iot hub. :paramtype last_known_error: str @@ -562,7 +549,7 @@ class EndpointHealthDataListResult(_serialization.Model): 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] + :vartype value: list[~azure.mgmt.iothub.models.EndpointHealthData] :ivar next_link: Link to more results. :vartype next_link: str """ @@ -579,11 +566,11 @@ class EndpointHealthDataListResult(_serialization.Model): 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] + :paramtype value: list[~azure.mgmt.iothub.models.EndpointHealthData] """ super().__init__(**kwargs) self.value = value - self.next_link = None + self.next_link: Optional[str] = None class EnrichmentProperties(_serialization.Model): @@ -660,10 +647,10 @@ class ErrorDetails(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.code = None - self.http_status_code = None - self.message = None - self.details = None + self.code: Optional[str] = None + self.http_status_code: Optional[str] = None + self.message: Optional[str] = None + self.details: Optional[str] = None class EventHubConsumerGroupBodyDescription(_serialization.Model): @@ -672,7 +659,7 @@ class EventHubConsumerGroupBodyDescription(_serialization.Model): All required parameters must be populated in order to send to server. :ivar properties: The EventHub consumer group name. Required. - :vartype properties: ~azure.mgmt.iothub.v2023_06_30_preview.models.EventHubConsumerGroupName + :vartype properties: ~azure.mgmt.iothub.models.EventHubConsumerGroupName """ _validation = { @@ -686,7 +673,7 @@ class EventHubConsumerGroupBodyDescription(_serialization.Model): 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 + :paramtype properties: ~azure.mgmt.iothub.models.EventHubConsumerGroupName """ super().__init__(**kwargs) self.properties = properties @@ -731,10 +718,10 @@ def __init__(self, *, properties: Optional[Dict[str, Any]] = None, **kwargs: Any """ super().__init__(**kwargs) self.properties = properties - self.id = None - self.name = None - self.type = None - self.etag = None + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None + self.etag: Optional[str] = None class EventHubConsumerGroupName(_serialization.Model): @@ -769,7 +756,7 @@ class EventHubConsumerGroupsListResult(_serialization.Model): 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] + :vartype value: list[~azure.mgmt.iothub.models.EventHubConsumerGroupInfo] :ivar next_link: The next link. :vartype next_link: str """ @@ -786,11 +773,11 @@ class EventHubConsumerGroupsListResult(_serialization.Model): 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] + :paramtype value: list[~azure.mgmt.iothub.models.EventHubConsumerGroupInfo] """ super().__init__(**kwargs) self.value = value - self.next_link = None + self.next_link: Optional[str] = None class EventHubProperties(_serialization.Model): @@ -842,9 +829,9 @@ def __init__( 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 + self.partition_ids: Optional[List[str]] = None + self.path: Optional[str] = None + self.endpoint: Optional[str] = None class ExportDevicesRequest(_serialization.Model): @@ -862,10 +849,9 @@ class ExportDevicesRequest(_serialization.Model): :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 + :vartype authentication_type: str or ~azure.mgmt.iothub.models.AuthenticationType :ivar identity: Managed identity properties of storage endpoint for export devices. - :vartype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :vartype identity: ~azure.mgmt.iothub.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 @@ -912,10 +898,9 @@ def __init__( :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 + :paramtype authentication_type: str or ~azure.mgmt.iothub.models.AuthenticationType :keyword identity: Managed identity properties of storage endpoint for export devices. - :paramtype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :paramtype identity: ~azure.mgmt.iothub.models.ManagedIdentity :keyword include_configurations: The value indicating whether configurations should be exported. :paramtype include_configurations: bool @@ -972,7 +957,7 @@ class FallbackRouteProperties(_serialization.Model): 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 + :vartype source: str or ~azure.mgmt.iothub.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. @@ -1016,7 +1001,7 @@ def __init__( 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 + :paramtype source: str or ~azure.mgmt.iothub.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. @@ -1102,7 +1087,7 @@ class GroupIdInformation(_serialization.Model): :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 + :vartype properties: ~azure.mgmt.iothub.models.GroupIdInformationProperties """ _validation = { @@ -1122,13 +1107,12 @@ class GroupIdInformation(_serialization.Model): 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 + :paramtype properties: ~azure.mgmt.iothub.models.GroupIdInformationProperties """ super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None self.properties = properties @@ -1187,10 +1171,9 @@ class ImportDevicesRequest(_serialization.Model): :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 + :vartype authentication_type: str or ~azure.mgmt.iothub.models.AuthenticationType :ivar identity: Managed identity properties of storage endpoint for import devices. - :vartype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :vartype identity: ~azure.mgmt.iothub.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 @@ -1239,10 +1222,9 @@ def __init__( :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 + :paramtype authentication_type: str or ~azure.mgmt.iothub.models.AuthenticationType :keyword identity: Managed identity properties of storage endpoint for import devices. - :paramtype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :paramtype identity: ~azure.mgmt.iothub.models.ManagedIdentity :keyword include_configurations: The value indicating whether configurations should be imported. :paramtype include_configurations: bool @@ -1274,7 +1256,7 @@ class IotHubCapacity(_serialization.Model): :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 + :vartype scale_type: str or ~azure.mgmt.iothub.models.IotHubScaleType """ _validation = { @@ -1294,10 +1276,10 @@ class IotHubCapacity(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.minimum = None - self.maximum = None - self.default = None - self.scale_type = None + self.minimum: Optional[int] = None + self.maximum: Optional[int] = None + self.default: Optional[int] = None + self.scale_type: Optional[Union[str, "_models.IotHubScaleType"]] = None class Resource(_serialization.Model): @@ -1342,9 +1324,9 @@ def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kw :paramtype tags: dict[str, str] """ super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None self.location = location self.tags = tags @@ -1370,13 +1352,13 @@ class IotHubDescription(Resource): 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 + :vartype properties: ~azure.mgmt.iothub.models.IotHubProperties :ivar sku: IotHub SKU info. Required. - :vartype sku: ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubSkuInfo + :vartype sku: ~azure.mgmt.iothub.models.IotHubSkuInfo :ivar identity: The managed identities for the IotHub. - :vartype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ArmIdentity + :vartype identity: ~azure.mgmt.iothub.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 + :vartype system_data: ~azure.mgmt.iothub.models.SystemData """ _validation = { @@ -1421,18 +1403,18 @@ def __init__( 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 + :paramtype properties: ~azure.mgmt.iothub.models.IotHubProperties :keyword sku: IotHub SKU info. Required. - :paramtype sku: ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubSkuInfo + :paramtype sku: ~azure.mgmt.iothub.models.IotHubSkuInfo :keyword identity: The managed identities for the IotHub. - :paramtype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ArmIdentity + :paramtype identity: ~azure.mgmt.iothub.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 + self.system_data: Optional["_models.SystemData"] = None class IotHubDescriptionListResult(_serialization.Model): @@ -1441,7 +1423,7 @@ class IotHubDescriptionListResult(_serialization.Model): 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] + :vartype value: list[~azure.mgmt.iothub.models.IotHubDescription] :ivar next_link: The next link. :vartype next_link: str """ @@ -1458,11 +1440,11 @@ class IotHubDescriptionListResult(_serialization.Model): 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] + :paramtype value: list[~azure.mgmt.iothub.models.IotHubDescription] """ super().__init__(**kwargs) self.value = value - self.next_link = None + self.next_link: Optional[str] = None class IotHubLocationDescription(_serialization.Model): @@ -1474,7 +1456,7 @@ class IotHubLocationDescription(_serialization.Model): 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 + :vartype role: str or ~azure.mgmt.iothub.models.IotHubReplicaRoleType """ _attribute_map = { @@ -1496,7 +1478,7 @@ def __init__( 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 + :paramtype role: str or ~azure.mgmt.iothub.models.IotHubReplicaRoleType """ super().__init__(**kwargs) self.location = location @@ -1511,8 +1493,7 @@ class IotHubNameAvailabilityInfo(_serialization.Model): :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 + :vartype reason: str or ~azure.mgmt.iothub.models.IotHubNameUnavailabilityReason :ivar message: The detailed reason message. :vartype message: str """ @@ -1534,8 +1515,8 @@ def __init__(self, *, message: Optional[str] = None, **kwargs: Any) -> None: :paramtype message: str """ super().__init__(**kwargs) - self.name_available = None - self.reason = None + self.name_available: Optional[bool] = None + self.reason: Optional[Union[str, "_models.IotHubNameUnavailabilityReason"]] = None self.message = message @@ -1547,7 +1528,7 @@ class IotHubProperties(_serialization.Model): :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] + list[~azure.mgmt.iothub.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 @@ -1565,19 +1546,17 @@ class IotHubProperties(_serialization.Model): :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 + :vartype public_network_access: str or ~azure.mgmt.iothub.models.PublicNetworkAccess :ivar ip_filter_rules: The IP filter rules. - :vartype ip_filter_rules: list[~azure.mgmt.iothub.v2023_06_30_preview.models.IpFilterRule] + :vartype ip_filter_rules: list[~azure.mgmt.iothub.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 + :vartype network_rule_sets: ~azure.mgmt.iothub.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] + list[~azure.mgmt.iothub.models.PrivateEndpointConnection] :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str :ivar state: The hub state. @@ -1587,49 +1566,42 @@ class IotHubProperties(_serialization.Model): :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] + :vartype event_hub_endpoints: dict[str, ~azure.mgmt.iothub.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 + :vartype routing: ~azure.mgmt.iothub.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] + :vartype storage_endpoints: dict[str, ~azure.mgmt.iothub.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] + :vartype messaging_endpoints: dict[str, ~azure.mgmt.iothub.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 + :vartype cloud_to_device: ~azure.mgmt.iothub.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 + :vartype device_streams: ~azure.mgmt.iothub.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 + :vartype features: str or ~azure.mgmt.iothub.models.Capabilities :ivar encryption: The encryption properties for the IoT hub. - :vartype encryption: - ~azure.mgmt.iothub.v2023_06_30_preview.models.EncryptionPropertiesDescription + :vartype encryption: ~azure.mgmt.iothub.models.EncryptionPropertiesDescription :ivar locations: Primary and secondary location for iot hub. - :vartype locations: - list[~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubLocationDescription] + :vartype locations: list[~azure.mgmt.iothub.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 + :vartype root_certificate: ~azure.mgmt.iothub.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 + :vartype ip_version: str or ~azure.mgmt.iothub.models.IpVersion """ _validation = { @@ -1703,7 +1675,7 @@ def __init__( # pylint: disable=too-many-locals :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] + list[~azure.mgmt.iothub.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 @@ -1721,63 +1693,55 @@ def __init__( # pylint: disable=too-many-locals :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 + :paramtype public_network_access: str or ~azure.mgmt.iothub.models.PublicNetworkAccess :keyword ip_filter_rules: The IP filter rules. - :paramtype ip_filter_rules: list[~azure.mgmt.iothub.v2023_06_30_preview.models.IpFilterRule] + :paramtype ip_filter_rules: list[~azure.mgmt.iothub.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 + :paramtype network_rule_sets: ~azure.mgmt.iothub.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] + list[~azure.mgmt.iothub.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] + :paramtype event_hub_endpoints: dict[str, ~azure.mgmt.iothub.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 + :paramtype routing: ~azure.mgmt.iothub.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] + :paramtype storage_endpoints: dict[str, ~azure.mgmt.iothub.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] + ~azure.mgmt.iothub.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 + :paramtype cloud_to_device: ~azure.mgmt.iothub.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 + :paramtype device_streams: ~azure.mgmt.iothub.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 + :paramtype features: str or ~azure.mgmt.iothub.models.Capabilities :keyword encryption: The encryption properties for the IoT hub. - :paramtype encryption: - ~azure.mgmt.iothub.v2023_06_30_preview.models.EncryptionPropertiesDescription + :paramtype encryption: ~azure.mgmt.iothub.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 + :paramtype root_certificate: ~azure.mgmt.iothub.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 + :paramtype ip_version: str or ~azure.mgmt.iothub.models.IpVersion """ super().__init__(**kwargs) self.authorization_policies = authorization_policies @@ -1791,9 +1755,9 @@ def __init__( # pylint: disable=too-many-locals 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.provisioning_state: Optional[str] = None + self.state: Optional[str] = None + self.host_name: Optional[str] = None self.event_hub_endpoints = event_hub_endpoints self.routing = routing self.storage_endpoints = storage_endpoints @@ -1804,7 +1768,7 @@ def __init__( # pylint: disable=too-many-locals self.device_streams = device_streams self.features = features self.encryption = encryption - self.locations = None + self.locations: Optional[List["_models.IotHubLocationDescription"]] = None self.enable_data_residency = enable_data_residency self.root_certificate = root_certificate self.ip_version = ip_version @@ -1858,9 +1822,9 @@ class IotHubQuotaMetricInfo(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.name = None - self.current_value = None - self.max_value = None + self.name: Optional[str] = None + self.current_value: Optional[int] = None + self.max_value: Optional[int] = None class IotHubQuotaMetricInfoListResult(_serialization.Model): @@ -1869,7 +1833,7 @@ class IotHubQuotaMetricInfoListResult(_serialization.Model): 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] + :vartype value: list[~azure.mgmt.iothub.models.IotHubQuotaMetricInfo] :ivar next_link: The next link. :vartype next_link: str """ @@ -1886,11 +1850,11 @@ class IotHubQuotaMetricInfoListResult(_serialization.Model): 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] + :paramtype value: list[~azure.mgmt.iothub.models.IotHubQuotaMetricInfo] """ super().__init__(**kwargs) self.value = value - self.next_link = None + self.next_link: Optional[str] = None class IotHubSkuDescription(_serialization.Model): @@ -1903,9 +1867,9 @@ class IotHubSkuDescription(_serialization.Model): :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 + :vartype sku: ~azure.mgmt.iothub.models.IotHubSkuInfo :ivar capacity: IotHub capacity. Required. - :vartype capacity: ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubCapacity + :vartype capacity: ~azure.mgmt.iothub.models.IotHubCapacity """ _validation = { @@ -1923,12 +1887,12 @@ class IotHubSkuDescription(_serialization.Model): 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 + :paramtype sku: ~azure.mgmt.iothub.models.IotHubSkuInfo :keyword capacity: IotHub capacity. Required. - :paramtype capacity: ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubCapacity + :paramtype capacity: ~azure.mgmt.iothub.models.IotHubCapacity """ super().__init__(**kwargs) - self.resource_type = None + self.resource_type: Optional[str] = None self.sku = sku self.capacity = capacity @@ -1939,7 +1903,7 @@ class IotHubSkuDescriptionListResult(_serialization.Model): 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] + :vartype value: list[~azure.mgmt.iothub.models.IotHubSkuDescription] :ivar next_link: The next link. :vartype next_link: str """ @@ -1956,11 +1920,11 @@ class IotHubSkuDescriptionListResult(_serialization.Model): 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] + :paramtype value: list[~azure.mgmt.iothub.models.IotHubSkuDescription] """ super().__init__(**kwargs) self.value = value - self.next_link = None + self.next_link: Optional[str] = None class IotHubSkuInfo(_serialization.Model): @@ -1972,10 +1936,10 @@ class IotHubSkuInfo(_serialization.Model): :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 + :vartype name: str or ~azure.mgmt.iothub.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 + :vartype tier: str or ~azure.mgmt.iothub.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 @@ -1996,14 +1960,14 @@ def __init__(self, *, name: Union[str, "_models.IotHubSku"], capacity: Optional[ """ :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 + :paramtype name: str or ~azure.mgmt.iothub.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.tier: Optional[Union[str, "_models.IotHubSkuTier"]] = None self.capacity = capacity @@ -2016,7 +1980,7 @@ class IpFilterRule(_serialization.Model): :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 + :vartype action: str or ~azure.mgmt.iothub.models.IpFilterActionType :ivar ip_mask: A string that contains the IP address range in CIDR notation for the rule. Required. :vartype ip_mask: str @@ -2042,7 +2006,7 @@ def __init__( :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 + :paramtype action: str or ~azure.mgmt.iothub.models.IpFilterActionType :keyword ip_mask: A string that contains the IP address range in CIDR notation for the rule. Required. :paramtype ip_mask: str @@ -2067,10 +2031,10 @@ class JobResponse(_serialization.Model): :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 + :vartype type: str or ~azure.mgmt.iothub.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 + :vartype status: str or ~azure.mgmt.iothub.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. @@ -2104,14 +2068,14 @@ class JobResponse(_serialization.Model): 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 + self.job_id: Optional[str] = None + self.start_time_utc: Optional[datetime.datetime] = None + self.end_time_utc: Optional[datetime.datetime] = None + self.type: Optional[Union[str, "_models.JobType"]] = None + self.status: Optional[Union[str, "_models.JobStatus"]] = None + self.failure_reason: Optional[str] = None + self.status_message: Optional[str] = None + self.parent_job_id: Optional[str] = None class JobResponseListResult(_serialization.Model): @@ -2120,7 +2084,7 @@ class JobResponseListResult(_serialization.Model): 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] + :vartype value: list[~azure.mgmt.iothub.models.JobResponse] :ivar next_link: The next link. :vartype next_link: str """ @@ -2137,11 +2101,11 @@ class JobResponseListResult(_serialization.Model): 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] + :paramtype value: list[~azure.mgmt.iothub.models.JobResponse] """ super().__init__(**kwargs) self.value = value - self.next_link = None + self.next_link: Optional[str] = None class KeyVaultKeyProperties(_serialization.Model): @@ -2150,7 +2114,7 @@ class KeyVaultKeyProperties(_serialization.Model): :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 + :vartype identity: ~azure.mgmt.iothub.models.ManagedIdentity """ _attribute_map = { @@ -2169,7 +2133,7 @@ def __init__( :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 + :paramtype identity: ~azure.mgmt.iothub.models.ManagedIdentity """ super().__init__(**kwargs) self.key_identifier = key_identifier @@ -2200,7 +2164,7 @@ 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 + :vartype properties: ~azure.mgmt.iothub.models.RouteProperties """ _attribute_map = { @@ -2210,7 +2174,7 @@ class MatchedRoute(_serialization.Model): 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 + :paramtype properties: ~azure.mgmt.iothub.models.RouteProperties """ super().__init__(**kwargs) self.properties = properties @@ -2301,7 +2265,7 @@ class NetworkRuleSetIpRule(_serialization.Model): :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 + :vartype action: str or ~azure.mgmt.iothub.models.NetworkRuleIPAction :ivar ip_mask: A string that contains the IP address range in CIDR notation for the rule. Required. :vartype ip_mask: str @@ -2330,7 +2294,7 @@ def __init__( :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 + :paramtype action: str or ~azure.mgmt.iothub.models.NetworkRuleIPAction :keyword ip_mask: A string that contains the IP address range in CIDR notation for the rule. Required. :paramtype ip_mask: str @@ -2348,12 +2312,12 @@ class NetworkRuleSetProperties(_serialization.Model): :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 + :vartype default_action: str or ~azure.mgmt.iothub.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] + :vartype ip_rules: list[~azure.mgmt.iothub.models.NetworkRuleSetIpRule] """ _validation = { @@ -2378,12 +2342,12 @@ def __init__( """ :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 + :paramtype default_action: str or ~azure.mgmt.iothub.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] + :paramtype ip_rules: list[~azure.mgmt.iothub.models.NetworkRuleSetIpRule] """ super().__init__(**kwargs) self.default_action = default_action @@ -2399,7 +2363,7 @@ class Operation(_serialization.Model): :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 + :vartype display: ~azure.mgmt.iothub.models.OperationDisplay """ _validation = { @@ -2414,10 +2378,10 @@ class Operation(_serialization.Model): 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 + :paramtype display: ~azure.mgmt.iothub.models.OperationDisplay """ super().__init__(**kwargs) - self.name = None + self.name: Optional[str] = None self.display = display @@ -2453,10 +2417,10 @@ class OperationDisplay(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None + self.provider: Optional[str] = None + self.resource: Optional[str] = None + self.operation: Optional[str] = None + self.description: Optional[str] = None class OperationInputs(_serialization.Model): @@ -2492,7 +2456,7 @@ class OperationListResult(_serialization.Model): 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] + :vartype value: list[~azure.mgmt.iothub.models.Operation] :ivar next_link: URL to get the next set of operation list results if there are any. :vartype next_link: str """ @@ -2510,8 +2474,8 @@ class OperationListResult(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.value = None - self.next_link = None + self.value: Optional[List["_models.Operation"]] = None + self.next_link: Optional[str] = None class PrivateEndpoint(_serialization.Model): @@ -2534,7 +2498,7 @@ class PrivateEndpoint(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.id = None + self.id: Optional[str] = None class PrivateEndpointConnection(_serialization.Model): @@ -2551,8 +2515,7 @@ class PrivateEndpointConnection(_serialization.Model): :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 + :vartype properties: ~azure.mgmt.iothub.models.PrivateEndpointConnectionProperties """ _validation = { @@ -2572,13 +2535,12 @@ class PrivateEndpointConnection(_serialization.Model): 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 + :paramtype properties: ~azure.mgmt.iothub.models.PrivateEndpointConnectionProperties """ super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None self.properties = properties @@ -2588,11 +2550,11 @@ class PrivateEndpointConnectionProperties(_serialization.Model): All required parameters must be populated in order to send to server. :ivar private_endpoint: The private endpoint property of a private endpoint connection. - :vartype private_endpoint: ~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateEndpoint + :vartype private_endpoint: ~azure.mgmt.iothub.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 + ~azure.mgmt.iothub.models.PrivateLinkServiceConnectionState """ _validation = { @@ -2616,11 +2578,11 @@ def __init__( ) -> 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 + :paramtype private_endpoint: ~azure.mgmt.iothub.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 + ~azure.mgmt.iothub.models.PrivateLinkServiceConnectionState """ super().__init__(**kwargs) self.private_endpoint = private_endpoint @@ -2631,7 +2593,7 @@ 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] + :vartype value: list[~azure.mgmt.iothub.models.GroupIdInformation] """ _attribute_map = { @@ -2641,7 +2603,7 @@ class PrivateLinkResources(_serialization.Model): 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] + :paramtype value: list[~azure.mgmt.iothub.models.GroupIdInformation] """ super().__init__(**kwargs) self.value = value @@ -2654,8 +2616,7 @@ class PrivateLinkServiceConnectionState(_serialization.Model): :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 + :vartype status: str or ~azure.mgmt.iothub.models.PrivateLinkServiceConnectionStatus :ivar description: The description for the current state of a private endpoint connection. Required. :vartype description: str @@ -2685,8 +2646,7 @@ def __init__( """ :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 + :paramtype status: str or ~azure.mgmt.iothub.models.PrivateLinkServiceConnectionStatus :keyword description: The description for the current state of a private endpoint connection. Required. :paramtype description: str @@ -2727,9 +2687,9 @@ class RegistryStatistics(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.total_device_count = None - self.enabled_device_count = None - self.disabled_device_count = None + self.total_device_count: Optional[int] = None + self.enabled_device_count: Optional[int] = None + self.disabled_device_count: Optional[int] = None class RootCertificateProperties(_serialization.Model): @@ -2761,7 +2721,7 @@ def __init__(self, *, enable_root_certificate_v2: Optional[bool] = None, **kwarg """ super().__init__(**kwargs) self.enable_root_certificate_v2 = enable_root_certificate_v2 - self.last_updated_time_utc = None + self.last_updated_time_utc: Optional[datetime.datetime] = None class RouteCompilationError(_serialization.Model): @@ -2770,9 +2730,9 @@ class RouteCompilationError(_serialization.Model): :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 + :vartype severity: str or ~azure.mgmt.iothub.models.RouteErrorSeverity :ivar location: Location where the route error happened. - :vartype location: ~azure.mgmt.iothub.v2023_06_30_preview.models.RouteErrorRange + :vartype location: ~azure.mgmt.iothub.models.RouteErrorRange """ _attribute_map = { @@ -2793,9 +2753,9 @@ def __init__( :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 + :paramtype severity: str or ~azure.mgmt.iothub.models.RouteErrorSeverity :keyword location: Location where the route error happened. - :paramtype location: ~azure.mgmt.iothub.v2023_06_30_preview.models.RouteErrorRange + :paramtype location: ~azure.mgmt.iothub.models.RouteErrorRange """ super().__init__(**kwargs) self.message = message @@ -2833,9 +2793,9 @@ 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 + :vartype start: ~azure.mgmt.iothub.models.RouteErrorPosition :ivar end: End where the route error happened. - :vartype end: ~azure.mgmt.iothub.v2023_06_30_preview.models.RouteErrorPosition + :vartype end: ~azure.mgmt.iothub.models.RouteErrorPosition """ _attribute_map = { @@ -2852,9 +2812,9 @@ def __init__( ) -> None: """ :keyword start: Start where the route error happened. - :paramtype start: ~azure.mgmt.iothub.v2023_06_30_preview.models.RouteErrorPosition + :paramtype start: ~azure.mgmt.iothub.models.RouteErrorPosition :keyword end: End where the route error happened. - :paramtype end: ~azure.mgmt.iothub.v2023_06_30_preview.models.RouteErrorPosition + :paramtype end: ~azure.mgmt.iothub.models.RouteErrorPosition """ super().__init__(**kwargs) self.start = start @@ -2873,7 +2833,7 @@ class RouteProperties(_serialization.Model): 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 + :vartype source: str or ~azure.mgmt.iothub.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. @@ -2919,7 +2879,7 @@ def __init__( 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 + :paramtype source: str or ~azure.mgmt.iothub.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. @@ -2959,10 +2919,9 @@ class RoutingCosmosDBSqlApiProperties(_serialization.Model): :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 + :vartype authentication_type: str or ~azure.mgmt.iothub.models.AuthenticationType :ivar identity: Managed identity properties of routing cosmos DB container endpoint. - :vartype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :vartype identity: ~azure.mgmt.iothub.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. @@ -3041,10 +3000,9 @@ def __init__( :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 + :paramtype authentication_type: str or ~azure.mgmt.iothub.models.AuthenticationType :keyword identity: Managed identity properties of routing cosmos DB container endpoint. - :paramtype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :paramtype identity: ~azure.mgmt.iothub.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. @@ -3088,23 +3046,21 @@ class RoutingEndpoints(_serialization.Model): :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] + list[~azure.mgmt.iothub.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] + list[~azure.mgmt.iothub.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] + :vartype event_hubs: list[~azure.mgmt.iothub.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] + :vartype storage_containers: list[~azure.mgmt.iothub.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] + list[~azure.mgmt.iothub.models.RoutingCosmosDBSqlApiProperties] """ _attribute_map = { @@ -3129,23 +3085,22 @@ def __init__( :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] + list[~azure.mgmt.iothub.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] + list[~azure.mgmt.iothub.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] + :paramtype event_hubs: list[~azure.mgmt.iothub.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] + list[~azure.mgmt.iothub.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] + list[~azure.mgmt.iothub.models.RoutingCosmosDBSqlApiProperties] """ super().__init__(**kwargs) self.service_bus_queues = service_bus_queues @@ -3170,10 +3125,9 @@ class RoutingEventHubProperties(_serialization.Model): :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 + :vartype authentication_type: str or ~azure.mgmt.iothub.models.AuthenticationType :ivar identity: Managed identity properties of routing event hub endpoint. - :vartype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :vartype identity: ~azure.mgmt.iothub.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 @@ -3226,10 +3180,9 @@ def __init__( :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 + :paramtype authentication_type: str or ~azure.mgmt.iothub.models.AuthenticationType :keyword identity: Managed identity properties of routing event hub endpoint. - :paramtype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :paramtype identity: ~azure.mgmt.iothub.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 @@ -3299,19 +3252,19 @@ class RoutingProperties(_serialization.Model): 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 + :vartype endpoints: ~azure.mgmt.iothub.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] + :vartype routes: list[~azure.mgmt.iothub.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 + :vartype fallback_route: ~azure.mgmt.iothub.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] + :vartype enrichments: list[~azure.mgmt.iothub.models.EnrichmentProperties] """ _attribute_map = { @@ -3335,22 +3288,20 @@ def __init__( 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 + :paramtype endpoints: ~azure.mgmt.iothub.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] + :paramtype routes: list[~azure.mgmt.iothub.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 + :paramtype fallback_route: ~azure.mgmt.iothub.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] + :paramtype enrichments: list[~azure.mgmt.iothub.models.EnrichmentProperties] """ super().__init__(**kwargs) self.endpoints = endpoints @@ -3375,10 +3326,9 @@ class RoutingServiceBusQueueEndpointProperties(_serialization.Model): :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 + :vartype authentication_type: str or ~azure.mgmt.iothub.models.AuthenticationType :ivar identity: Managed identity properties of routing service bus queue endpoint. - :vartype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :vartype identity: ~azure.mgmt.iothub.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 @@ -3432,10 +3382,9 @@ def __init__( :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 + :paramtype authentication_type: str or ~azure.mgmt.iothub.models.AuthenticationType :keyword identity: Managed identity properties of routing service bus queue endpoint. - :paramtype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :paramtype identity: ~azure.mgmt.iothub.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 @@ -3474,10 +3423,9 @@ class RoutingServiceBusTopicEndpointProperties(_serialization.Model): :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 + :vartype authentication_type: str or ~azure.mgmt.iothub.models.AuthenticationType :ivar identity: Managed identity properties of routing service bus topic endpoint. - :vartype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :vartype identity: ~azure.mgmt.iothub.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 @@ -3532,10 +3480,9 @@ def __init__( :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 + :paramtype authentication_type: str or ~azure.mgmt.iothub.models.AuthenticationType :keyword identity: Managed identity properties of routing service bus topic endpoint. - :paramtype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :paramtype identity: ~azure.mgmt.iothub.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 @@ -3572,10 +3519,9 @@ class RoutingStorageContainerProperties(_serialization.Model): :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 + :vartype authentication_type: str or ~azure.mgmt.iothub.models.AuthenticationType :ivar identity: Managed identity properties of routing storage endpoint. - :vartype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :vartype identity: ~azure.mgmt.iothub.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 @@ -3600,8 +3546,7 @@ class RoutingStorageContainerProperties(_serialization.Model): :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 + :vartype encoding: str or ~azure.mgmt.iothub.models.RoutingStorageContainerPropertiesEncoding """ _validation = { @@ -3654,10 +3599,9 @@ def __init__( :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 + :paramtype authentication_type: str or ~azure.mgmt.iothub.models.AuthenticationType :keyword identity: Managed identity properties of routing storage endpoint. - :paramtype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :paramtype identity: ~azure.mgmt.iothub.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 @@ -3682,8 +3626,7 @@ def __init__( :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 + :paramtype encoding: str or ~azure.mgmt.iothub.models.RoutingStorageContainerPropertiesEncoding """ super().__init__(**kwargs) self.id = id @@ -3707,7 +3650,7 @@ class RoutingTwin(_serialization.Model): :ivar tags: Twin Tags. :vartype tags: JSON :ivar properties: - :vartype properties: ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingTwinProperties + :vartype properties: ~azure.mgmt.iothub.models.RoutingTwinProperties """ _attribute_map = { @@ -3726,7 +3669,7 @@ def __init__( :keyword tags: Twin Tags. :paramtype tags: JSON :keyword properties: - :paramtype properties: ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingTwinProperties + :paramtype properties: ~azure.mgmt.iothub.models.RoutingTwinProperties """ super().__init__(**kwargs) self.tags = tags @@ -3777,7 +3720,7 @@ class SharedAccessSignatureAuthorizationRule(_serialization.Model): "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 + :vartype rights: str or ~azure.mgmt.iothub.models.AccessRights """ _validation = { @@ -3815,7 +3758,7 @@ def __init__( "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 + :paramtype rights: str or ~azure.mgmt.iothub.models.AccessRights """ super().__init__(**kwargs) self.key_name = key_name @@ -3830,8 +3773,7 @@ class SharedAccessSignatureAuthorizationRuleListResult(_serialization.Model): # 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] + :vartype value: list[~azure.mgmt.iothub.models.SharedAccessSignatureAuthorizationRule] :ivar next_link: The next link. :vartype next_link: str """ @@ -3850,12 +3792,11 @@ def __init__( ) -> None: """ :keyword value: The list of shared access policies. - :paramtype value: - list[~azure.mgmt.iothub.v2023_06_30_preview.models.SharedAccessSignatureAuthorizationRule] + :paramtype value: list[~azure.mgmt.iothub.models.SharedAccessSignatureAuthorizationRule] """ super().__init__(**kwargs) self.value = value - self.next_link = None + self.next_link: Optional[str] = None class StorageEndpointProperties(_serialization.Model): @@ -3865,7 +3806,7 @@ class StorageEndpointProperties(_serialization.Model): :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. # pylint: disable=line-too-long + 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. @@ -3875,10 +3816,9 @@ class StorageEndpointProperties(_serialization.Model): :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 + :vartype authentication_type: str or ~azure.mgmt.iothub.models.AuthenticationType :ivar identity: Managed identity properties of storage endpoint for file upload. - :vartype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :vartype identity: ~azure.mgmt.iothub.models.ManagedIdentity """ _validation = { @@ -3907,7 +3847,7 @@ def __init__( """ :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. # pylint: disable=line-too-long + 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. @@ -3917,10 +3857,9 @@ def __init__( :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 + :paramtype authentication_type: str or ~azure.mgmt.iothub.models.AuthenticationType :keyword identity: Managed identity properties of storage endpoint for file upload. - :paramtype identity: ~azure.mgmt.iothub.v2023_06_30_preview.models.ManagedIdentity + :paramtype identity: ~azure.mgmt.iothub.models.ManagedIdentity """ super().__init__(**kwargs) self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 @@ -3937,15 +3876,14 @@ class SystemData(_serialization.Model): :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 + :vartype created_by_type: str or ~azure.mgmt.iothub.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 + :vartype last_modified_by_type: str or ~azure.mgmt.iothub.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). :vartype last_modified_at: ~datetime.datetime """ @@ -3975,15 +3913,14 @@ def __init__( :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 + :paramtype created_by_type: str or ~azure.mgmt.iothub.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 + :paramtype last_modified_by_type: str or ~azure.mgmt.iothub.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ @@ -4023,11 +3960,11 @@ class TestAllRoutesInput(_serialization.Model): :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 + :vartype routing_source: str or ~azure.mgmt.iothub.models.RoutingSource :ivar message: Routing message. - :vartype message: ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingMessage + :vartype message: ~azure.mgmt.iothub.models.RoutingMessage :ivar twin: Routing Twin Reference. - :vartype twin: ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingTwin + :vartype twin: ~azure.mgmt.iothub.models.RoutingTwin """ _attribute_map = { @@ -4048,11 +3985,11 @@ def __init__( :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 + :paramtype routing_source: str or ~azure.mgmt.iothub.models.RoutingSource :keyword message: Routing message. - :paramtype message: ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingMessage + :paramtype message: ~azure.mgmt.iothub.models.RoutingMessage :keyword twin: Routing Twin Reference. - :paramtype twin: ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingTwin + :paramtype twin: ~azure.mgmt.iothub.models.RoutingTwin """ super().__init__(**kwargs) self.routing_source = routing_source @@ -4064,7 +4001,7 @@ 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] + :vartype routes: list[~azure.mgmt.iothub.models.MatchedRoute] """ _attribute_map = { @@ -4074,7 +4011,7 @@ class TestAllRoutesResult(_serialization.Model): 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] + :paramtype routes: list[~azure.mgmt.iothub.models.MatchedRoute] """ super().__init__(**kwargs) self.routes = routes @@ -4086,11 +4023,11 @@ class TestRouteInput(_serialization.Model): All required parameters must be populated in order to send to server. :ivar message: Routing message. - :vartype message: ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingMessage + :vartype message: ~azure.mgmt.iothub.models.RoutingMessage :ivar route: Route properties. Required. - :vartype route: ~azure.mgmt.iothub.v2023_06_30_preview.models.RouteProperties + :vartype route: ~azure.mgmt.iothub.models.RouteProperties :ivar twin: Routing Twin Reference. - :vartype twin: ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingTwin + :vartype twin: ~azure.mgmt.iothub.models.RoutingTwin """ _validation = { @@ -4113,11 +4050,11 @@ def __init__( ) -> None: """ :keyword message: Routing message. - :paramtype message: ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingMessage + :paramtype message: ~azure.mgmt.iothub.models.RoutingMessage :keyword route: Route properties. Required. - :paramtype route: ~azure.mgmt.iothub.v2023_06_30_preview.models.RouteProperties + :paramtype route: ~azure.mgmt.iothub.models.RouteProperties :keyword twin: Routing Twin Reference. - :paramtype twin: ~azure.mgmt.iothub.v2023_06_30_preview.models.RoutingTwin + :paramtype twin: ~azure.mgmt.iothub.models.RoutingTwin """ super().__init__(**kwargs) self.message = message @@ -4129,9 +4066,9 @@ 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 + :vartype result: str or ~azure.mgmt.iothub.models.TestResultStatus :ivar details: Detailed result of testing route. - :vartype details: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestRouteResultDetails + :vartype details: ~azure.mgmt.iothub.models.TestRouteResultDetails """ _attribute_map = { @@ -4148,9 +4085,9 @@ def __init__( ) -> 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 + :paramtype result: str or ~azure.mgmt.iothub.models.TestResultStatus :keyword details: Detailed result of testing route. - :paramtype details: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestRouteResultDetails + :paramtype details: ~azure.mgmt.iothub.models.TestRouteResultDetails """ super().__init__(**kwargs) self.result = result @@ -4161,8 +4098,7 @@ 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] + :vartype compilation_errors: list[~azure.mgmt.iothub.models.RouteCompilationError] """ _attribute_map = { @@ -4174,8 +4110,7 @@ def __init__( ) -> None: """ :keyword compilation_errors: JSON-serialized list of route compilation errors. - :paramtype compilation_errors: - list[~azure.mgmt.iothub.v2023_06_30_preview.models.RouteCompilationError] + :paramtype compilation_errors: list[~azure.mgmt.iothub.models.RouteCompilationError] """ super().__init__(**kwargs) self.compilation_errors = compilation_errors @@ -4195,7 +4130,7 @@ class UserSubscriptionQuota(_serialization.Model): :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 + :vartype name: ~azure.mgmt.iothub.models.Name """ _attribute_map = { @@ -4230,7 +4165,7 @@ def __init__( :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 + :paramtype name: ~azure.mgmt.iothub.models.Name """ super().__init__(**kwargs) self.id = id @@ -4247,7 +4182,7 @@ class UserSubscriptionQuotaListResult(_serialization.Model): 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] + :vartype value: list[~azure.mgmt.iothub.models.UserSubscriptionQuota] :ivar next_link: :vartype next_link: str """ @@ -4264,8 +4199,8 @@ class UserSubscriptionQuotaListResult(_serialization.Model): 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] + :paramtype value: list[~azure.mgmt.iothub.models.UserSubscriptionQuota] """ super().__init__(**kwargs) self.value = value - self.next_link = None + self.next_link: Optional[str] = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/models/_patch.py similarity index 61% rename from sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_patch.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/models/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_patch.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/models/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: 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/operations/__init__.py similarity index 100% rename from sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/__init__.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/operations/__init__.py 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/operations/_certificates_operations.py similarity index 93% rename from sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_certificates_operations.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/operations/_certificates_operations.py index 15897eb06a27..2bbe8b00624e 100644 --- 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/operations/_certificates_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,10 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -24,12 +26,9 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer +from .._configuration import IotHubClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,14 +42,14 @@ 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + 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"), @@ -74,14 +73,14 @@ def build_get_request( _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")) + 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"), @@ -114,7 +113,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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + 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") @@ -122,7 +121,7 @@ def build_create_or_update_request( _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"), @@ -159,14 +158,14 @@ def build_delete_request( _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")) + 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"), @@ -200,14 +199,14 @@ def build_generate_verification_code_request( _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")) + 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"), @@ -241,7 +240,7 @@ def build_verify_request( _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")) + 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") @@ -249,7 +248,7 @@ def build_verify_request( _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"), @@ -279,19 +278,18 @@ class CertificatesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.iothub.v2023_06_30.IotHubClient`'s + :class:`~azure.mgmt.iothub.IotHubClient`'s :attr:`certificates` attribute. """ models = _models - def __init__(self, *args, **kwargs): + 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") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: IotHubClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_iot_hub( @@ -306,7 +304,7 @@ def list_by_iot_hub( :param resource_name: The name of the IoT hub. Required. :type resource_name: str :return: CertificateListDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateListDescription + :rtype: ~azure.mgmt.iothub.models.CertificateListDescription :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -320,7 +318,7 @@ def list_by_iot_hub( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CertificateListDescription] = kwargs.pop("cls", None) _request = build_list_by_iot_hub_request( @@ -367,7 +365,7 @@ def get( :param certificate_name: The name of the certificate. Required. :type certificate_name: str :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :rtype: ~azure.mgmt.iothub.models.CertificateDescription :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -381,7 +379,7 @@ def get( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) _request = build_get_request( @@ -437,7 +435,7 @@ def create_or_update( :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 + :type certificate_description: ~azure.mgmt.iothub.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 @@ -445,7 +443,7 @@ def create_or_update( Default value is "application/json". :paramtype content_type: str :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :rtype: ~azure.mgmt.iothub.models.CertificateDescription :raises ~azure.core.exceptions.HttpResponseError: """ @@ -480,7 +478,7 @@ def create_or_update( Default value is "application/json". :paramtype content_type: str :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :rtype: ~azure.mgmt.iothub.models.CertificateDescription :raises ~azure.core.exceptions.HttpResponseError: """ @@ -506,13 +504,12 @@ def create_or_update( :type certificate_name: str :param certificate_description: The certificate body. Is either a CertificateDescription type or a IO[bytes] type. Required. - :type certificate_description: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription or - IO[bytes] + :type certificate_description: ~azure.mgmt.iothub.models.CertificateDescription or IO[bytes] :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 :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :rtype: ~azure.mgmt.iothub.models.CertificateDescription :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -526,7 +523,7 @@ def create_or_update( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) @@ -603,7 +600,7 @@ def delete( # pylint: disable=inconsistent-return-statements _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) _request = build_delete_request( @@ -651,7 +648,7 @@ def generate_verification_code( :param if_match: ETag of the Certificate. Required. :type if_match: str :return: CertificateWithNonceDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateWithNonceDescription + :rtype: ~azure.mgmt.iothub.models.CertificateWithNonceDescription :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -665,7 +662,7 @@ def generate_verification_code( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CertificateWithNonceDescription] = kwargs.pop("cls", None) _request = build_generate_verification_code_request( @@ -726,12 +723,12 @@ def verify( :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 + ~azure.mgmt.iothub.models.CertificateVerificationDescription :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :rtype: ~azure.mgmt.iothub.models.CertificateDescription :raises ~azure.core.exceptions.HttpResponseError: """ @@ -766,7 +763,7 @@ def verify( Default value is "application/json". :paramtype content_type: str :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :rtype: ~azure.mgmt.iothub.models.CertificateDescription :raises ~azure.core.exceptions.HttpResponseError: """ @@ -796,9 +793,9 @@ def verify( :param certificate_verification_body: The name of the certificate. Is either a CertificateVerificationDescription type or a IO[bytes] type. Required. :type certificate_verification_body: - ~azure.mgmt.iothub.v2023_06_30.models.CertificateVerificationDescription or IO[bytes] + ~azure.mgmt.iothub.models.CertificateVerificationDescription or IO[bytes] :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.CertificateDescription + :rtype: ~azure.mgmt.iothub.models.CertificateDescription :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -812,7 +809,7 @@ def verify( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CertificateDescription] = kwargs.pop("cls", None) 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/operations/_iot_hub_operations.py similarity index 91% rename from sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_iot_hub_operations.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/operations/_iot_hub_operations.py index a699aa2b17a2..3d4817064e25 100644 --- 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/operations/_iot_hub_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,10 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -import sys from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -28,12 +30,9 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from ..._serialization import Serializer +from .._configuration import IotHubClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +46,7 @@ def build_manual_failover_request( _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")) + 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") @@ -55,7 +54,7 @@ def build_manual_failover_request( _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"), @@ -81,19 +80,18 @@ class IotHubOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.iothub.v2023_06_30.IotHubClient`'s + :class:`~azure.mgmt.iothub.IotHubClient`'s :attr:`iot_hub` attribute. """ models = _models - def __init__(self, *args, **kwargs): + 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") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: IotHubClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _manual_failover_initial( self, @@ -113,7 +111,7 @@ def _manual_failover_initial( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) @@ -192,7 +190,7 @@ def begin_manual_failover( :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 + :type failover_input: ~azure.mgmt.iothub.models.FailoverInput :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -255,7 +253,7 @@ def begin_manual_failover( 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[bytes] type. Required. - :type failover_input: ~azure.mgmt.iothub.v2023_06_30.models.FailoverInput or IO[bytes] + :type failover_input: ~azure.mgmt.iothub.models.FailoverInput or IO[bytes] :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: @@ -263,7 +261,7 @@ def begin_manual_failover( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) 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/v2023_06_30/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/operations/_iot_hub_resource_operations.py similarity index 93% rename from sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_iot_hub_resource_operations.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/operations/_iot_hub_resource_operations.py index 894de8a281ff..eb34f96ec29c 100644 --- 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/operations/_iot_hub_resource_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,11 +6,12 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -31,12 +32,9 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from ..._serialization import Serializer +from .._configuration import IotHubClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -48,14 +46,14 @@ 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + 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"), @@ -79,7 +77,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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + 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") @@ -87,7 +85,7 @@ def build_create_or_update_request( _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"), @@ -115,7 +113,7 @@ def build_update_request( _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")) + 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") @@ -123,7 +121,7 @@ def build_update_request( _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"), @@ -149,14 +147,14 @@ def build_delete_request( _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")) + 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"), @@ -178,7 +176,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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -202,14 +200,14 @@ 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + 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"), @@ -232,14 +230,14 @@ def build_get_stats_request( _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")) + 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"), @@ -263,14 +261,14 @@ def build_get_valid_skus_request( _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")) + 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"), @@ -294,14 +292,14 @@ def build_list_event_hub_consumer_groups_request( # pylint: disable=name-too-lo _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")) + 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"), @@ -331,14 +329,14 @@ def build_get_event_hub_consumer_group_request( # pylint: disable=name-too-long _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")) + 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"), @@ -369,7 +367,7 @@ def build_create_event_hub_consumer_group_request( # pylint: disable=name-too-l _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")) + 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") @@ -377,7 +375,7 @@ def build_create_event_hub_consumer_group_request( # pylint: disable=name-too-l _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"), @@ -410,14 +408,14 @@ def build_delete_event_hub_consumer_group_request( # pylint: disable=name-too-l _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")) + 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"), @@ -443,14 +441,14 @@ def build_list_jobs_request( _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")) + 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"), @@ -474,14 +472,14 @@ def build_get_job_request( _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")) + 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"), @@ -506,14 +504,14 @@ def build_get_quota_metrics_request( _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")) + 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"), @@ -537,14 +535,14 @@ def build_get_endpoint_health_request( _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")) + 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"), @@ -566,7 +564,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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + 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") @@ -597,7 +595,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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + 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") @@ -605,7 +603,7 @@ def build_test_all_routes_request( _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"), @@ -631,7 +629,7 @@ def build_test_route_request( _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")) + 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") @@ -639,7 +637,7 @@ def build_test_route_request( _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"), @@ -665,14 +663,14 @@ def build_list_keys_request( _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")) + 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"), @@ -696,14 +694,14 @@ 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + 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"), @@ -728,7 +726,7 @@ def build_export_devices_request( _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")) + 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") @@ -736,7 +734,7 @@ def build_export_devices_request( _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"), @@ -762,7 +760,7 @@ def build_import_devices_request( _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")) + 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") @@ -770,7 +768,7 @@ def build_import_devices_request( _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"), @@ -796,19 +794,18 @@ class IotHubResourceOperations: # pylint: disable=too-many-public-methods **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.iothub.v2023_06_30.IotHubClient`'s + :class:`~azure.mgmt.iothub.IotHubClient`'s :attr:`iot_hub_resource` attribute. """ models = _models - def __init__(self, *args, **kwargs): + 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") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: IotHubClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.IotHubDescription: @@ -821,7 +818,7 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m :param resource_name: The name of the IoT hub. Required. :type resource_name: str :return: IotHubDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription + :rtype: ~azure.mgmt.iothub.models.IotHubDescription :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -835,7 +832,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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.IotHubDescription] = kwargs.pop("cls", None) _request = build_get_request( @@ -886,7 +883,7 @@ def _create_or_update_initial( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) @@ -929,10 +926,16 @@ def _create_or_update_initial( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -951,16 +954,14 @@ def begin_create_or_update( 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. + 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.models.IotHubDescription + :type iot_hub_description: ~azure.mgmt.iothub.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 @@ -969,7 +970,7 @@ def begin_create_or_update( :paramtype content_type: str :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] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.models.IotHubDescription] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -988,9 +989,7 @@ def begin_create_or_update( 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. + 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 @@ -1006,7 +1005,7 @@ def begin_create_or_update( :paramtype content_type: str :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] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.models.IotHubDescription] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -1023,9 +1022,7 @@ def begin_create_or_update( 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. + 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 @@ -1033,19 +1030,19 @@ def begin_create_or_update( :type resource_name: str :param iot_hub_description: The IoT hub metadata and security metadata. Is either a IotHubDescription type or a IO[bytes] type. Required. - :type iot_hub_description: ~azure.mgmt.iothub.v2023_06_30.models.IotHubDescription or IO[bytes] + :type iot_hub_description: ~azure.mgmt.iothub.models.IotHubDescription or IO[bytes] :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 :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] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) 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) @@ -1108,7 +1105,7 @@ def _update_initial( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) @@ -1149,10 +1146,15 @@ def _update_initial( 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 = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -1175,13 +1177,13 @@ def begin_update( :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 + :type iot_hub_tags: ~azure.mgmt.iothub.models.TagsResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :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] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.models.IotHubDescription] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -1210,7 +1212,7 @@ def begin_update( :paramtype content_type: str :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] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.models.IotHubDescription] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -1232,16 +1234,16 @@ def begin_update( :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[bytes] type. Required. - :type iot_hub_tags: ~azure.mgmt.iothub.v2023_06_30.models.TagsResource or IO[bytes] + :type iot_hub_tags: ~azure.mgmt.iothub.models.TagsResource or IO[bytes] :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] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) 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) @@ -1263,9 +1265,15 @@ def begin_update( 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.http_response) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: @@ -1297,7 +1305,7 @@ def _delete_initial(self, resource_group_name: str, resource_name: str, **kwargs _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( @@ -1332,7 +1340,6 @@ def _delete_initial(self, resource_group_name: str, resource_name: str, **kwargs response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -1355,14 +1362,14 @@ def begin_delete( :type resource_name: str :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] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.models.IotHubDescription] or + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) 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) @@ -1404,19 +1411,19 @@ def get_long_running_output(pipeline_response): ) @distributed_trace - def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: + def list_by_subscription(self, **kwargs: Any) -> ItemPaged["_models.IotHubDescription"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :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] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { @@ -1447,7 +1454,7 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._api_version + _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 ) @@ -1481,7 +1488,7 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.IotHubDescription"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.IotHubDescription"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. @@ -1489,13 +1496,13 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group that contains the IoT hub. Required. :type resource_group_name: str :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] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { @@ -1527,7 +1534,7 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._api_version + _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 ) @@ -1571,7 +1578,7 @@ def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) :param resource_name: The name of the IoT hub. Required. :type resource_name: str :return: RegistryStatistics or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.RegistryStatistics + :rtype: ~azure.mgmt.iothub.models.RegistryStatistics :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1585,7 +1592,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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RegistryStatistics] = kwargs.pop("cls", None) _request = build_get_stats_request( @@ -1620,7 +1627,7 @@ def get_stats(self, resource_group_name: str, resource_name: str, **kwargs: Any) @distributed_trace def get_valid_skus( self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Iterable["_models.IotHubSkuDescription"]: + ) -> ItemPaged["_models.IotHubSkuDescription"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. @@ -1631,14 +1638,13 @@ def get_valid_skus( :type resource_name: str :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] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { @@ -1671,7 +1677,7 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._api_version + _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 ) @@ -1707,7 +1713,7 @@ def get_next(next_link=None): @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"]: + ) -> ItemPaged["_models.EventHubConsumerGroupInfo"]: """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. @@ -1722,14 +1728,13 @@ def list_event_hub_consumer_groups( :type event_hub_endpoint_name: str :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] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { @@ -1763,7 +1768,7 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._api_version + _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 ) @@ -1814,7 +1819,7 @@ def get_event_hub_consumer_group( :param name: The name of the consumer group to retrieve. Required. :type name: str :return: EventHubConsumerGroupInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupInfo + :rtype: ~azure.mgmt.iothub.models.EventHubConsumerGroupInfo :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1828,7 +1833,7 @@ def get_event_hub_consumer_group( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) _request = build_get_event_hub_consumer_group_request( @@ -1888,13 +1893,12 @@ def create_event_hub_consumer_group( :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 + :type consumer_group_body: ~azure.mgmt.iothub.models.EventHubConsumerGroupBodyDescription :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: EventHubConsumerGroupInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupInfo + :rtype: ~azure.mgmt.iothub.models.EventHubConsumerGroupInfo :raises ~azure.core.exceptions.HttpResponseError: """ @@ -1929,7 +1933,7 @@ def create_event_hub_consumer_group( Default value is "application/json". :paramtype content_type: str :return: EventHubConsumerGroupInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupInfo + :rtype: ~azure.mgmt.iothub.models.EventHubConsumerGroupInfo :raises ~azure.core.exceptions.HttpResponseError: """ @@ -1958,10 +1962,10 @@ def create_event_hub_consumer_group( :type name: str :param consumer_group_body: The consumer group to add. Is either a EventHubConsumerGroupBodyDescription type or a IO[bytes] type. Required. - :type consumer_group_body: - ~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupBodyDescription or IO[bytes] + :type consumer_group_body: ~azure.mgmt.iothub.models.EventHubConsumerGroupBodyDescription or + IO[bytes] :return: EventHubConsumerGroupInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.EventHubConsumerGroupInfo + :rtype: ~azure.mgmt.iothub.models.EventHubConsumerGroupInfo :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1975,7 +1979,7 @@ def create_event_hub_consumer_group( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) @@ -2053,7 +2057,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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) _request = build_delete_event_hub_consumer_group_request( @@ -2084,7 +2088,9 @@ def delete_event_hub_consumer_group( # pylint: disable=inconsistent-return-stat return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterable["_models.JobResponse"]: + def list_jobs( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> ItemPaged["_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. @@ -2096,13 +2102,13 @@ def list_jobs(self, resource_group_name: str, resource_name: str, **kwargs: Any) :param resource_name: The name of the IoT hub. Required. :type resource_name: str :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] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { @@ -2135,7 +2141,7 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._api_version + _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 ) @@ -2183,7 +2189,7 @@ def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **k :param job_id: The job identifier. Required. :type job_id: str :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :rtype: ~azure.mgmt.iothub.models.JobResponse :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2197,7 +2203,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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) _request = build_get_job_request( @@ -2233,7 +2239,7 @@ def get_job(self, resource_group_name: str, resource_name: str, job_id: str, **k @distributed_trace def get_quota_metrics( self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Iterable["_models.IotHubQuotaMetricInfo"]: + ) -> ItemPaged["_models.IotHubQuotaMetricInfo"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. @@ -2244,14 +2250,13 @@ def get_quota_metrics( :type resource_name: str :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] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { @@ -2284,7 +2289,7 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._api_version + _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 ) @@ -2320,7 +2325,7 @@ def get_next(next_link=None): @distributed_trace def get_endpoint_health( self, resource_group_name: str, iot_hub_name: str, **kwargs: Any - ) -> Iterable["_models.EndpointHealthData"]: + ) -> ItemPaged["_models.EndpointHealthData"]: """Get the health for routing endpoints. Get the health for routing endpoints. @@ -2330,13 +2335,13 @@ def get_endpoint_health( :param iot_hub_name: Required. :type iot_hub_name: str :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] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { @@ -2369,7 +2374,7 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._api_version + _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 ) @@ -2412,12 +2417,12 @@ def check_name_availability( :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 + :type operation_inputs: ~azure.mgmt.iothub.models.OperationInputs :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: IotHubNameAvailabilityInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.IotHubNameAvailabilityInfo + :rtype: ~azure.mgmt.iothub.models.IotHubNameAvailabilityInfo :raises ~azure.core.exceptions.HttpResponseError: """ @@ -2436,7 +2441,7 @@ def check_name_availability( Default value is "application/json". :paramtype content_type: str :return: IotHubNameAvailabilityInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.IotHubNameAvailabilityInfo + :rtype: ~azure.mgmt.iothub.models.IotHubNameAvailabilityInfo :raises ~azure.core.exceptions.HttpResponseError: """ @@ -2450,9 +2455,9 @@ def check_name_availability( :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[bytes] type. Required. - :type operation_inputs: ~azure.mgmt.iothub.v2023_06_30.models.OperationInputs or IO[bytes] + :type operation_inputs: ~azure.mgmt.iothub.models.OperationInputs or IO[bytes] :return: IotHubNameAvailabilityInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.IotHubNameAvailabilityInfo + :rtype: ~azure.mgmt.iothub.models.IotHubNameAvailabilityInfo :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2466,7 +2471,7 @@ def check_name_availability( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IotHubNameAvailabilityInfo] = kwargs.pop("cls", None) @@ -2527,12 +2532,12 @@ def test_all_routes( :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 + :type input: ~azure.mgmt.iothub.models.TestAllRoutesInput :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: TestAllRoutesResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.TestAllRoutesResult + :rtype: ~azure.mgmt.iothub.models.TestAllRoutesResult :raises ~azure.core.exceptions.HttpResponseError: """ @@ -2560,7 +2565,7 @@ def test_all_routes( Default value is "application/json". :paramtype content_type: str :return: TestAllRoutesResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.TestAllRoutesResult + :rtype: ~azure.mgmt.iothub.models.TestAllRoutesResult :raises ~azure.core.exceptions.HttpResponseError: """ @@ -2582,9 +2587,9 @@ def test_all_routes( :type resource_group_name: str :param input: Input for testing all routes. Is either a TestAllRoutesInput type or a IO[bytes] type. Required. - :type input: ~azure.mgmt.iothub.v2023_06_30.models.TestAllRoutesInput or IO[bytes] + :type input: ~azure.mgmt.iothub.models.TestAllRoutesInput or IO[bytes] :return: TestAllRoutesResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.TestAllRoutesResult + :rtype: ~azure.mgmt.iothub.models.TestAllRoutesResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2598,7 +2603,7 @@ def test_all_routes( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestAllRoutesResult] = kwargs.pop("cls", None) @@ -2661,12 +2666,12 @@ def test_route( :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 + :type input: ~azure.mgmt.iothub.models.TestRouteInput :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: TestRouteResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.TestRouteResult + :rtype: ~azure.mgmt.iothub.models.TestRouteResult :raises ~azure.core.exceptions.HttpResponseError: """ @@ -2694,7 +2699,7 @@ def test_route( Default value is "application/json". :paramtype content_type: str :return: TestRouteResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.TestRouteResult + :rtype: ~azure.mgmt.iothub.models.TestRouteResult :raises ~azure.core.exceptions.HttpResponseError: """ @@ -2716,9 +2721,9 @@ def test_route( :type resource_group_name: str :param input: Route that needs to be tested. Is either a TestRouteInput type or a IO[bytes] type. Required. - :type input: ~azure.mgmt.iothub.v2023_06_30.models.TestRouteInput or IO[bytes] + :type input: ~azure.mgmt.iothub.models.TestRouteInput or IO[bytes] :return: TestRouteResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.TestRouteResult + :rtype: ~azure.mgmt.iothub.models.TestRouteResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2732,7 +2737,7 @@ def test_route( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TestRouteResult] = kwargs.pop("cls", None) @@ -2779,7 +2784,7 @@ def test_route( @distributed_trace def list_keys( self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Iterable["_models.SharedAccessSignatureAuthorizationRule"]: + ) -> ItemPaged["_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. @@ -2793,13 +2798,13 @@ def list_keys( :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] + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { @@ -2832,7 +2837,7 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._api_version + _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 ) @@ -2882,7 +2887,7 @@ def get_keys_for_key_name( :param key_name: The name of the shared access policy. Required. :type key_name: str :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.SharedAccessSignatureAuthorizationRule + :rtype: ~azure.mgmt.iothub.models.SharedAccessSignatureAuthorizationRule :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2896,7 +2901,7 @@ def get_keys_for_key_name( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SharedAccessSignatureAuthorizationRule] = kwargs.pop("cls", None) _request = build_get_keys_for_key_name_request( @@ -2953,12 +2958,12 @@ def export_devices( :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 + :type export_devices_parameters: ~azure.mgmt.iothub.models.ExportDevicesRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :rtype: ~azure.mgmt.iothub.models.JobResponse :raises ~azure.core.exceptions.HttpResponseError: """ @@ -2991,7 +2996,7 @@ def export_devices( Default value is "application/json". :paramtype content_type: str :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :rtype: ~azure.mgmt.iothub.models.JobResponse :raises ~azure.core.exceptions.HttpResponseError: """ @@ -3017,10 +3022,9 @@ def export_devices( :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. Is either a ExportDevicesRequest type or a IO[bytes] type. Required. - :type export_devices_parameters: ~azure.mgmt.iothub.v2023_06_30.models.ExportDevicesRequest or - IO[bytes] + :type export_devices_parameters: ~azure.mgmt.iothub.models.ExportDevicesRequest or IO[bytes] :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :rtype: ~azure.mgmt.iothub.models.JobResponse :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -3034,7 +3038,7 @@ def export_devices( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) @@ -3102,12 +3106,12 @@ def import_devices( :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 + :type import_devices_parameters: ~azure.mgmt.iothub.models.ImportDevicesRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :rtype: ~azure.mgmt.iothub.models.JobResponse :raises ~azure.core.exceptions.HttpResponseError: """ @@ -3140,7 +3144,7 @@ def import_devices( Default value is "application/json". :paramtype content_type: str :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :rtype: ~azure.mgmt.iothub.models.JobResponse :raises ~azure.core.exceptions.HttpResponseError: """ @@ -3166,10 +3170,9 @@ def import_devices( :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. Is either a ImportDevicesRequest type or a IO[bytes] type. Required. - :type import_devices_parameters: ~azure.mgmt.iothub.v2023_06_30.models.ImportDevicesRequest or - IO[bytes] + :type import_devices_parameters: ~azure.mgmt.iothub.models.ImportDevicesRequest or IO[bytes] :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.JobResponse + :rtype: ~azure.mgmt.iothub.models.JobResponse :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -3183,7 +3186,7 @@ def import_devices( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JobResponse] = kwargs.pop("cls", None) 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/operations/_operations.py similarity index 83% rename from sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_operations.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/operations/_operations.py index 2979c6457b6c..037c82d12efa 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/operations/_operations.py @@ -5,10 +5,11 @@ # 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 +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -25,12 +26,9 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer +from .._configuration import IotHubClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,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: str = kwargs.pop("api_version", _params.pop("api-version", "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,32 +61,31 @@ class Operations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.iothub.v2019_03_22.IotHubClient`'s + :class:`~azure.mgmt.iothub.IotHubClient`'s :attr:`operations` attribute. """ models = _models - def __init__(self, *args, **kwargs): + 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") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: IotHubClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: + def list(self, **kwargs: Any) -> ItemPaged["_models.Operation"]: """Lists all of the available IoT Hub REST API operations. :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.Operation] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.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 "2019-03-22")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { @@ -118,7 +115,7 @@ def prepare_request(next_link=None): for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) - _next_request_params["api-version"] = self._api_version + _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 ) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/operations/_patch.py new file mode 100644 index 000000000000..8bcb627aa475 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/operations/_patch.py @@ -0,0 +1,21 @@ +# 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. +# -------------------------------------------------------------------------- +"""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/operations/_private_endpoint_connections_operations.py similarity index 92% rename from sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_private_endpoint_connections_operations.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/operations/_private_endpoint_connections_operations.py index 6d0e0d59e778..c86f5767b579 100644 --- 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/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,10 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -import sys from typing import Any, Callable, Dict, IO, Iterator, List, Optional, TypeVar, Union, cast, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -28,12 +30,9 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from ..._serialization import Serializer +from .._configuration import IotHubClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,14 +46,14 @@ def build_list_request( _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")) + 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"), @@ -82,14 +81,14 @@ def build_get_request( _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")) + 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"), @@ -120,7 +119,7 @@ def build_update_request( _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")) + 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") @@ -128,7 +127,7 @@ def build_update_request( _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"), @@ -161,14 +160,14 @@ def build_delete_request( _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")) + 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"), @@ -195,19 +194,18 @@ class PrivateEndpointConnectionsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.iothub.v2023_06_30.IotHubClient`'s + :class:`~azure.mgmt.iothub.IotHubClient`'s :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, *args, **kwargs): + 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") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: IotHubClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( @@ -222,7 +220,7 @@ def list( :param resource_name: The name of the IoT hub. Required. :type resource_name: str :return: list of PrivateEndpointConnection or the result of cls(response) - :rtype: list[~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpointConnection] + :rtype: list[~azure.mgmt.iothub.models.PrivateEndpointConnection] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -236,7 +234,7 @@ def list( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) _request = build_list_request( @@ -283,7 +281,7 @@ def get( :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpointConnection + :rtype: ~azure.mgmt.iothub.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -297,7 +295,7 @@ def get( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) _request = build_get_request( @@ -349,7 +347,7 @@ def _update_initial( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) @@ -392,10 +390,16 @@ def _update_initial( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @@ -422,15 +426,13 @@ def begin_update( :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 + :type private_endpoint_connection: ~azure.mgmt.iothub.models.PrivateEndpointConnection :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :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] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.models.PrivateEndpointConnection] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -463,8 +465,7 @@ def begin_update( :paramtype content_type: str :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] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.models.PrivateEndpointConnection] :raises ~azure.core.exceptions.HttpResponseError: """ @@ -489,18 +490,17 @@ def begin_update( :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[bytes] type. Required. - :type private_endpoint_connection: - ~azure.mgmt.iothub.v2023_06_30.models.PrivateEndpointConnection or IO[bytes] + :type private_endpoint_connection: ~azure.mgmt.iothub.models.PrivateEndpointConnection or + IO[bytes] :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] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) 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) @@ -559,7 +559,7 @@ def _delete_initial( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( @@ -595,7 +595,6 @@ def _delete_initial( response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) @@ -620,14 +619,13 @@ def begin_delete( :type private_endpoint_connection_name: str :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] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) 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/v2023_06_30/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/operations/_private_link_resources_operations.py similarity index 88% rename from sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_private_link_resources_operations.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/operations/_private_link_resources_operations.py index 284e216d9080..91076ea833fd 100644 --- 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/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,10 @@ # 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 collections.abc import MutableMapping from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -23,12 +25,9 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer +from .._configuration import IotHubClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,14 +41,14 @@ def build_list_request( _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")) + 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"), @@ -73,14 +72,14 @@ def build_get_request( _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")) + 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"), @@ -105,19 +104,18 @@ class PrivateLinkResourcesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.iothub.v2023_06_30.IotHubClient`'s + :class:`~azure.mgmt.iothub.IotHubClient`'s :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, *args, **kwargs): + 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") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: IotHubClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.PrivateLinkResources: @@ -130,7 +128,7 @@ def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _ :param resource_name: The name of the IoT hub. Required. :type resource_name: str :return: PrivateLinkResources or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.PrivateLinkResources + :rtype: ~azure.mgmt.iothub.models.PrivateLinkResources :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -144,7 +142,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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkResources] = kwargs.pop("cls", None) _request = build_list_request( @@ -191,7 +189,7 @@ def get( :param group_id: The name of the private link resource. Required. :type group_id: str :return: GroupIdInformation or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.GroupIdInformation + :rtype: ~azure.mgmt.iothub.models.GroupIdInformation :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -205,7 +203,7 @@ def get( _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")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GroupIdInformation] = kwargs.pop("cls", None) _request = build_get_request( 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/operations/_resource_provider_common_operations.py similarity index 83% rename from sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_resource_provider_common_operations.py rename to sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/operations/_resource_provider_common_operations.py index a7cc8a6ca62e..029ec0d56f45 100644 --- 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/operations/_resource_provider_common_operations.py @@ -5,9 +5,10 @@ # 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 collections.abc import MutableMapping from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -23,12 +24,9 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from ..._serialization import Serializer +from .._configuration import IotHubClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-30-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,19 +64,18 @@ class ResourceProviderCommonOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.iothub.v2023_06_30.IotHubClient`'s + :class:`~azure.mgmt.iothub.IotHubClient`'s :attr:`resource_provider_common` attribute. """ models = _models - def __init__(self, *args, **kwargs): + 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") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: IotHubClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuotaListResult: @@ -87,7 +84,7 @@ def get_subscription_quota(self, **kwargs: Any) -> _models.UserSubscriptionQuota Get the number of free and paid iot hubs in the subscription. :return: UserSubscriptionQuotaListResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2023_06_30.models.UserSubscriptionQuotaListResult + :rtype: ~azure.mgmt.iothub.models.UserSubscriptionQuotaListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -101,7 +98,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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-06-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) 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/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/__init__.py deleted file mode 100644 index ec710f27f0eb..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._iot_hub_client import IotHubClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_patch_sdk() 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 deleted file mode 100644 index 30ac7539309d..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class IotHubClientConfiguration: # 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 "2019-03-22". 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: - api_version: str = kwargs.pop("api_version", "2019-03-22") - - 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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**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/v2019_03_22/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_iot_hub_client.py deleted file mode 100644 index c4ff4f1c002f..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_iot_hub_client.py +++ /dev/null @@ -1,134 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import IotHubClientConfiguration -from .operations import ( - CertificatesOperations, - IotHubOperations, - IotHubResourceOperations, - Operations, - ResourceProviderCommonOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class IotHubClient: - """Use this API to manage the IoT hubs in your Azure subscription. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.iothub.v2019_03_22.operations.Operations - :ivar iot_hub_resource: IotHubResourceOperations operations - :vartype iot_hub_resource: azure.mgmt.iothub.v2019_03_22.operations.IotHubResourceOperations - :ivar resource_provider_common: ResourceProviderCommonOperations operations - :vartype resource_provider_common: - azure.mgmt.iothub.v2019_03_22.operations.ResourceProviderCommonOperations - :ivar certificates: CertificatesOperations operations - :vartype certificates: azure.mgmt.iothub.v2019_03_22.operations.CertificatesOperations - :ivar iot_hub: IotHubOperations operations - :vartype iot_hub: azure.mgmt.iothub.v2019_03_22.operations.IotHubOperations - :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 "2019-03-22". 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) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **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, "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, "2019-03-22" - ) - self.certificates = CertificatesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-03-22" - ) - self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize, "2019-03-22") - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - 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/v2019_03_22/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_metadata.json deleted file mode 100644 index 3ef82e3de9cf..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_metadata.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "chosen_version": "2019-03-22", - "total_api_version_list": ["2019-03-22"], - "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_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"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\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "operations": "Operations", - "iot_hub_resource": "IotHubResourceOperations", - "resource_provider_common": "ResourceProviderCommonOperations", - "certificates": "CertificatesOperations", - "iot_hub": "IotHubOperations" - } -} diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/__init__.py deleted file mode 100644 index df18749d0db3..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._iot_hub_client import IotHubClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_patch_sdk() 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 deleted file mode 100644 index 25b37b5f724e..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class IotHubClientConfiguration: # 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 "2019-03-22". 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: - api_version: str = kwargs.pop("api_version", "2019-03-22") - - 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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**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/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 deleted file mode 100644 index cdf6e0711df0..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_iot_hub_client.py +++ /dev/null @@ -1,137 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import IotHubClientConfiguration -from .operations import ( - CertificatesOperations, - IotHubOperations, - IotHubResourceOperations, - Operations, - ResourceProviderCommonOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class IotHubClient: - """Use this API to manage the IoT hubs in your Azure subscription. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.iothub.v2019_03_22.aio.operations.Operations - :ivar iot_hub_resource: IotHubResourceOperations operations - :vartype iot_hub_resource: - azure.mgmt.iothub.v2019_03_22.aio.operations.IotHubResourceOperations - :ivar resource_provider_common: ResourceProviderCommonOperations operations - :vartype resource_provider_common: - azure.mgmt.iothub.v2019_03_22.aio.operations.ResourceProviderCommonOperations - :ivar certificates: CertificatesOperations operations - :vartype certificates: azure.mgmt.iothub.v2019_03_22.aio.operations.CertificatesOperations - :ivar iot_hub: IotHubOperations operations - :vartype iot_hub: azure.mgmt.iothub.v2019_03_22.aio.operations.IotHubOperations - :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 "2019-03-22". 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) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **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, "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, "2019-03-22" - ) - self.certificates = CertificatesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-03-22" - ) - self.iot_hub = IotHubOperations(self._client, self._config, self._serialize, self._deserialize, "2019-03-22") - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - 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/v2019_03_22/aio/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/__init__.py deleted file mode 100644 index 32e1fa0a9eb1..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import Operations # type: ignore -from ._iot_hub_resource_operations import IotHubResourceOperations # type: ignore -from ._resource_provider_common_operations import ResourceProviderCommonOperations # type: ignore -from ._certificates_operations import CertificatesOperations # type: ignore -from ._iot_hub_operations import IotHubOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Operations", - "IotHubResourceOperations", - "ResourceProviderCommonOperations", - "CertificatesOperations", - "IotHubOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_patch_sdk() 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 deleted file mode 100644 index 812876239c99..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_certificates_operations.py +++ /dev/null @@ -1,627 +0,0 @@ -# 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 -import sys -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.rest import AsyncHttpResponse, 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 ...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, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2019_03_22.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 - :return: CertificateListDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateListDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-03-22")) - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-03-22")) - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - certificate_description: _models.CertificateBodyDescription, - 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.v2019_03_22.models.CertificateBodyDescription - :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 - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.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[bytes], - 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[bytes] - :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 - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.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.CertificateBodyDescription, IO[bytes]], - 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 CertificateBodyDescription - type or a IO[bytes] type. Required. - :type certificate_description: ~azure.mgmt.iothub.v2019_03_22.models.CertificateBodyDescription - or IO[bytes] - :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 - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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, (IOBase, bytes)): - _content = certificate_description - else: - _json = self._serialize.body(certificate_description, "CertificateBodyDescription") - - _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, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("CertificateDescription", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( - 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-03-22")) - 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, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @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 - :return: CertificateWithNonceDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateWithNonceDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-03-22")) - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_03_22.models.CertificateVerificationDescription - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.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[bytes]], - **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[bytes] type. Required. - :type certificate_verification_body: - ~azure.mgmt.iothub.v2019_03_22.models.CertificateVerificationDescription or IO[bytes] - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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, (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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 158d024d6954..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_iot_hub_operations.py +++ /dev/null @@ -1,260 +0,0 @@ -# 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 -import sys -from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._iot_hub_operations import build_manual_failover_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2019_03_22.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( - self, - iot_hub_name: str, - resource_group_name: str, - failover_input: Union[_models.FailoverInput, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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 "2019-03-22")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_03_22.models.FailoverInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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[bytes] type. - Required. - :type failover_input: ~azure.mgmt.iothub.v2019_03_22.models.FailoverInput or IO[bytes] - :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 "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) - 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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index efbbd9860855..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_iot_hub_resource_operations.py +++ /dev/null @@ -1,2426 +0,0 @@ -# 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 -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2019_03_22.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 - :return: IotHubDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-03-22")) - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - iot_hub_description: Union[_models.IotHubDescription, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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 "2019-03-22")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_03_22.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 - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_03_22.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[bytes], - 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[bytes] - :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 - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_03_22.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[bytes]], - 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[bytes] type. Required. - :type iot_hub_description: ~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription or IO[bytes] - :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 - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_03_22.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 "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) - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("IotHubDescription", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.IotHubDescription].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.IotHubDescription]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - resource_name: str, - iot_hub_tags: Union[_models.TagsResource, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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 "2019-03-22")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_03_22.models.TagsResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - resource_name: str, - iot_hub_tags: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_03_22.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[bytes]], - **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[bytes] type. Required. - :type iot_hub_tags: ~azure.mgmt.iothub.v2019_03_22.models.TagsResource or IO[bytes] - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_03_22.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 "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) - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("IotHubDescription", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.IotHubDescription].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.IotHubDescription]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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 "2019-03-22")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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.v2019_03_22.models.IotHubDescription] or - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_03_22.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 "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) - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("IotHubDescription", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.IotHubDescription].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.IotHubDescription]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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. - - :return: An iterator like instance of either IotHubDescription or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.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 "2019-03-22")) - cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :return: An iterator like instance of either IotHubDescription or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.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 "2019-03-22")) - cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :return: RegistryStatistics or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.RegistryStatistics - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-03-22")) - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: An iterator like instance of either IotHubSkuDescription or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.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 "2019-03-22")) - cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.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 "2019-03-22")) - cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :return: EventHubConsumerGroupInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.EventHubConsumerGroupInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-03-22")) - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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, **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 - :return: EventHubConsumerGroupInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.EventHubConsumerGroupInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-03-22")) - cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) - - _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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete_event_hub_consumer_group( - 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-03-22")) - 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, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @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 - :return: An iterator like instance of either JobResponse or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.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 "2019-03-22")) - cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.JobResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-03-22")) - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.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 "2019-03-22")) - cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :return: An iterator like instance of either EndpointHealthData or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.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 "2019-03-22")) - cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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.v2019_03_22.models.OperationInputs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: IotHubNameAvailabilityInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.IotHubNameAvailabilityInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_name_availability( - self, operation_inputs: IO[bytes], *, 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: IotHubNameAvailabilityInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.IotHubNameAvailabilityInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def check_name_availability( - self, operation_inputs: Union[_models.OperationInputs, IO[bytes]], **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[bytes] type. Required. - :type operation_inputs: ~azure.mgmt.iothub.v2019_03_22.models.OperationInputs or IO[bytes] - :return: IotHubNameAvailabilityInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.IotHubNameAvailabilityInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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, (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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_03_22.models.TestAllRoutesInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: TestAllRoutesResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.TestAllRoutesResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def test_all_routes( - self, - iot_hub_name: str, - resource_group_name: str, - input: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: TestAllRoutesResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.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[bytes]], - **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[bytes] - type. Required. - :type input: ~azure.mgmt.iothub.v2019_03_22.models.TestAllRoutesInput or IO[bytes] - :return: TestAllRoutesResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.TestAllRoutesResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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, (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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_03_22.models.TestRouteInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: TestRouteResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.TestRouteResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def test_route( - self, - iot_hub_name: str, - resource_group_name: str, - input: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: TestRouteResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.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[bytes]], - **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[bytes] - type. Required. - :type input: ~azure.mgmt.iothub.v2019_03_22.models.TestRouteInput or IO[bytes] - :return: TestRouteResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.TestRouteResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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, (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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_keys( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRule"]: - # pylint: disable=line-too-long - """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 - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.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 "2019-03-22")) - cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.SharedAccessSignatureAuthorizationRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-03-22")) - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_03_22.models.ExportDevicesRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.JobResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def export_devices( - self, - resource_group_name: str, - resource_name: str, - export_devices_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.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[bytes]], - **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[bytes] type. Required. - :type export_devices_parameters: ~azure.mgmt.iothub.v2019_03_22.models.ExportDevicesRequest or - IO[bytes] - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.JobResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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, (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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_03_22.models.ImportDevicesRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.JobResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def import_devices( - self, - resource_group_name: str, - resource_name: str, - import_devices_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.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[bytes]], - **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[bytes] type. Required. - :type import_devices_parameters: ~azure.mgmt.iothub.v2019_03_22.models.ImportDevicesRequest or - IO[bytes] - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.JobResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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, (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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 5a20569101c4..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_resource_provider_common_operations.py +++ /dev/null @@ -1,105 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -import sys -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.rest import AsyncHttpResponse, 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 ...operations._resource_provider_common_operations import build_get_subscription_quota_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2019_03_22.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. - - :return: UserSubscriptionQuotaListResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.UserSubscriptionQuotaListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-03-22")) - cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) - - _request = build_get_subscription_quota_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/__init__.py deleted file mode 100644 index 6d972b1460ed..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/__init__.py +++ /dev/null @@ -1,190 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - CertificateBodyDescription, - CertificateDescription, - CertificateListDescription, - CertificateProperties, - CertificatePropertiesWithNonce, - CertificateVerificationDescription, - CertificateWithNonceDescription, - CloudToDeviceProperties, - EndpointHealthData, - EndpointHealthDataListResult, - ErrorDetails, - EventHubConsumerGroupInfo, - EventHubConsumerGroupsListResult, - EventHubProperties, - ExportDevicesRequest, - FailoverInput, - FallbackRouteProperties, - FeedbackProperties, - ImportDevicesRequest, - IotHubCapacity, - IotHubDescription, - IotHubDescriptionListResult, - IotHubLocationDescription, - IotHubNameAvailabilityInfo, - IotHubProperties, - IotHubQuotaMetricInfo, - IotHubQuotaMetricInfoListResult, - IotHubSkuDescription, - IotHubSkuDescriptionListResult, - IotHubSkuInfo, - IpFilterRule, - JobResponse, - JobResponseListResult, - MatchedRoute, - MessagingEndpointProperties, - Name, - Operation, - OperationDisplay, - OperationInputs, - OperationListResult, - RegistryStatistics, - Resource, - RouteCompilationError, - RouteErrorPosition, - RouteErrorRange, - RouteProperties, - RoutingEndpoints, - RoutingEventHubProperties, - RoutingMessage, - RoutingProperties, - RoutingServiceBusQueueEndpointProperties, - RoutingServiceBusTopicEndpointProperties, - RoutingStorageContainerProperties, - RoutingTwin, - RoutingTwinProperties, - SharedAccessSignatureAuthorizationRule, - SharedAccessSignatureAuthorizationRuleListResult, - StorageEndpointProperties, - TagsResource, - TestAllRoutesInput, - TestAllRoutesResult, - TestRouteInput, - TestRouteResult, - TestRouteResultDetails, - UserSubscriptionQuota, - UserSubscriptionQuotaListResult, -) - -from ._iot_hub_client_enums import ( # type: ignore - AccessRights, - Capabilities, - EndpointHealthStatus, - IotHubNameUnavailabilityReason, - IotHubReplicaRoleType, - IotHubScaleType, - IotHubSku, - IotHubSkuTier, - IpFilterActionType, - JobStatus, - JobType, - RouteErrorSeverity, - RoutingSource, - RoutingStorageContainerPropertiesEncoding, - TestResultStatus, -) -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CertificateBodyDescription", - "CertificateDescription", - "CertificateListDescription", - "CertificateProperties", - "CertificatePropertiesWithNonce", - "CertificateVerificationDescription", - "CertificateWithNonceDescription", - "CloudToDeviceProperties", - "EndpointHealthData", - "EndpointHealthDataListResult", - "ErrorDetails", - "EventHubConsumerGroupInfo", - "EventHubConsumerGroupsListResult", - "EventHubProperties", - "ExportDevicesRequest", - "FailoverInput", - "FallbackRouteProperties", - "FeedbackProperties", - "ImportDevicesRequest", - "IotHubCapacity", - "IotHubDescription", - "IotHubDescriptionListResult", - "IotHubLocationDescription", - "IotHubNameAvailabilityInfo", - "IotHubProperties", - "IotHubQuotaMetricInfo", - "IotHubQuotaMetricInfoListResult", - "IotHubSkuDescription", - "IotHubSkuDescriptionListResult", - "IotHubSkuInfo", - "IpFilterRule", - "JobResponse", - "JobResponseListResult", - "MatchedRoute", - "MessagingEndpointProperties", - "Name", - "Operation", - "OperationDisplay", - "OperationInputs", - "OperationListResult", - "RegistryStatistics", - "Resource", - "RouteCompilationError", - "RouteErrorPosition", - "RouteErrorRange", - "RouteProperties", - "RoutingEndpoints", - "RoutingEventHubProperties", - "RoutingMessage", - "RoutingProperties", - "RoutingServiceBusQueueEndpointProperties", - "RoutingServiceBusTopicEndpointProperties", - "RoutingStorageContainerProperties", - "RoutingTwin", - "RoutingTwinProperties", - "SharedAccessSignatureAuthorizationRule", - "SharedAccessSignatureAuthorizationRuleListResult", - "StorageEndpointProperties", - "TagsResource", - "TestAllRoutesInput", - "TestAllRoutesResult", - "TestRouteInput", - "TestRouteResult", - "TestRouteResultDetails", - "UserSubscriptionQuota", - "UserSubscriptionQuotaListResult", - "AccessRights", - "Capabilities", - "EndpointHealthStatus", - "IotHubNameUnavailabilityReason", - "IotHubReplicaRoleType", - "IotHubScaleType", - "IotHubSku", - "IotHubSkuTier", - "IpFilterActionType", - "JobStatus", - "JobType", - "RouteErrorSeverity", - "RoutingSource", - "RoutingStorageContainerPropertiesEncoding", - "TestResultStatus", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_patch_sdk() 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 deleted file mode 100644 index 2a2b2ef64ffa..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_iot_hub_client_enums.py +++ /dev/null @@ -1,171 +0,0 @@ -# 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 Capabilities(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The capabilities and features enabled for the IoT hub.""" - - NONE = "None" - DEVICE_MANAGEMENT = "DeviceManagement" - - -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" - 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 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" - - -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/v2019_03_22/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_models_py3.py deleted file mode 100644 index 0cadf0df165f..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_models_py3.py +++ /dev/null @@ -1,2888 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- - -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 - -if TYPE_CHECKING: - from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object - - -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 - """ - - _attribute_map = { - "certificate": {"key": "certificate", "type": "str"}, - } - - def __init__(self, *, certificate: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword certificate: base-64 representation of the X509 leaf certificate .cer file or just - .pem file content. - :paramtype certificate: str - """ - super().__init__(**kwargs) - self.certificate = certificate - - -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.v2019_03_22.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.v2019_03_22.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.v2019_03_22.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.v2019_03_22.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}, - "is_verified": {"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, *, certificate: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword certificate: The certificate content. - :paramtype certificate: str - """ - super().__init__(**kwargs) - self.subject = None - self.expiry = None - self.thumbprint = None - self.is_verified = None - 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.v2019_03_22.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.v2019_03_22.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.v2019_03_22.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.v2019_03_22.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", "unhealthy", and - "dead". - :vartype health_status: str or ~azure.mgmt.iothub.v2019_03_22.models.EndpointHealthStatus - """ - - _attribute_map = { - "endpoint_id": {"key": "endpointId", "type": "str"}, - "health_status": {"key": "healthStatus", "type": "str"}, - } - - def __init__( - self, - *, - endpoint_id: Optional[str] = None, - health_status: Optional[Union[str, "_models.EndpointHealthStatus"]] = 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", - "unhealthy", and "dead". - :paramtype health_status: str or ~azure.mgmt.iothub.v2019_03_22.models.EndpointHealthStatus - """ - super().__init__(**kwargs) - self.endpoint_id = endpoint_id - self.health_status = health_status - - -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.v2019_03_22.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.v2019_03_22.models.EndpointHealthData] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -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 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, str] - :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": "{str}"}, - "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, str]] = None, **kwargs: Any) -> None: - """ - :keyword properties: The tags. - :paramtype properties: dict[str, str] - """ - super().__init__(**kwargs) - self.properties = properties - self.id = None - self.name = None - self.type = None - self.etag = None - - -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.v2019_03_22.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.v2019_03_22.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 server. - - :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 - """ - - _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"}, - } - - def __init__(self, *, export_blob_container_uri: str, exclude_keys: bool, **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 - """ - super().__init__(**kwargs) - self.export_blob_container_uri = export_blob_container_uri - self.exclude_keys = exclude_keys - - -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 server. - - :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 server. - - :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", and "DeviceJobLifecycleEvents". - :vartype source: str or ~azure.mgmt.iothub.v2019_03_22.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", and "DeviceJobLifecycleEvents". - :paramtype source: str or ~azure.mgmt.iothub.v2019_03_22.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 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 server. - - :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 - """ - - _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"}, - } - - def __init__(self, *, input_blob_container_uri: str, output_blob_container_uri: str, **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 - """ - super().__init__(**kwargs) - self.input_blob_container_uri = input_blob_container_uri - self.output_blob_container_uri = output_blob_container_uri - - -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.v2019_03_22.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 server. - - :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 server. - - :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.v2019_03_22.models.IotHubProperties - :ivar sku: IotHub SKU info. Required. - :vartype sku: ~azure.mgmt.iothub.v2019_03_22.models.IotHubSkuInfo - """ - - _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}, - } - - _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"}, - } - - def __init__( - self, - *, - location: str, - sku: "_models.IotHubSkuInfo", - tags: Optional[Dict[str, str]] = None, - etag: Optional[str] = None, - properties: Optional["_models.IotHubProperties"] = 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.v2019_03_22.models.IotHubProperties - :keyword sku: IotHub SKU info. Required. - :paramtype sku: ~azure.mgmt.iothub.v2019_03_22.models.IotHubSkuInfo - """ - super().__init__(location=location, tags=tags, **kwargs) - self.etag = etag - self.properties = properties - self.sku = sku - - -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.v2019_03_22.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.v2019_03_22.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.v2019_03_22.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.v2019_03_22.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.v2019_03_22.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): - """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.v2019_03_22.models.SharedAccessSignatureAuthorizationRule] - :ivar ip_filter_rules: The IP filter rules. - :vartype ip_filter_rules: list[~azure.mgmt.iothub.v2019_03_22.models.IpFilterRule] - :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.v2019_03_22.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.v2019_03_22.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.v2019_03_22.models.StorageEndpointProperties] - :ivar messaging_endpoints: The messaging endpoint properties for the file upload notification - queue. - :vartype messaging_endpoints: dict[str, - ~azure.mgmt.iothub.v2019_03_22.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.v2019_03_22.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.v2019_03_22.models.Capabilities - :ivar locations: Primary and secondary location for iot hub. - :vartype locations: list[~azure.mgmt.iothub.v2019_03_22.models.IotHubLocationDescription] - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "state": {"readonly": True}, - "host_name": {"readonly": True}, - "locations": {"readonly": True}, - } - - _attribute_map = { - "authorization_policies": {"key": "authorizationPolicies", "type": "[SharedAccessSignatureAuthorizationRule]"}, - "ip_filter_rules": {"key": "ipFilterRules", "type": "[IpFilterRule]"}, - "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]"}, - } - - def __init__( - self, - *, - authorization_policies: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, - ip_filter_rules: Optional[List["_models.IpFilterRule"]] = 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, - **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.v2019_03_22.models.SharedAccessSignatureAuthorizationRule] - :keyword ip_filter_rules: The IP filter rules. - :paramtype ip_filter_rules: list[~azure.mgmt.iothub.v2019_03_22.models.IpFilterRule] - :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.v2019_03_22.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.v2019_03_22.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.v2019_03_22.models.StorageEndpointProperties] - :keyword messaging_endpoints: The messaging endpoint properties for the file upload - notification queue. - :paramtype messaging_endpoints: dict[str, - ~azure.mgmt.iothub.v2019_03_22.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.v2019_03_22.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.v2019_03_22.models.Capabilities - """ - super().__init__(**kwargs) - self.authorization_policies = authorization_policies - self.ip_filter_rules = ip_filter_rules - 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 - - -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.v2019_03_22.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.v2019_03_22.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 server. - - :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.v2019_03_22.models.IotHubSkuInfo - :ivar capacity: IotHub capacity. Required. - :vartype capacity: ~azure.mgmt.iothub.v2019_03_22.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.v2019_03_22.models.IotHubSkuInfo - :keyword capacity: IotHub capacity. Required. - :paramtype capacity: ~azure.mgmt.iothub.v2019_03_22.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.v2019_03_22.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.v2019_03_22.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 server. - - :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.v2019_03_22.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.v2019_03_22.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.v2019_03_22.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 server. - - :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.v2019_03_22.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.v2019_03_22.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.v2019_03_22.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.v2019_03_22.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.v2019_03_22.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.v2019_03_22.models.JobResponse] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class MatchedRoute(_serialization.Model): - """Routes that matched. - - :ivar properties: Properties of routes that matched. - :vartype properties: ~azure.mgmt.iothub.v2019_03_22.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.v2019_03_22.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 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.v2019_03_22.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.v2019_03_22.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 server. - - :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.v2019_03_22.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 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.v2019_03_22.models.RouteErrorSeverity - :ivar location: Location where the route error happened. - :vartype location: ~azure.mgmt.iothub.v2019_03_22.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.v2019_03_22.models.RouteErrorSeverity - :keyword location: Location where the route error happened. - :paramtype location: ~azure.mgmt.iothub.v2019_03_22.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.v2019_03_22.models.RouteErrorPosition - :ivar end: End where the route error happened. - :vartype end: ~azure.mgmt.iothub.v2019_03_22.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.v2019_03_22.models.RouteErrorPosition - :keyword end: End where the route error happened. - :paramtype end: ~azure.mgmt.iothub.v2019_03_22.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 server. - - :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", and "DeviceJobLifecycleEvents". - :vartype source: str or ~azure.mgmt.iothub.v2019_03_22.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", and "DeviceJobLifecycleEvents". - :paramtype source: str or ~azure.mgmt.iothub.v2019_03_22.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 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.v2019_03_22.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.v2019_03_22.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.v2019_03_22.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.v2019_03_22.models.RoutingStorageContainerProperties] - """ - - _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]"}, - } - - 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, - **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.v2019_03_22.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.v2019_03_22.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.v2019_03_22.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.v2019_03_22.models.RoutingStorageContainerProperties] - """ - 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 - - -class RoutingEventHubProperties(_serialization.Model): - """The properties related to an event hub endpoint. - - All required parameters must be populated in order to send to server. - - :ivar connection_string: The connection string of the event hub endpoint. Required. - :vartype connection_string: str - :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 = { - "connection_string": {"required": True}, - "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, - } - - _attribute_map = { - "connection_string": {"key": "connectionString", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "subscription_id": {"key": "subscriptionId", "type": "str"}, - "resource_group": {"key": "resourceGroup", "type": "str"}, - } - - def __init__( - self, - *, - connection_string: str, - name: str, - subscription_id: Optional[str] = None, - resource_group: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword connection_string: The connection string of the event hub endpoint. Required. - :paramtype connection_string: str - :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.connection_string = connection_string - 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.v2019_03_22.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.v2019_03_22.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.v2019_03_22.models.FallbackRouteProperties - """ - - _attribute_map = { - "endpoints": {"key": "endpoints", "type": "RoutingEndpoints"}, - "routes": {"key": "routes", "type": "[RouteProperties]"}, - "fallback_route": {"key": "fallbackRoute", "type": "FallbackRouteProperties"}, - } - - def __init__( - self, - *, - endpoints: Optional["_models.RoutingEndpoints"] = None, - routes: Optional[List["_models.RouteProperties"]] = None, - fallback_route: Optional["_models.FallbackRouteProperties"] = 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.v2019_03_22.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.v2019_03_22.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.v2019_03_22.models.FallbackRouteProperties - """ - super().__init__(**kwargs) - self.endpoints = endpoints - self.routes = routes - self.fallback_route = fallback_route - - -class RoutingServiceBusQueueEndpointProperties(_serialization.Model): - """The properties related to service bus queue endpoint types. - - All required parameters must be populated in order to send to server. - - :ivar connection_string: The connection string of the service bus queue endpoint. Required. - :vartype connection_string: str - :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 = { - "connection_string": {"required": True}, - "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, - } - - _attribute_map = { - "connection_string": {"key": "connectionString", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "subscription_id": {"key": "subscriptionId", "type": "str"}, - "resource_group": {"key": "resourceGroup", "type": "str"}, - } - - def __init__( - self, - *, - connection_string: str, - name: str, - subscription_id: Optional[str] = None, - resource_group: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword connection_string: The connection string of the service bus queue endpoint. Required. - :paramtype connection_string: str - :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.connection_string = connection_string - 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 server. - - :ivar connection_string: The connection string of the service bus topic endpoint. Required. - :vartype connection_string: str - :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 = { - "connection_string": {"required": True}, - "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, - } - - _attribute_map = { - "connection_string": {"key": "connectionString", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "subscription_id": {"key": "subscriptionId", "type": "str"}, - "resource_group": {"key": "resourceGroup", "type": "str"}, - } - - def __init__( - self, - *, - connection_string: str, - name: str, - subscription_id: Optional[str] = None, - resource_group: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword connection_string: The connection string of the service bus topic endpoint. Required. - :paramtype connection_string: str - :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.connection_string = connection_string - self.name = name - self.subscription_id = subscription_id - self.resource_group = resource_group - - -class RoutingStorageContainerProperties(_serialization.Model): - """The properties related to a storage container endpoint. - - All required parameters must be populated in order to send to server. - - :ivar connection_string: The connection string of the storage account. Required. - :vartype connection_string: str - :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.v2019_03_22.models.RoutingStorageContainerPropertiesEncoding - """ - - _validation = { - "connection_string": {"required": True}, - "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 = { - "connection_string": {"key": "connectionString", "type": "str"}, - "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, - *, - connection_string: str, - name: str, - container_name: str, - 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 connection_string: The connection string of the storage account. Required. - :paramtype connection_string: str - :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.v2019_03_22.models.RoutingStorageContainerPropertiesEncoding - """ - super().__init__(**kwargs) - self.connection_string = connection_string - 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.v2019_03_22.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.v2019_03_22.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 server. - - :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.v2019_03_22.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.v2019_03_22.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): # pylint: disable=name-too-long - """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.v2019_03_22.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.v2019_03_22.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 server. - - :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. # pylint: disable=line-too-long - :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 - """ - - _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"}, - } - - def __init__( - self, - *, - connection_string: str, - container_name: str, - sas_ttl_as_iso8601: Optional[datetime.timedelta] = 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. # pylint: disable=line-too-long - :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 - """ - super().__init__(**kwargs) - self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 - self.connection_string = connection_string - self.container_name = container_name - - -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", and "DeviceJobLifecycleEvents". - :vartype routing_source: str or ~azure.mgmt.iothub.v2019_03_22.models.RoutingSource - :ivar message: Routing message. - :vartype message: ~azure.mgmt.iothub.v2019_03_22.models.RoutingMessage - :ivar twin: Routing Twin Reference. - :vartype twin: ~azure.mgmt.iothub.v2019_03_22.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", and "DeviceJobLifecycleEvents". - :paramtype routing_source: str or ~azure.mgmt.iothub.v2019_03_22.models.RoutingSource - :keyword message: Routing message. - :paramtype message: ~azure.mgmt.iothub.v2019_03_22.models.RoutingMessage - :keyword twin: Routing Twin Reference. - :paramtype twin: ~azure.mgmt.iothub.v2019_03_22.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.v2019_03_22.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.v2019_03_22.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 server. - - :ivar message: Routing message. - :vartype message: ~azure.mgmt.iothub.v2019_03_22.models.RoutingMessage - :ivar route: Route properties. Required. - :vartype route: ~azure.mgmt.iothub.v2019_03_22.models.RouteProperties - :ivar twin: Routing Twin Reference. - :vartype twin: ~azure.mgmt.iothub.v2019_03_22.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.v2019_03_22.models.RoutingMessage - :keyword route: Route properties. Required. - :paramtype route: ~azure.mgmt.iothub.v2019_03_22.models.RouteProperties - :keyword twin: Routing Twin Reference. - :paramtype twin: ~azure.mgmt.iothub.v2019_03_22.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.v2019_03_22.models.TestResultStatus - :ivar details: Detailed result of testing route. - :vartype details: ~azure.mgmt.iothub.v2019_03_22.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.v2019_03_22.models.TestResultStatus - :keyword details: Detailed result of testing route. - :paramtype details: ~azure.mgmt.iothub.v2019_03_22.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.v2019_03_22.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.v2019_03_22.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.v2019_03_22.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.v2019_03_22.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.v2019_03_22.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.v2019_03_22.models.UserSubscriptionQuota] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/__init__.py deleted file mode 100644 index 32e1fa0a9eb1..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import Operations # type: ignore -from ._iot_hub_resource_operations import IotHubResourceOperations # type: ignore -from ._resource_provider_common_operations import ResourceProviderCommonOperations # type: ignore -from ._certificates_operations import CertificatesOperations # type: ignore -from ._iot_hub_operations import IotHubOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Operations", - "IotHubResourceOperations", - "ResourceProviderCommonOperations", - "CertificatesOperations", - "IotHubOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_patch_sdk() 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 deleted file mode 100644 index 10934f4ec771..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_certificates_operations.py +++ /dev/null @@ -1,859 +0,0 @@ -# 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 -import sys -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.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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", "2019-03-22")) - 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", "2019-03-22")) - 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", "2019-03-22")) - 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", "2019-03-22")) - 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", "2019-03-22")) - 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", "2019-03-22")) - 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.v2019_03_22.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 - :return: CertificateListDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateListDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-03-22")) - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-03-22")) - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - certificate_description: _models.CertificateBodyDescription, - 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.v2019_03_22.models.CertificateBodyDescription - :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 - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.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[bytes], - 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[bytes] - :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 - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.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.CertificateBodyDescription, IO[bytes]], - 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 CertificateBodyDescription - type or a IO[bytes] type. Required. - :type certificate_description: ~azure.mgmt.iothub.v2019_03_22.models.CertificateBodyDescription - or IO[bytes] - :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 - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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, (IOBase, bytes)): - _content = certificate_description - else: - _json = self._serialize.body(certificate_description, "CertificateBodyDescription") - - _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, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("CertificateDescription", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-03-22")) - 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, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @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 - :return: CertificateWithNonceDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateWithNonceDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-03-22")) - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_03_22.models.CertificateVerificationDescription - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.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[bytes]], - **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[bytes] type. Required. - :type certificate_verification_body: - ~azure.mgmt.iothub.v2019_03_22.models.CertificateVerificationDescription or IO[bytes] - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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, (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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 5319018ded20..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_iot_hub_operations.py +++ /dev/null @@ -1,297 +0,0 @@ -# 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 -import sys -from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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", "2019-03-22")) - 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.v2019_03_22.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( - self, - iot_hub_name: str, - resource_group_name: str, - failover_input: Union[_models.FailoverInput, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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 "2019-03-22")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_03_22.models.FailoverInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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[bytes] type. - Required. - :type failover_input: ~azure.mgmt.iothub.v2019_03_22.models.FailoverInput or IO[bytes] - :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 "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) - 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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 4848a7c494c9..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_iot_hub_resource_operations.py +++ /dev/null @@ -1,3125 +0,0 @@ -# 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 -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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", "2019-03-22")) - 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", "2019-03-22")) - 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", "2019-03-22")) - 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", "2019-03-22")) - 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", "2019-03-22")) - 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", "2019-03-22")) - 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", "2019-03-22")) - 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", "2019-03-22")) - 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( # pylint: disable=name-too-long - 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", "2019-03-22")) - 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( # pylint: disable=name-too-long - 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", "2019-03-22")) - 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( # pylint: disable=name-too-long - 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", "2019-03-22")) - 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_event_hub_consumer_group_request( # pylint: disable=name-too-long - 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", "2019-03-22")) - 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", "2019-03-22")) - 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", "2019-03-22")) - 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", "2019-03-22")) - 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", "2019-03-22")) - 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", "2019-03-22")) - 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", "2019-03-22")) - 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", "2019-03-22")) - 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", "2019-03-22")) - 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", "2019-03-22")) - 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", "2019-03-22")) - 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", "2019-03-22")) - 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.v2019_03_22.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 - :return: IotHubDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-03-22")) - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - iot_hub_description: Union[_models.IotHubDescription, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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 "2019-03-22")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_03_22.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 - :return: An instance of LROPoller that returns either IotHubDescription or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_03_22.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[bytes], - 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[bytes] - :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 - :return: An instance of LROPoller that returns either IotHubDescription or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_03_22.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[bytes]], - 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[bytes] type. Required. - :type iot_hub_description: ~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription or IO[bytes] - :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 - :return: An instance of LROPoller that returns either IotHubDescription or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_03_22.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 "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) - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("IotHubDescription", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.IotHubDescription].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.IotHubDescription]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - resource_name: str, - iot_hub_tags: Union[_models.TagsResource, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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 "2019-03-22")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_03_22.models.TagsResource - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either IotHubDescription or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - resource_name: str, - iot_hub_tags: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either IotHubDescription or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_03_22.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[bytes]], - **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[bytes] type. Required. - :type iot_hub_tags: ~azure.mgmt.iothub.v2019_03_22.models.TagsResource or IO[bytes] - :return: An instance of LROPoller that returns either IotHubDescription or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_03_22.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 "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) - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("IotHubDescription", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.IotHubDescription].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.IotHubDescription]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 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 "2019-03-22")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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.v2019_03_22.models.IotHubDescription] - or ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_03_22.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 "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) - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("IotHubDescription", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.IotHubDescription].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.IotHubDescription]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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. - - :return: An iterator like instance of either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.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 "2019-03-22")) - cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :return: An iterator like instance of either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.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 "2019-03-22")) - cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :return: RegistryStatistics or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.RegistryStatistics - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-03-22")) - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: An iterator like instance of either IotHubSkuDescription or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.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 "2019-03-22")) - cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.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 "2019-03-22")) - cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :return: EventHubConsumerGroupInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.EventHubConsumerGroupInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-03-22")) - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def create_event_hub_consumer_group( - self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **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 - :return: EventHubConsumerGroupInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.EventHubConsumerGroupInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-03-22")) - cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) - - _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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-03-22")) - 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, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @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 - :return: An iterator like instance of either JobResponse or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.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 "2019-03-22")) - cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.JobResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-03-22")) - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.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 "2019-03-22")) - cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :return: An iterator like instance of either EndpointHealthData or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.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 "2019-03-22")) - cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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.v2019_03_22.models.OperationInputs - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: IotHubNameAvailabilityInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.IotHubNameAvailabilityInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_name_availability( - self, operation_inputs: IO[bytes], *, 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: IotHubNameAvailabilityInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.IotHubNameAvailabilityInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_name_availability( - self, operation_inputs: Union[_models.OperationInputs, IO[bytes]], **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[bytes] type. Required. - :type operation_inputs: ~azure.mgmt.iothub.v2019_03_22.models.OperationInputs or IO[bytes] - :return: IotHubNameAvailabilityInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.IotHubNameAvailabilityInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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, (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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_03_22.models.TestAllRoutesInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: TestAllRoutesResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.TestAllRoutesResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def test_all_routes( - self, - iot_hub_name: str, - resource_group_name: str, - input: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: TestAllRoutesResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.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[bytes]], - **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[bytes] - type. Required. - :type input: ~azure.mgmt.iothub.v2019_03_22.models.TestAllRoutesInput or IO[bytes] - :return: TestAllRoutesResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.TestAllRoutesResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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, (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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_03_22.models.TestRouteInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: TestRouteResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.TestRouteResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def test_route( - self, - iot_hub_name: str, - resource_group_name: str, - input: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: TestRouteResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.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[bytes]], - **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[bytes] - type. Required. - :type input: ~azure.mgmt.iothub.v2019_03_22.models.TestRouteInput or IO[bytes] - :return: TestRouteResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.TestRouteResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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, (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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.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 "2019-03-22")) - cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.SharedAccessSignatureAuthorizationRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-03-22")) - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_03_22.models.ExportDevicesRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.JobResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def export_devices( - self, - resource_group_name: str, - resource_name: str, - export_devices_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.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[bytes]], - **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[bytes] type. Required. - :type export_devices_parameters: ~azure.mgmt.iothub.v2019_03_22.models.ExportDevicesRequest or - IO[bytes] - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.JobResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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, (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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_03_22.models.ImportDevicesRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.JobResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def import_devices( - self, - resource_group_name: str, - resource_name: str, - import_devices_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.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[bytes]], - **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[bytes] type. Required. - :type import_devices_parameters: ~azure.mgmt.iothub.v2019_03_22.models.ImportDevicesRequest or - IO[bytes] - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.JobResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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, (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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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/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 deleted file mode 100644 index eb441505b9d5..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_resource_provider_common_operations.py +++ /dev/null @@ -1,132 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -import sys -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.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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", "2019-03-22")) - 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.v2019_03_22.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. - - :return: UserSubscriptionQuotaListResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_03_22.models.UserSubscriptionQuotaListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-03-22")) - cls: ClsType[_models.UserSubscriptionQuotaListResult] = kwargs.pop("cls", None) - - _request = build_get_subscription_quota_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/py.typed b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/__init__.py deleted file mode 100644 index ec710f27f0eb..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._iot_hub_client import IotHubClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_patch_sdk() 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 deleted file mode 100644 index 92014c62ce04..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class IotHubClientConfiguration: # 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 "2019-07-01-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: - api_version: str = kwargs.pop("api_version", "2019-07-01-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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**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/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 deleted file mode 100644 index f0c285854fc5..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_iot_hub_client.py +++ /dev/null @@ -1,139 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import IotHubClientConfiguration -from .operations import ( - CertificatesOperations, - IotHubOperations, - IotHubResourceOperations, - Operations, - ResourceProviderCommonOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class IotHubClient: - """Use this API to manage the IoT hubs in your Azure subscription. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.iothub.v2019_07_01_preview.operations.Operations - :ivar iot_hub_resource: IotHubResourceOperations operations - :vartype iot_hub_resource: - azure.mgmt.iothub.v2019_07_01_preview.operations.IotHubResourceOperations - :ivar resource_provider_common: ResourceProviderCommonOperations operations - :vartype resource_provider_common: - azure.mgmt.iothub.v2019_07_01_preview.operations.ResourceProviderCommonOperations - :ivar certificates: CertificatesOperations operations - :vartype certificates: azure.mgmt.iothub.v2019_07_01_preview.operations.CertificatesOperations - :ivar iot_hub: IotHubOperations operations - :vartype iot_hub: azure.mgmt.iothub.v2019_07_01_preview.operations.IotHubOperations - :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 "2019-07-01-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) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **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, "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, "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" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - 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/v2019_07_01_preview/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_metadata.json deleted file mode 100644 index ca9ac08778e7..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_metadata.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "chosen_version": "2019-07-01-preview", - "total_api_version_list": ["2019-07-01-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_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"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\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "operations": "Operations", - "iot_hub_resource": "IotHubResourceOperations", - "resource_provider_common": "ResourceProviderCommonOperations", - "certificates": "CertificatesOperations", - "iot_hub": "IotHubOperations" - } -} diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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/v2019_07_01_preview/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_version.py deleted file mode 100644 index 77f53a3589c6..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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 = "4.0.0" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/__init__.py deleted file mode 100644 index df18749d0db3..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._iot_hub_client import IotHubClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_patch_sdk() 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 deleted file mode 100644 index ac74e8972a32..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class IotHubClientConfiguration: # 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 "2019-07-01-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: - api_version: str = kwargs.pop("api_version", "2019-07-01-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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**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/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 deleted file mode 100644 index 0c97e16e0b77..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_iot_hub_client.py +++ /dev/null @@ -1,142 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import IotHubClientConfiguration -from .operations import ( - CertificatesOperations, - IotHubOperations, - IotHubResourceOperations, - Operations, - ResourceProviderCommonOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class IotHubClient: - """Use this API to manage the IoT hubs in your Azure subscription. - - :ivar operations: Operations operations - :vartype operations: azure.mgmt.iothub.v2019_07_01_preview.aio.operations.Operations - :ivar iot_hub_resource: IotHubResourceOperations operations - :vartype iot_hub_resource: - azure.mgmt.iothub.v2019_07_01_preview.aio.operations.IotHubResourceOperations - :ivar resource_provider_common: ResourceProviderCommonOperations operations - :vartype resource_provider_common: - azure.mgmt.iothub.v2019_07_01_preview.aio.operations.ResourceProviderCommonOperations - :ivar certificates: CertificatesOperations operations - :vartype certificates: - azure.mgmt.iothub.v2019_07_01_preview.aio.operations.CertificatesOperations - :ivar iot_hub: IotHubOperations operations - :vartype iot_hub: azure.mgmt.iothub.v2019_07_01_preview.aio.operations.IotHubOperations - :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 "2019-07-01-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) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **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, "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, "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" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - 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/v2019_07_01_preview/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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/v2019_07_01_preview/aio/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/__init__.py deleted file mode 100644 index 32e1fa0a9eb1..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import Operations # type: ignore -from ._iot_hub_resource_operations import IotHubResourceOperations # type: ignore -from ._resource_provider_common_operations import ResourceProviderCommonOperations # type: ignore -from ._certificates_operations import CertificatesOperations # type: ignore -from ._iot_hub_operations import IotHubOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Operations", - "IotHubResourceOperations", - "ResourceProviderCommonOperations", - "CertificatesOperations", - "IotHubOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_patch_sdk() 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 deleted file mode 100644 index 6da83ab0d5b3..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_certificates_operations.py +++ /dev/null @@ -1,640 +0,0 @@ -# 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 -import sys -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.rest import AsyncHttpResponse, 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 ...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, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2019_07_01_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 - :return: CertificateListDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateListDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-07-01-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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-07-01-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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - certificate_description: _models.CertificateBodyDescription, - 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.v2019_07_01_preview.models.CertificateBodyDescription - :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 - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_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[bytes], - 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[bytes] - :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 - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_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.CertificateBodyDescription, IO[bytes]], - 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 CertificateBodyDescription - type or a IO[bytes] type. Required. - :type certificate_description: - ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateBodyDescription or IO[bytes] - :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 - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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) - - 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, "CertificateBodyDescription") - - _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, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("CertificateDescription", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( - 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-07-01-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, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @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 - :return: CertificateWithNonceDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateWithNonceDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-07-01-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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_07_01_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 - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_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[bytes]], - **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[bytes] type. Required. - :type certificate_verification_body: - ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateVerificationDescription or IO[bytes] - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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) - - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 06660397e4c1..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_iot_hub_operations.py +++ /dev/null @@ -1,252 +0,0 @@ -# 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 -import sys -from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._iot_hub_operations import build_manual_failover_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2019_07_01_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( - self, - iot_hub_name: str, - resource_group_name: str, - failover_input: Union[_models.FailoverInput, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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 "2019-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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]: - """Manual Failover Fail over. - - Perform manual fail over of given hub. - - :param iot_hub_name: IotHub to fail over. Required. - :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. Required. - :type resource_group_name: str - :param failover_input: Region to failover to. Must be a azure DR pair. Required. - :type failover_input: ~azure.mgmt.iothub.v2019_07_01_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 - :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[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Manual Failover Fail over. - - Perform manual fail over of given hub. - - :param iot_hub_name: IotHub to fail over. Required. - :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. Required. - :type resource_group_name: str - :param failover_input: Region to failover to. Must be a azure DR pair. Required. - :type failover_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Manual Failover Fail over. - - Perform manual fail over of given hub. - - :param iot_hub_name: IotHub to fail over. Required. - :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. Required. - :type resource_group_name: str - :param failover_input: Region to failover to. Must be a azure DR pair. Is either a - FailoverInput type or a IO[bytes] type. Required. - :type failover_input: ~azure.mgmt.iothub.v2019_07_01_preview.models.FailoverInput or IO[bytes] - :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 "2019-07-01-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 661ff6007a9a..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_iot_hub_resource_operations.py +++ /dev/null @@ -1,2484 +0,0 @@ -# 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 -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2019_07_01_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 - :return: IotHubDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-07-01-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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - iot_hub_description: Union[_models.IotHubDescription, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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 "2019-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_07_01_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 - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_07_01_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[bytes], - 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[bytes] - :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 - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_07_01_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[bytes]], - 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[bytes] type. Required. - :type iot_hub_description: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription or - IO[bytes] - :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 - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_07_01_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 "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) - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("IotHubDescription", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.IotHubDescription].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.IotHubDescription]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - resource_name: str, - iot_hub_tags: Union[_models.TagsResource, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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 "2019-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_07_01_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 - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_07_01_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_07_01_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[bytes]], - **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[bytes] type. Required. - :type iot_hub_tags: ~azure.mgmt.iothub.v2019_07_01_preview.models.TagsResource or IO[bytes] - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_07_01_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 "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) - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("IotHubDescription", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.IotHubDescription].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.IotHubDescription]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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 "2019-07-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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.v2019_07_01_preview.models.IotHubDescription] - or - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_07_01_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 "2019-07-01-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("IotHubDescription", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.IotHubDescription].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.IotHubDescription]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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. - - :return: An iterator like instance of either IotHubDescription or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_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 "2019-07-01-preview") - ) - cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :return: An iterator like instance of either IotHubDescription or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_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 "2019-07-01-preview") - ) - cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :return: RegistryStatistics or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.RegistryStatistics - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-07-01-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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: An iterator like instance of either IotHubSkuDescription or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_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 "2019-07-01-preview") - ) - cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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"]: - # pylint: disable=line-too-long - """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 - :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_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 "2019-07-01-preview") - ) - cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :return: EventHubConsumerGroupInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.EventHubConsumerGroupInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-07-01-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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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, **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 - :return: EventHubConsumerGroupInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.EventHubConsumerGroupInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-07-01-preview") - ) - cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) - - _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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete_event_hub_consumer_group( - 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-07-01-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, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @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 - :return: An iterator like instance of either JobResponse or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_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 "2019-07-01-preview") - ) - cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-07-01-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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_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 "2019-07-01-preview") - ) - cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :return: An iterator like instance of either EndpointHealthData or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_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 "2019-07-01-preview") - ) - cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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.v2019_07_01_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 - :return: IotHubNameAvailabilityInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubNameAvailabilityInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_name_availability( - self, operation_inputs: IO[bytes], *, 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: IotHubNameAvailabilityInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubNameAvailabilityInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def check_name_availability( - self, operation_inputs: Union[_models.OperationInputs, IO[bytes]], **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[bytes] type. Required. - :type operation_inputs: ~azure.mgmt.iothub.v2019_07_01_preview.models.OperationInputs or - IO[bytes] - :return: IotHubNameAvailabilityInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubNameAvailabilityInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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) - - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_07_01_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 - :return: TestAllRoutesResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: TestAllRoutesResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_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[bytes]], - **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[bytes] - type. Required. - :type input: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestAllRoutesInput or IO[bytes] - :return: TestAllRoutesResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestAllRoutesResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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) - - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_07_01_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 - :return: TestRouteResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestRouteResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def test_route( - self, - iot_hub_name: str, - resource_group_name: str, - input: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: TestRouteResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_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[bytes]], - **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[bytes] - type. Required. - :type input: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestRouteInput or IO[bytes] - :return: TestRouteResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestRouteResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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) - - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_keys( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRule"]: - # pylint: disable=line-too-long - """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 - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the - result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_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 "2019-07-01-preview") - ) - cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.SharedAccessSignatureAuthorizationRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-07-01-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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_07_01_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 - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_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[bytes]], - **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[bytes] type. Required. - :type export_devices_parameters: - ~azure.mgmt.iothub.v2019_07_01_preview.models.ExportDevicesRequest or IO[bytes] - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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) - - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_07_01_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 - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_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[bytes]], - **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[bytes] type. Required. - :type import_devices_parameters: - ~azure.mgmt.iothub.v2019_07_01_preview.models.ImportDevicesRequest or IO[bytes] - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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) - - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 2d52f8e0216f..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_operations.py +++ /dev/null @@ -1,133 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -import sys -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.rest import AsyncHttpResponse, 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 ...operations._operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2019_07_01_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. - - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_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 "2019-07-01-preview") - ) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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/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 deleted file mode 100644 index 19a15c5f3c08..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_resource_provider_common_operations.py +++ /dev/null @@ -1,107 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -import sys -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.rest import AsyncHttpResponse, 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 ...operations._resource_provider_common_operations import build_get_subscription_quota_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2019_07_01_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. - - :return: UserSubscriptionQuotaListResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.UserSubscriptionQuotaListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-07-01-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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/__init__.py deleted file mode 100644 index ae999a71e978..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/__init__.py +++ /dev/null @@ -1,194 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - CertificateBodyDescription, - CertificateDescription, - CertificateListDescription, - CertificateProperties, - CertificatePropertiesWithNonce, - CertificateVerificationDescription, - CertificateWithNonceDescription, - CloudToDeviceProperties, - EndpointHealthData, - EndpointHealthDataListResult, - EnrichmentProperties, - ErrorDetails, - EventHubConsumerGroupInfo, - EventHubConsumerGroupsListResult, - EventHubProperties, - ExportDevicesRequest, - FailoverInput, - FallbackRouteProperties, - FeedbackProperties, - ImportDevicesRequest, - IotHubCapacity, - IotHubDescription, - IotHubDescriptionListResult, - IotHubLocationDescription, - IotHubNameAvailabilityInfo, - IotHubProperties, - IotHubPropertiesDeviceStreams, - IotHubQuotaMetricInfo, - IotHubQuotaMetricInfoListResult, - IotHubSkuDescription, - IotHubSkuDescriptionListResult, - IotHubSkuInfo, - IpFilterRule, - JobResponse, - JobResponseListResult, - MatchedRoute, - MessagingEndpointProperties, - Name, - Operation, - OperationDisplay, - OperationInputs, - OperationListResult, - RegistryStatistics, - Resource, - RouteCompilationError, - RouteErrorPosition, - RouteErrorRange, - RouteProperties, - RoutingEndpoints, - RoutingEventHubProperties, - RoutingMessage, - RoutingProperties, - RoutingServiceBusQueueEndpointProperties, - RoutingServiceBusTopicEndpointProperties, - RoutingStorageContainerProperties, - RoutingTwin, - RoutingTwinProperties, - SharedAccessSignatureAuthorizationRule, - SharedAccessSignatureAuthorizationRuleListResult, - StorageEndpointProperties, - TagsResource, - TestAllRoutesInput, - TestAllRoutesResult, - TestRouteInput, - TestRouteResult, - TestRouteResultDetails, - UserSubscriptionQuota, - UserSubscriptionQuotaListResult, -) - -from ._iot_hub_client_enums import ( # type: ignore - AccessRights, - Capabilities, - EndpointHealthStatus, - IotHubNameUnavailabilityReason, - IotHubReplicaRoleType, - IotHubScaleType, - IotHubSku, - IotHubSkuTier, - IpFilterActionType, - JobStatus, - JobType, - RouteErrorSeverity, - RoutingSource, - RoutingStorageContainerPropertiesEncoding, - TestResultStatus, -) -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CertificateBodyDescription", - "CertificateDescription", - "CertificateListDescription", - "CertificateProperties", - "CertificatePropertiesWithNonce", - "CertificateVerificationDescription", - "CertificateWithNonceDescription", - "CloudToDeviceProperties", - "EndpointHealthData", - "EndpointHealthDataListResult", - "EnrichmentProperties", - "ErrorDetails", - "EventHubConsumerGroupInfo", - "EventHubConsumerGroupsListResult", - "EventHubProperties", - "ExportDevicesRequest", - "FailoverInput", - "FallbackRouteProperties", - "FeedbackProperties", - "ImportDevicesRequest", - "IotHubCapacity", - "IotHubDescription", - "IotHubDescriptionListResult", - "IotHubLocationDescription", - "IotHubNameAvailabilityInfo", - "IotHubProperties", - "IotHubPropertiesDeviceStreams", - "IotHubQuotaMetricInfo", - "IotHubQuotaMetricInfoListResult", - "IotHubSkuDescription", - "IotHubSkuDescriptionListResult", - "IotHubSkuInfo", - "IpFilterRule", - "JobResponse", - "JobResponseListResult", - "MatchedRoute", - "MessagingEndpointProperties", - "Name", - "Operation", - "OperationDisplay", - "OperationInputs", - "OperationListResult", - "RegistryStatistics", - "Resource", - "RouteCompilationError", - "RouteErrorPosition", - "RouteErrorRange", - "RouteProperties", - "RoutingEndpoints", - "RoutingEventHubProperties", - "RoutingMessage", - "RoutingProperties", - "RoutingServiceBusQueueEndpointProperties", - "RoutingServiceBusTopicEndpointProperties", - "RoutingStorageContainerProperties", - "RoutingTwin", - "RoutingTwinProperties", - "SharedAccessSignatureAuthorizationRule", - "SharedAccessSignatureAuthorizationRuleListResult", - "StorageEndpointProperties", - "TagsResource", - "TestAllRoutesInput", - "TestAllRoutesResult", - "TestRouteInput", - "TestRouteResult", - "TestRouteResultDetails", - "UserSubscriptionQuota", - "UserSubscriptionQuotaListResult", - "AccessRights", - "Capabilities", - "EndpointHealthStatus", - "IotHubNameUnavailabilityReason", - "IotHubReplicaRoleType", - "IotHubScaleType", - "IotHubSku", - "IotHubSkuTier", - "IpFilterActionType", - "JobStatus", - "JobType", - "RouteErrorSeverity", - "RoutingSource", - "RoutingStorageContainerPropertiesEncoding", - "TestResultStatus", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_patch_sdk() 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 deleted file mode 100644 index d348e72d3242..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_iot_hub_client_enums.py +++ /dev/null @@ -1,169 +0,0 @@ -# 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 Capabilities(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The capabilities and features enabled for the IoT hub.""" - - NONE = "None" - DEVICE_MANAGEMENT = "DeviceManagement" - - -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" - 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): - """Specific Role assigned to this location.""" - - 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 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" - - -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/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 deleted file mode 100644 index c61dcb39c087..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_models_py3.py +++ /dev/null @@ -1,2978 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- - -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 - -if TYPE_CHECKING: - from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object - - -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 - """ - - _attribute_map = { - "certificate": {"key": "certificate", "type": "str"}, - } - - def __init__(self, *, certificate: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword certificate: base-64 representation of the X509 leaf certificate .cer file or just - .pem file content. - :paramtype certificate: str - """ - super().__init__(**kwargs) - self.certificate = certificate - - -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.v2019_07_01_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.v2019_07_01_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.v2019_07_01_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.v2019_07_01_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}, - "is_verified": {"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, *, certificate: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword certificate: The certificate content. - :paramtype certificate: str - """ - super().__init__(**kwargs) - self.subject = None - self.expiry = None - self.thumbprint = None - self.is_verified = None - 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.v2019_07_01_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.v2019_07_01_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.v2019_07_01_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.v2019_07_01_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 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", "unhealthy", and - "dead". - :vartype health_status: str or - ~azure.mgmt.iothub.v2019_07_01_preview.models.EndpointHealthStatus - """ - - _attribute_map = { - "endpoint_id": {"key": "endpointId", "type": "str"}, - "health_status": {"key": "healthStatus", "type": "str"}, - } - - def __init__( - self, - *, - endpoint_id: Optional[str] = None, - health_status: Optional[Union[str, "_models.EndpointHealthStatus"]] = 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", - "unhealthy", and "dead". - :paramtype health_status: str or - ~azure.mgmt.iothub.v2019_07_01_preview.models.EndpointHealthStatus - """ - super().__init__(**kwargs) - self.endpoint_id = endpoint_id - self.health_status = health_status - - -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.v2019_07_01_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.v2019_07_01_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 server. - - :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 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, str] - :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": "{str}"}, - "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, str]] = None, **kwargs: Any) -> None: - """ - :keyword properties: The tags. - :paramtype properties: dict[str, str] - """ - super().__init__(**kwargs) - self.properties = properties - self.id = None - self.name = None - self.type = None - self.etag = None - - -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.v2019_07_01_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.v2019_07_01_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 server. - - :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 - """ - - _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"}, - } - - def __init__(self, *, export_blob_container_uri: str, exclude_keys: bool, **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 - """ - super().__init__(**kwargs) - self.export_blob_container_uri = export_blob_container_uri - self.exclude_keys = exclude_keys - - -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 server. - - :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 server. - - :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 "DigitalTwinChangeEvents". - :vartype source: str or ~azure.mgmt.iothub.v2019_07_01_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", and "DigitalTwinChangeEvents". - :paramtype source: str or ~azure.mgmt.iothub.v2019_07_01_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 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 server. - - :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 - """ - - _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"}, - } - - def __init__(self, *, input_blob_container_uri: str, output_blob_container_uri: str, **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 - """ - super().__init__(**kwargs) - self.input_blob_container_uri = input_blob_container_uri - self.output_blob_container_uri = output_blob_container_uri - - -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.v2019_07_01_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 server. - - :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 server. - - :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.v2019_07_01_preview.models.IotHubProperties - :ivar sku: IotHub SKU info. Required. - :vartype sku: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSkuInfo - """ - - _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}, - } - - _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"}, - } - - def __init__( - self, - *, - location: str, - sku: "_models.IotHubSkuInfo", - tags: Optional[Dict[str, str]] = None, - etag: Optional[str] = None, - properties: Optional["_models.IotHubProperties"] = 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.v2019_07_01_preview.models.IotHubProperties - :keyword sku: IotHub SKU info. Required. - :paramtype sku: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSkuInfo - """ - super().__init__(location=location, tags=tags, **kwargs) - self.etag = etag - self.properties = properties - self.sku = sku - - -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.v2019_07_01_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.v2019_07_01_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: Azure Geo Regions. - :vartype location: str - :ivar role: Specific Role assigned to this location. Known values are: "primary" and - "secondary". - :vartype role: str or ~azure.mgmt.iothub.v2019_07_01_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: Azure Geo Regions. - :paramtype location: str - :keyword role: Specific Role assigned to this location. Known values are: "primary" and - "secondary". - :paramtype role: str or ~azure.mgmt.iothub.v2019_07_01_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.v2019_07_01_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): - """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.v2019_07_01_preview.models.SharedAccessSignatureAuthorizationRule] - :ivar ip_filter_rules: The IP filter rules. - :vartype ip_filter_rules: list[~azure.mgmt.iothub.v2019_07_01_preview.models.IpFilterRule] - :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.v2019_07_01_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.v2019_07_01_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.v2019_07_01_preview.models.StorageEndpointProperties] - :ivar messaging_endpoints: The messaging endpoint properties for the file upload notification - queue. - :vartype messaging_endpoints: dict[str, - ~azure.mgmt.iothub.v2019_07_01_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.v2019_07_01_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.v2019_07_01_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.v2019_07_01_preview.models.Capabilities - :ivar locations: Primary and secondary location for iot hub. - :vartype locations: - list[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubLocationDescription] - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "state": {"readonly": True}, - "host_name": {"readonly": True}, - "locations": {"readonly": True}, - } - - _attribute_map = { - "authorization_policies": {"key": "authorizationPolicies", "type": "[SharedAccessSignatureAuthorizationRule]"}, - "ip_filter_rules": {"key": "ipFilterRules", "type": "[IpFilterRule]"}, - "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"}, - "locations": {"key": "locations", "type": "[IotHubLocationDescription]"}, - } - - def __init__( - self, - *, - authorization_policies: Optional[List["_models.SharedAccessSignatureAuthorizationRule"]] = None, - ip_filter_rules: Optional[List["_models.IpFilterRule"]] = 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, - **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.v2019_07_01_preview.models.SharedAccessSignatureAuthorizationRule] - :keyword ip_filter_rules: The IP filter rules. - :paramtype ip_filter_rules: list[~azure.mgmt.iothub.v2019_07_01_preview.models.IpFilterRule] - :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.v2019_07_01_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.v2019_07_01_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.v2019_07_01_preview.models.StorageEndpointProperties] - :keyword messaging_endpoints: The messaging endpoint properties for the file upload - notification queue. - :paramtype messaging_endpoints: dict[str, - ~azure.mgmt.iothub.v2019_07_01_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.v2019_07_01_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.v2019_07_01_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.v2019_07_01_preview.models.Capabilities - """ - super().__init__(**kwargs) - self.authorization_policies = authorization_policies - self.ip_filter_rules = ip_filter_rules - 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.locations = None - - -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.v2019_07_01_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.v2019_07_01_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 server. - - :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.v2019_07_01_preview.models.IotHubSkuInfo - :ivar capacity: IotHub capacity. Required. - :vartype capacity: ~azure.mgmt.iothub.v2019_07_01_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.v2019_07_01_preview.models.IotHubSkuInfo - :keyword capacity: IotHub capacity. Required. - :paramtype capacity: ~azure.mgmt.iothub.v2019_07_01_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.v2019_07_01_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.v2019_07_01_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 server. - - :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.v2019_07_01_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.v2019_07_01_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.v2019_07_01_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 server. - - :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.v2019_07_01_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.v2019_07_01_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.v2019_07_01_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.v2019_07_01_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.v2019_07_01_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.v2019_07_01_preview.models.JobResponse] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class MatchedRoute(_serialization.Model): - """Routes that matched. - - :ivar properties: Properties of routes that matched. - :vartype properties: ~azure.mgmt.iothub.v2019_07_01_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.v2019_07_01_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 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.v2019_07_01_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.v2019_07_01_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 server. - - :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.v2019_07_01_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 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.v2019_07_01_preview.models.RouteErrorSeverity - :ivar location: Location where the route error happened. - :vartype location: ~azure.mgmt.iothub.v2019_07_01_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.v2019_07_01_preview.models.RouteErrorSeverity - :keyword location: Location where the route error happened. - :paramtype location: ~azure.mgmt.iothub.v2019_07_01_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.v2019_07_01_preview.models.RouteErrorPosition - :ivar end: End where the route error happened. - :vartype end: ~azure.mgmt.iothub.v2019_07_01_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.v2019_07_01_preview.models.RouteErrorPosition - :keyword end: End where the route error happened. - :paramtype end: ~azure.mgmt.iothub.v2019_07_01_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 server. - - :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 "DigitalTwinChangeEvents". - :vartype source: str or ~azure.mgmt.iothub.v2019_07_01_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", and "DigitalTwinChangeEvents". - :paramtype source: str or ~azure.mgmt.iothub.v2019_07_01_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 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.v2019_07_01_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.v2019_07_01_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.v2019_07_01_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.v2019_07_01_preview.models.RoutingStorageContainerProperties] - """ - - _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]"}, - } - - 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, - **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.v2019_07_01_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.v2019_07_01_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.v2019_07_01_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.v2019_07_01_preview.models.RoutingStorageContainerProperties] - """ - 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 - - -class RoutingEventHubProperties(_serialization.Model): - """The properties related to an event hub endpoint. - - All required parameters must be populated in order to send to server. - - :ivar connection_string: The connection string of the event hub endpoint. Required. - :vartype connection_string: str - :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 = { - "connection_string": {"required": True}, - "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, - } - - _attribute_map = { - "connection_string": {"key": "connectionString", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "subscription_id": {"key": "subscriptionId", "type": "str"}, - "resource_group": {"key": "resourceGroup", "type": "str"}, - } - - def __init__( - self, - *, - connection_string: str, - name: str, - subscription_id: Optional[str] = None, - resource_group: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword connection_string: The connection string of the event hub endpoint. Required. - :paramtype connection_string: str - :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.connection_string = connection_string - 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.v2019_07_01_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.v2019_07_01_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.v2019_07_01_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/iotmsgenrich. - :vartype enrichments: list[~azure.mgmt.iothub.v2019_07_01_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.v2019_07_01_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.v2019_07_01_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.v2019_07_01_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/iotmsgenrich. - :paramtype enrichments: - list[~azure.mgmt.iothub.v2019_07_01_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 server. - - :ivar connection_string: The connection string of the service bus queue endpoint. Required. - :vartype connection_string: str - :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 = { - "connection_string": {"required": True}, - "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, - } - - _attribute_map = { - "connection_string": {"key": "connectionString", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "subscription_id": {"key": "subscriptionId", "type": "str"}, - "resource_group": {"key": "resourceGroup", "type": "str"}, - } - - def __init__( - self, - *, - connection_string: str, - name: str, - subscription_id: Optional[str] = None, - resource_group: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword connection_string: The connection string of the service bus queue endpoint. Required. - :paramtype connection_string: str - :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.connection_string = connection_string - 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 server. - - :ivar connection_string: The connection string of the service bus topic endpoint. Required. - :vartype connection_string: str - :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 = { - "connection_string": {"required": True}, - "name": {"required": True, "pattern": r"^[A-Za-z0-9-._]{1,64}$"}, - } - - _attribute_map = { - "connection_string": {"key": "connectionString", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "subscription_id": {"key": "subscriptionId", "type": "str"}, - "resource_group": {"key": "resourceGroup", "type": "str"}, - } - - def __init__( - self, - *, - connection_string: str, - name: str, - subscription_id: Optional[str] = None, - resource_group: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword connection_string: The connection string of the service bus topic endpoint. Required. - :paramtype connection_string: str - :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.connection_string = connection_string - self.name = name - self.subscription_id = subscription_id - self.resource_group = resource_group - - -class RoutingStorageContainerProperties(_serialization.Model): - """The properties related to a storage container endpoint. - - All required parameters must be populated in order to send to server. - - :ivar connection_string: The connection string of the storage account. Required. - :vartype connection_string: str - :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.v2019_07_01_preview.models.RoutingStorageContainerPropertiesEncoding - """ - - _validation = { - "connection_string": {"required": True}, - "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 = { - "connection_string": {"key": "connectionString", "type": "str"}, - "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, - *, - connection_string: str, - name: str, - container_name: str, - 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 connection_string: The connection string of the storage account. Required. - :paramtype connection_string: str - :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.v2019_07_01_preview.models.RoutingStorageContainerPropertiesEncoding - """ - super().__init__(**kwargs) - self.connection_string = connection_string - 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.v2019_07_01_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.v2019_07_01_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 server. - - :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.v2019_07_01_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.v2019_07_01_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): # pylint: disable=name-too-long - """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.v2019_07_01_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.v2019_07_01_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 server. - - :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. # pylint: disable=line-too-long - :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 - """ - - _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"}, - } - - def __init__( - self, - *, - connection_string: str, - container_name: str, - sas_ttl_as_iso8601: Optional[datetime.timedelta] = 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. # pylint: disable=line-too-long - :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 - """ - super().__init__(**kwargs) - self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 - self.connection_string = connection_string - self.container_name = container_name - - -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 - "DigitalTwinChangeEvents". - :vartype routing_source: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingSource - :ivar message: Routing message. - :vartype message: ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingMessage - :ivar twin: Routing Twin Reference. - :vartype twin: ~azure.mgmt.iothub.v2019_07_01_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", and - "DigitalTwinChangeEvents". - :paramtype routing_source: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingSource - :keyword message: Routing message. - :paramtype message: ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingMessage - :keyword twin: Routing Twin Reference. - :paramtype twin: ~azure.mgmt.iothub.v2019_07_01_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.v2019_07_01_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.v2019_07_01_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 server. - - :ivar message: Routing message. - :vartype message: ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingMessage - :ivar route: Route properties. Required. - :vartype route: ~azure.mgmt.iothub.v2019_07_01_preview.models.RouteProperties - :ivar twin: Routing Twin Reference. - :vartype twin: ~azure.mgmt.iothub.v2019_07_01_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.v2019_07_01_preview.models.RoutingMessage - :keyword route: Route properties. Required. - :paramtype route: ~azure.mgmt.iothub.v2019_07_01_preview.models.RouteProperties - :keyword twin: Routing Twin Reference. - :paramtype twin: ~azure.mgmt.iothub.v2019_07_01_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.v2019_07_01_preview.models.TestResultStatus - :ivar details: Detailed result of testing route. - :vartype details: ~azure.mgmt.iothub.v2019_07_01_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.v2019_07_01_preview.models.TestResultStatus - :keyword details: Detailed result of testing route. - :paramtype details: ~azure.mgmt.iothub.v2019_07_01_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.v2019_07_01_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.v2019_07_01_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.v2019_07_01_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.v2019_07_01_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.v2019_07_01_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.v2019_07_01_preview.models.UserSubscriptionQuota] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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/v2019_07_01_preview/operations/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/__init__.py deleted file mode 100644 index 32e1fa0a9eb1..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import Operations # type: ignore -from ._iot_hub_resource_operations import IotHubResourceOperations # type: ignore -from ._resource_provider_common_operations import ResourceProviderCommonOperations # type: ignore -from ._certificates_operations import CertificatesOperations # type: ignore -from ._iot_hub_operations import IotHubOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "Operations", - "IotHubResourceOperations", - "ResourceProviderCommonOperations", - "CertificatesOperations", - "IotHubOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_patch_sdk() 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 deleted file mode 100644 index b099dc8b6c9e..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_certificates_operations.py +++ /dev/null @@ -1,872 +0,0 @@ -# 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 -import sys -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.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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", "2019-07-01-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", "2019-07-01-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", "2019-07-01-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", "2019-07-01-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", "2019-07-01-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", "2019-07-01-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.v2019_07_01_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 - :return: CertificateListDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateListDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-07-01-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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-07-01-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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - certificate_description: _models.CertificateBodyDescription, - 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.v2019_07_01_preview.models.CertificateBodyDescription - :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 - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_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[bytes], - 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[bytes] - :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 - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_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.CertificateBodyDescription, IO[bytes]], - 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 CertificateBodyDescription - type or a IO[bytes] type. Required. - :type certificate_description: - ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateBodyDescription or IO[bytes] - :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 - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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) - - 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, "CertificateBodyDescription") - - _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, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("CertificateDescription", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-07-01-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, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @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 - :return: CertificateWithNonceDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateWithNonceDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-07-01-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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_07_01_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 - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_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[bytes]], - **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[bytes] type. Required. - :type certificate_verification_body: - ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateVerificationDescription or IO[bytes] - :return: CertificateDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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) - - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index bcc0c2fc8dab..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_iot_hub_operations.py +++ /dev/null @@ -1,289 +0,0 @@ -# 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 -import sys -from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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", "2019-07-01-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.v2019_07_01_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( - self, - iot_hub_name: str, - resource_group_name: str, - failover_input: Union[_models.FailoverInput, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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 "2019-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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]: - """Manual Failover Fail over. - - Perform manual fail over of given hub. - - :param iot_hub_name: IotHub to fail over. Required. - :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. Required. - :type resource_group_name: str - :param failover_input: Region to failover to. Must be a azure DR pair. Required. - :type failover_input: ~azure.mgmt.iothub.v2019_07_01_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 - :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[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Manual Failover Fail over. - - Perform manual fail over of given hub. - - :param iot_hub_name: IotHub to fail over. Required. - :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. Required. - :type resource_group_name: str - :param failover_input: Region to failover to. Must be a azure DR pair. Required. - :type failover_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **kwargs: Any - ) -> LROPoller[None]: - """Manual Failover Fail over. - - Perform manual fail over of given hub. - - :param iot_hub_name: IotHub to fail over. Required. - :type iot_hub_name: str - :param resource_group_name: resource group which Iot Hub belongs to. Required. - :type resource_group_name: str - :param failover_input: Region to failover to. Must be a azure DR pair. Is either a - FailoverInput type or a IO[bytes] type. Required. - :type failover_input: ~azure.mgmt.iothub.v2019_07_01_preview.models.FailoverInput or IO[bytes] - :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 "2019-07-01-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 927e2c7b1a86..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_iot_hub_resource_operations.py +++ /dev/null @@ -1,3192 +0,0 @@ -# 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 -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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", "2019-07-01-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", "2019-07-01-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", "2019-07-01-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", "2019-07-01-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", "2019-07-01-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", "2019-07-01-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", "2019-07-01-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", "2019-07-01-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( # pylint: disable=name-too-long - 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", "2019-07-01-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( # pylint: disable=name-too-long - 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", "2019-07-01-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( # pylint: disable=name-too-long - 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", "2019-07-01-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="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_event_hub_consumer_group_request( # pylint: disable=name-too-long - 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", "2019-07-01-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", "2019-07-01-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", "2019-07-01-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", "2019-07-01-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", "2019-07-01-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", "2019-07-01-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", "2019-07-01-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", "2019-07-01-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", "2019-07-01-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", "2019-07-01-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", "2019-07-01-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", "2019-07-01-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.v2019_07_01_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 - :return: IotHubDescription or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-07-01-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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - iot_hub_description: Union[_models.IotHubDescription, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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 "2019-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_07_01_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 - :return: An instance of LROPoller that returns either IotHubDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_07_01_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[bytes], - 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[bytes] - :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 - :return: An instance of LROPoller that returns either IotHubDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_07_01_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[bytes]], - 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[bytes] type. Required. - :type iot_hub_description: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription or - IO[bytes] - :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 - :return: An instance of LROPoller that returns either IotHubDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_07_01_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 "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) - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("IotHubDescription", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.IotHubDescription].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.IotHubDescription]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - resource_name: str, - iot_hub_tags: Union[_models.TagsResource, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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 "2019-07-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_07_01_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 - :return: An instance of LROPoller that returns either IotHubDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - resource_name: str, - iot_hub_tags: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either IotHubDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_07_01_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[bytes]], - **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[bytes] type. Required. - :type iot_hub_tags: ~azure.mgmt.iothub.v2019_07_01_preview.models.TagsResource or IO[bytes] - :return: An instance of LROPoller that returns either IotHubDescription or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_07_01_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 "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) - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("IotHubDescription", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.IotHubDescription].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.IotHubDescription]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 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 "2019-07-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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.v2019_07_01_preview.models.IotHubDescription] - or ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_07_01_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 "2019-07-01-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("IotHubDescription", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.IotHubDescription].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.IotHubDescription]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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. - - :return: An iterator like instance of either IotHubDescription or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_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 "2019-07-01-preview") - ) - cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :return: An iterator like instance of either IotHubDescription or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_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 "2019-07-01-preview") - ) - cls: ClsType[_models.IotHubDescriptionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :return: RegistryStatistics or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.RegistryStatistics - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-07-01-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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: An iterator like instance of either IotHubSkuDescription or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_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 "2019-07-01-preview") - ) - cls: ClsType[_models.IotHubSkuDescriptionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :return: An iterator like instance of either EventHubConsumerGroupInfo or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_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 "2019-07-01-preview") - ) - cls: ClsType[_models.EventHubConsumerGroupsListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :return: EventHubConsumerGroupInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.EventHubConsumerGroupInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-07-01-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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def create_event_hub_consumer_group( - self, resource_group_name: str, resource_name: str, event_hub_endpoint_name: str, name: str, **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 - :return: EventHubConsumerGroupInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.EventHubConsumerGroupInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-07-01-preview") - ) - cls: ClsType[_models.EventHubConsumerGroupInfo] = kwargs.pop("cls", None) - - _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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-07-01-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, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @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 - :return: An iterator like instance of either JobResponse or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_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 "2019-07-01-preview") - ) - cls: ClsType[_models.JobResponseListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-07-01-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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: An iterator like instance of either IotHubQuotaMetricInfo or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_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 "2019-07-01-preview") - ) - cls: ClsType[_models.IotHubQuotaMetricInfoListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :return: An iterator like instance of either EndpointHealthData or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_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 "2019-07-01-preview") - ) - cls: ClsType[_models.EndpointHealthDataListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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.v2019_07_01_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 - :return: IotHubNameAvailabilityInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubNameAvailabilityInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_name_availability( - self, operation_inputs: IO[bytes], *, 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: IotHubNameAvailabilityInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubNameAvailabilityInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_name_availability( - self, operation_inputs: Union[_models.OperationInputs, IO[bytes]], **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[bytes] type. Required. - :type operation_inputs: ~azure.mgmt.iothub.v2019_07_01_preview.models.OperationInputs or - IO[bytes] - :return: IotHubNameAvailabilityInfo or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubNameAvailabilityInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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) - - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_07_01_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 - :return: TestAllRoutesResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestAllRoutesResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def test_all_routes( - self, - iot_hub_name: str, - resource_group_name: str, - input: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: TestAllRoutesResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_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[bytes]], - **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[bytes] - type. Required. - :type input: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestAllRoutesInput or IO[bytes] - :return: TestAllRoutesResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestAllRoutesResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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) - - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_07_01_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 - :return: TestRouteResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestRouteResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def test_route( - self, - iot_hub_name: str, - resource_group_name: str, - input: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: TestRouteResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_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[bytes]], - **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[bytes] - type. Required. - :type input: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestRouteInput or IO[bytes] - :return: TestRouteResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestRouteResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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) - - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_keys( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Iterable["_models.SharedAccessSignatureAuthorizationRule"]: - # pylint: disable=line-too-long - """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 - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRule or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_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 "2019-07-01-preview") - ) - cls: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :return: SharedAccessSignatureAuthorizationRule or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.SharedAccessSignatureAuthorizationRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-07-01-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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_07_01_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 - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def export_devices( - self, - resource_group_name: str, - resource_name: str, - export_devices_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_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[bytes]], - **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[bytes] type. Required. - :type export_devices_parameters: - ~azure.mgmt.iothub.v2019_07_01_preview.models.ExportDevicesRequest or IO[bytes] - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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) - - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.v2019_07_01_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 - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def import_devices( - self, - resource_group_name: str, - resource_name: str, - import_devices_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_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[bytes]], - **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[bytes] type. Required. - :type import_devices_parameters: - ~azure.mgmt.iothub.v2019_07_01_preview.models.ImportDevicesRequest or IO[bytes] - :return: JobResponse or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "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) - - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 27e75cf42548..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_operations.py +++ /dev/null @@ -1,154 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -import sys -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.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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", "2019-07-01-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.v2019_07_01_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. - - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_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 "2019-07-01-preview") - ) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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/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 deleted file mode 100644 index da3a48cb80d6..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_resource_provider_common_operations.py +++ /dev/null @@ -1,134 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -import sys -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.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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", "2019-07-01-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.v2019_07_01_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. - - :return: UserSubscriptionQuotaListResult or the result of cls(response) - :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.UserSubscriptionQuotaListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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 "2019-07-01-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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/py.typed b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# 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/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/__init__.py deleted file mode 100644 index ec710f27f0eb..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._iot_hub_client import IotHubClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_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 deleted file mode 100644 index 8cbb3db2034e..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class IotHubClientConfiguration: # 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: - 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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**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 deleted file mode 100644 index 1dedfb070e95..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/_iot_hub_client.py +++ /dev/null @@ -1,148 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -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: - from azure.core.credentials import TokenCredential - - -class IotHubClient: # pylint: disable=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) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **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, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - 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 deleted file mode 100644 index 81739d1e6456..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/_metadata.json +++ /dev/null @@ -1,116 +0,0 @@ -{ - "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_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"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\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/_version.py deleted file mode 100644 index 77f53a3589c6..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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 = "4.0.0" 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 deleted file mode 100644 index df18749d0db3..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._iot_hub_client import IotHubClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_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 deleted file mode 100644 index f2acebf38736..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class IotHubClientConfiguration: # 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: - 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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**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 deleted file mode 100644 index b37ff2b3a7e1..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/_iot_hub_client.py +++ /dev/null @@ -1,151 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -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: - from azure.core.credentials_async import AsyncTokenCredential - - -class IotHubClient: # pylint: disable=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) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **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, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - 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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_operations.py deleted file mode 100644 index a45b580d87e5..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_operations.py +++ /dev/null @@ -1,131 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -import sys -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.rest import AsyncHttpResponse, 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 ...operations._operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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. - - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) 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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/models/__init__.py deleted file mode 100644 index aa50cf715ae2..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/models/__init__.py +++ /dev/null @@ -1,238 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - 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, -) - -from ._iot_hub_client_enums import ( # type: ignore - AccessRights, - AuthenticationType, - Capabilities, - CreatedByType, - DefaultAction, - EndpointHealthStatus, - IotHubNameUnavailabilityReason, - IotHubReplicaRoleType, - IotHubScaleType, - IotHubSku, - IotHubSkuTier, - IpFilterActionType, - JobStatus, - JobType, - NetworkRuleIPAction, - PrivateLinkServiceConnectionStatus, - PublicNetworkAccess, - ResourceIdentityType, - RouteErrorSeverity, - RoutingSource, - RoutingStorageContainerPropertiesEncoding, - TestResultStatus, -) -from ._patch import __all__ as _patch_all -from ._patch 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__]) # pyright: ignore -_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 deleted file mode 100644 index 2d31d1e7ac49..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/models/_iot_hub_client_enums.py +++ /dev/null @@ -1,230 +0,0 @@ -# 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 deleted file mode 100644 index e56420a2686a..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/models/_models_py3.py +++ /dev/null @@ -1,4078 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- - -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 - -if TYPE_CHECKING: - 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 server. - - :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 server. - - :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 server. - - :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 server. - - :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 server. - - :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 server. - - :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 server. - - :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 server. - - :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 server. - - :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 server. - - :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): - """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 server. - - :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 server. - - :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 server. - - :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 server. - - :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 server. - - :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 server. - - :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 server. - - :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 server. - - :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 server. - - :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 server. - - :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): - """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 server. - - :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 server. - - :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 server. - - :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 server. - - :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): - """The properties related to a storage container endpoint. - - All required parameters must be populated in order to send to server. - - :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 server. - - :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): # pylint: disable=name-too-long - """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 server. - - :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. # pylint: disable=line-too-long - :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. # pylint: disable=line-too-long - :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 server. - - :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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_operations.py deleted file mode 100644 index 6d6f86f6d063..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_operations.py +++ /dev/null @@ -1,152 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -import sys -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.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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. - - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) 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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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/py.typed b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30/py.typed +++ /dev/null @@ -1 +0,0 @@ -# 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 deleted file mode 100644 index ec710f27f0eb..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._iot_hub_client import IotHubClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_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 deleted file mode 100644 index e006dbc459b7..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class IotHubClientConfiguration: # 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: - 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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**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 deleted file mode 100644 index a07680c62afc..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/_iot_hub_client.py +++ /dev/null @@ -1,153 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -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: - from azure.core.credentials import TokenCredential - - -class IotHubClient: # pylint: disable=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) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **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, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - 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 deleted file mode 100644 index 0d2f1485692e..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/_metadata.json +++ /dev/null @@ -1,116 +0,0 @@ -{ - "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_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"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\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/_version.py deleted file mode 100644 index 77f53a3589c6..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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 = "4.0.0" 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 deleted file mode 100644 index df18749d0db3..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._iot_hub_client import IotHubClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_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 deleted file mode 100644 index 3d6cfa29acf1..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class IotHubClientConfiguration: # 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: - 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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**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 deleted file mode 100644 index 878509ef8c21..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/_iot_hub_client.py +++ /dev/null @@ -1,156 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -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: - from azure.core.credentials_async import AsyncTokenCredential - - -class IotHubClient: # pylint: disable=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) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **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, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - 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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index 7f2b24868d73..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/__init__.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import Operations # type: ignore -from ._iot_hub_resource_operations import IotHubResourceOperations # type: ignore -from ._resource_provider_common_operations import ResourceProviderCommonOperations # type: ignore -from ._certificates_operations import CertificatesOperations # type: ignore -from ._iot_hub_operations import IotHubOperations # type: ignore -from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch 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__]) # pyright: ignore -_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 deleted file mode 100644 index 4f5ce9246ebd..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_certificates_operations.py +++ /dev/null @@ -1,640 +0,0 @@ -# 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 -import sys -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.rest import AsyncHttpResponse, 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 ...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, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - 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[bytes] - :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 - :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[bytes]], - 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[bytes] type. Required. - :type certificate_description: - ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateDescription or IO[bytes] - :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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("CertificateDescription", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( - 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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[bytes] type. Required. - :type certificate_verification_body: - ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateVerificationDescription or IO[bytes] - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index bd259dacc53b..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_iot_hub_operations.py +++ /dev/null @@ -1,271 +0,0 @@ -# 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 -import sys -from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._iot_hub_operations import build_manual_failover_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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( - self, - iot_hub_name: str, - resource_group_name: str, - failover_input: Union[_models.FailoverInput, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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[bytes] type. - Required. - :type failover_input: ~azure.mgmt.iothub.v2023_06_30_preview.models.FailoverInput or IO[bytes] - :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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index ec0a02ceb9b4..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_iot_hub_resource_operations.py +++ /dev/null @@ -1,2594 +0,0 @@ -# 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 -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - iot_hub_description: Union[_models.IotHubDescription, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - 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[bytes] - :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 - :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[bytes]], - 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[bytes] type. Required. - :type iot_hub_description: ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription or - IO[bytes] - :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 - :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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("IotHubDescription", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.IotHubDescription].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.IotHubDescription]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - resource_name: str, - iot_hub_tags: Union[_models.TagsResource, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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[bytes] type. Required. - :type iot_hub_tags: ~azure.mgmt.iothub.v2023_06_30_preview.models.TagsResource or IO[bytes] - :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 - ) - await raw_result.http_response.read() # type: ignore - 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.http_response) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - 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[_models.IotHubDescription].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.IotHubDescription]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("IotHubDescription", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.IotHubDescription].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.IotHubDescription]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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. - - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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"]: - # pylint: disable=line-too-long - """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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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[bytes] type. Required. - :type consumer_group_body: - ~azure.mgmt.iothub.v2023_06_30_preview.models.EventHubConsumerGroupBodyDescription or IO[bytes] - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete_event_hub_consumer_group( - 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :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[bytes], *, 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], **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[bytes] type. Required. - :type operation_inputs: ~azure.mgmt.iothub.v2023_06_30_preview.models.OperationInputs or - IO[bytes] - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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[bytes] - type. Required. - :type input: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestAllRoutesInput or IO[bytes] - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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[bytes] - type. Required. - :type input: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestRouteInput or IO[bytes] - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_keys( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRule"]: - # pylint: disable=line-too-long - """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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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[bytes] type. Required. - :type export_devices_parameters: - ~azure.mgmt.iothub.v2023_06_30_preview.models.ExportDevicesRequest or IO[bytes] - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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[bytes] type. Required. - :type import_devices_parameters: - ~azure.mgmt.iothub.v2023_06_30_preview.models.ImportDevicesRequest or IO[bytes] - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 596a1b92bf59..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_operations.py +++ /dev/null @@ -1,133 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -import sys -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.rest import AsyncHttpResponse, 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 ...operations._operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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. - - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) 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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index 09beffb42a6e..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,541 +0,0 @@ -# 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 -import sys -from typing import Any, AsyncIterator, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._private_endpoint_connections_operations import ( - build_delete_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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[bytes] type. Required. - :type private_endpoint_connection: - ~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateEndpointConnection or IO[bytes] - :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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 97c5f9f891ea..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_private_link_resources_operations.py +++ /dev/null @@ -1,177 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -import sys -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.rest import AsyncHttpResponse, 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 ...operations._private_link_resources_operations import build_get_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index a6c11a496113..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/aio/operations/_resource_provider_common_operations.py +++ /dev/null @@ -1,107 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -import sys -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.rest import AsyncHttpResponse, 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 ...operations._resource_provider_common_operations import build_get_subscription_quota_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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. - - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index 7f2b24868d73..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/__init__.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import Operations # type: ignore -from ._iot_hub_resource_operations import IotHubResourceOperations # type: ignore -from ._resource_provider_common_operations import ResourceProviderCommonOperations # type: ignore -from ._certificates_operations import CertificatesOperations # type: ignore -from ._iot_hub_operations import IotHubOperations # type: ignore -from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch 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__]) # pyright: ignore -_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 deleted file mode 100644 index 9a8d543a61c3..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_certificates_operations.py +++ /dev/null @@ -1,872 +0,0 @@ -# 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 -import sys -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.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - 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[bytes] - :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 - :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[bytes]], - 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[bytes] type. Required. - :type certificate_description: - ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateDescription or IO[bytes] - :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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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) - - deserialized = self._deserialize("CertificateDescription", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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[bytes] type. Required. - :type certificate_verification_body: - ~azure.mgmt.iothub.v2023_06_30_preview.models.CertificateVerificationDescription or IO[bytes] - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 4ebee9997d67..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_iot_hub_operations.py +++ /dev/null @@ -1,308 +0,0 @@ -# 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 -import sys -from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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( - self, - iot_hub_name: str, - resource_group_name: str, - failover_input: Union[_models.FailoverInput, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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[bytes] type. - Required. - :type failover_input: ~azure.mgmt.iothub.v2023_06_30_preview.models.FailoverInput or IO[bytes] - :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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index e4f0562f0c7a..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_iot_hub_resource_operations.py +++ /dev/null @@ -1,3305 +0,0 @@ -# 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 -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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( # pylint: disable=name-too-long - 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( # pylint: disable=name-too-long - 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( # pylint: disable=name-too-long - 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( # pylint: disable=name-too-long - 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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - resource_name: str, - iot_hub_description: Union[_models.IotHubDescription, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - 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[bytes] - :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 - :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[bytes]], - 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[bytes] type. Required. - :type iot_hub_description: ~azure.mgmt.iothub.v2023_06_30_preview.models.IotHubDescription or - IO[bytes] - :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 - :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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("IotHubDescription", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.IotHubDescription].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.IotHubDescription]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - resource_name: str, - iot_hub_tags: Union[_models.TagsResource, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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[bytes] type. Required. - :type iot_hub_tags: ~azure.mgmt.iothub.v2023_06_30_preview.models.TagsResource or IO[bytes] - :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 - ) - raw_result.http_response.read() # type: ignore - 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.http_response) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - 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[_models.IotHubDescription].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.IotHubDescription]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 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[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("IotHubDescription", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.IotHubDescription].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.IotHubDescription]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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. - - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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[bytes] type. Required. - :type consumer_group_body: - ~azure.mgmt.iothub.v2023_06_30_preview.models.EventHubConsumerGroupBodyDescription or IO[bytes] - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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, {}) # type: ignore - - @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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :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[bytes], *, 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], **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[bytes] type. Required. - :type operation_inputs: ~azure.mgmt.iothub.v2023_06_30_preview.models.OperationInputs or - IO[bytes] - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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[bytes] - type. Required. - :type input: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestAllRoutesInput or IO[bytes] - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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[bytes] - type. Required. - :type input: ~azure.mgmt.iothub.v2023_06_30_preview.models.TestRouteInput or IO[bytes] - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_keys( - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> Iterable["_models.SharedAccessSignatureAuthorizationRule"]: - # pylint: disable=line-too-long - """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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - @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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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[bytes] type. Required. - :type export_devices_parameters: - ~azure.mgmt.iothub.v2023_06_30_preview.models.ExportDevicesRequest or IO[bytes] - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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[bytes] type. Required. - :type import_devices_parameters: - ~azure.mgmt.iothub.v2023_06_30_preview.models.ImportDevicesRequest or IO[bytes] - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 8b1bb376d778..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_operations.py +++ /dev/null @@ -1,154 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -import sys -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.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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. - - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) 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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index 5d9e5a31af8f..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,687 +0,0 @@ -# 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 -import sys -from typing import Any, Callable, Dict, IO, Iterator, List, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _update_initial( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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[bytes] type. Required. - :type private_endpoint_connection: - ~azure.mgmt.iothub.v2023_06_30_preview.models.PrivateEndpointConnection or IO[bytes] - :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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 9f8af9aab995..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_private_link_resources_operations.py +++ /dev/null @@ -1,243 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -import sys -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.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index bb7dacfa1e80..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/operations/_resource_provider_common_operations.py +++ /dev/null @@ -1,134 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -import sys -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.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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. - - :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: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2023_06_30_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index b6e032c27ba1..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/generated_samples/iothub_add_routing_cosmos_db_endpoint.py +++ /dev/null @@ -1,110 +0,0 @@ -# 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/pyproject.toml b/sdk/iothub/azure-mgmt-iothub/pyproject.toml index 540da07d41af..563b5351f389 100644 --- a/sdk/iothub/azure-mgmt-iothub/pyproject.toml +++ b/sdk/iothub/azure-mgmt-iothub/pyproject.toml @@ -4,3 +4,12 @@ mypy = false pyright = false type_check_samples = false verifytypes = false + +[packaging] +package_name = "azure-mgmt-iothub" +package_pprint_name = "IoT Hub Management" +package_doc_id = "iot" +is_stable = false +is_arm = true +sample_link = "" +title = "IotHubClient" diff --git a/sdk/iothub/azure-mgmt-iothub/sdk_packaging.toml b/sdk/iothub/azure-mgmt-iothub/sdk_packaging.toml deleted file mode 100644 index b9a25c5cb5e1..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/sdk_packaging.toml +++ /dev/null @@ -1,8 +0,0 @@ -[packaging] -package_name = "azure-mgmt-iothub" -package_pprint_name = "IoT Hub Management" -package_doc_id = "iot" -is_stable = true -is_arm = true -sample_link = "" -title = "IotHubClient" diff --git a/sdk/iothub/azure-mgmt-iothub/setup.py b/sdk/iothub/azure-mgmt-iothub/setup.py index ce72712f1af9..d0ce6746026d 100644 --- a/sdk/iothub/azure-mgmt-iothub/setup.py +++ b/sdk/iothub/azure-mgmt-iothub/setup.py @@ -49,15 +49,15 @@ url="https://github.com/Azure/azure-sdk-for-python", keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product classifiers=[ - "Development Status :: 5 - Production/Stable", + "Development Status :: 4 - Beta", "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "License :: OSI Approved :: MIT License", ], zip_safe=False, @@ -77,7 +77,7 @@ "isodate>=0.6.1", "typing-extensions>=4.6.0", "azure-common>=1.1", - "azure-mgmt-core>=1.3.2", + "azure-mgmt-core>=1.6.0", ], - python_requires=">=3.8", + python_requires=">=3.9", )